## n x n determinant | Matrix transformations | Linear Algebra | Khan Academy

So far we’ve been able to define
the determinant for a 2-by-2 matrix. This was our definition right
that a bit by creating a definition for the determinant
of a 3-by-3 matrix, and we did that right
here, where we essentially said the determinant is equal
to each of these terms– you could call these maybe the
coefficient terms– times the determinant of the matrix– you
can kind of view it as the submatrix produced– when you
get rid of each of these guys’ column and row. So when you got rid of this
guy’s column and row, you’re left with this matrix. So we said this guy times
the determinant of this. And we kept switching signs,
minus this guy times the determinant, if you move
his column and his row. So it was left with these terms
right there to get that determinant. Then finally, you switched
signs again. So plus this guy times the
determinant of the 2-by-2 matrix if you get rid of this
row and this column. So this thing right here,
extend this to a general n-by-n matrix. So let’s write out our n-by-n
matrix right over here. I’ll do it in blue. So let’s say I have some matrix
A that is an n-by-n matrix, so it’s going
to look like this. This would be a11, that would
be a12, and we would go all the way to– you’re going
to have n columns, a1n. And when you go down, this is
going to be your second row: a21, and it’s going to go all
the way down to an1, because you have n rows as well. And then if you go down the
diagonal all the way, this right here would be ann. So there is my n-by-n matrix. Now, before I define how to find
the determinant of this, let me make another
definition. Let me define– so this
is my matrix A. Let me define a submatrix Aij to
be equal to– see this is n by n, right? So this is going to be an n
minus 1 by n minus 1 matrix. So if this is 7 by 7, the
submatrix is going to be 6 by 6, one less in each direction. So this is going to be the n
minus 1 by n minus 1 matrix you get if you essentially
ignore or if you take away– maybe I should say take away. Let’s say ignore, like
the word ignore. If you ignore the i-th row, this
right here is the row, the i-th row and the
j-th column of a. So, for example, let’s go back
to our 3 by 3 right here. This thing could be denoted
based on that definition I– we could have called
this, this was a11, this term right here. We could denote the matrix when
you get rid of the first column and the first row or the
first row and the first column, we could call this thing
right here, we could call that big matrix A11. So this was big matrix A11. This is big matrix A21, or
actually, this matrix was called C, so this would
be C11 right there. We could call this one, this
would be matrix C12. Why is that? Because if you get rid of the
first row, let me get rid of the first row, right? The first term is your row. If you get rid of the first
row and the second column, this is the matrix that’s
left over: 2, 3, 4, 1. So this is this guy
and this guy. 2, 3, 4, 1. So this is the submatrix c
because this is the big matrix C, But this one is C12. I know it’s a little
bit messy there. So that’s all we mean
by the submatrix. Very similar to what we did
in the 3 by 3 case. You essentially get rid of–
so if you want to find out this guy’s submatrix, you would
call that a11, and you would literally cross out the
first row and the first column, and everything
left over here would be that submatrix. Now, with that out of the way,
we can create a definition, and it might seem a little
circular to you at first, and on some level it is. We’re going to define the
determinant of A to be equal to– this is interesting. It’s actually a recursive
in a second. It’s equal to– we start
with a plus. It’s equal to a11 times the
submatrix if you remove this guy’s row and column. So that, by definition, is
just A, big capital A11’s determinant. So that’s exactly what we did. Let me write that a
little bit neater. So times the determinant of
its submatrix, so the determinant of A11. So you take A11, you get rid of
its column and its row or its row and its column, and
everything else, you find the determinant of that. Actually, let me write it
in terms of– let me write it this way. a11 times the determinant
of the submatrix A11. And then we switch sides. We’re just going to go along
this row, and then you do minus a12 times the determinant
of its submatrix, which we’ll just call A12. We would get rid of this row
and this column, and everything left would
be this matrix A12. We want to find its
determinant. And then we’ll take the next
guy over here would be a13. So we switch signs with minus. Now, you go plus,
so a13 times the determinant of its submatrix. So if this is n by n, these each
are going to be n minus 1 by n minus 1. So the determinant of A13. And you’re just going to keep
doing that, keep switching signs, so it’s going to be a
minus and then a plus and you keep going all the way–
and then I don’t know. It depends on whether an,
whether we’re dealing with an odd number or an even number. If we’re dealing with an even
number, this is going to be a minus sign. If it’s an odd number, it’s
going to be a plus sign, but you get the idea. It’s either going to be a plus
or a minus, not just– if it’s odd, this is going
to be a plus. If it’s an even n, it’s going to
be a minus, All the way to a1n, the n-th column times
its submatrix, A1n. With that submatrix, you get rid
of the first row and the n-th column, and it’s going
to be everything that’s left in between. And you immediately might
say, Sal, what kind of a definition is this? You defined a determinant for an
arbitrary n-by-n matrix in terms of another definition
of a determinant. How does this work? And the reason why this works
is because the determinant that you use in the definition
are determinants of a smaller matrix. So this is a determinant of an n
minus 1 by n minus 1 matrix. And you’re saying hey, Sal, that
still doesn’t make any sense because we don’t know how
to find the determinant of an n minus 1 by n
minus 1 matrix. Well, you apply this definition
again, and then it’s going to be in terms of n
minus 2 times n– or n minus 2 by n minus 2 matrices. And you’re like how
do you do that? Well, you keep doing it, and
you’re going to get all the way down to a 2-by-2 matrix. And that one we defined well. We defined the determinant of
a 2-by-2 matrix not in terms of a determinant. We just defined it in terms of
a times– we defined it as– let me write it up here. It was a times d minus
b times c. And you can see. I mean, we could just go down to
the 3 by 3, but the 2 by 2 is really the most fundamental
definition. And you could see that the
definition of a 3-by-3 determinant is a special
case of the general case for an n by n. We take this guy and we
multiply him times the determinant of his submatrix
right there. Then we take this guy where
we switch signs. We have a minus. And we multiply him times the
determinant of his submatrix, which is that right there. Then you do a plus. You switch signs and then you
multiply this guy times the determinant of his submatrix,
which is that right there. So this is a general case
of what I just defined. But we know it’s never that
satisfying to deal in the abstract or the generalities. We want to do a specific case. And actually, before I do that,
let me just introduce a term to you. This is called a recursive
formula. And if you become a computer
science major, you’ll see this a lot. But a recursive function or a
recursive formula is defined in terms of itself. But the things that you use in
the definition use a slightly simpler version of it, and as
you keep going through, or you keep recursing through it, you
get simpler and simpler versions of it until you get
to some type of base case. In this case, our base case is
the case of a 2-by-2 matrix. You keep doing this, and
eventually you’ll get to a determinant of a 2-by-2 matrix,
and we know how to find those. So this is a recursive
definition. But let’s actually apply it
because I think that’s what actually makes things
concrete. So let’s take– this is going
to be computationally intensive, but I think if we
focus, we can get there. So I’m going to have a 4-by-4
matrix: 1, 2, 3, 4. 1– throw some zeroes in there
to make the computation a little bit simpler, 0, 1, 2,
3, and then 2, 3, 0, 0. So let’s figure out this
determinant right there. This is the determinant
of the matrix. If I put some brackets
there that would have been the matrix. But let’s find the determinant
of this matrix. So this is going to be equal
to– by our definition, it’s going to be equal to 1 times the
determinant of this matrix right here if you get rid of
this row and this column. So it’s going to be 1 times the
determinant of 0, 2, 0; 1, 2, 3; 3, 0, 0. That’s just this guy right here,
this matrix right there. Then I’m going to have a 2, but
I’m going to switch signs. So it’s minus 2 times the
determinant if I get rid of that row and this column,
so it’s 1, 2, 0. I’m ignoring the zero because
it’s in the same column as the 2: 1, 2, 0; 0, 2, 3,
and then 2, 0, 0. And then I switch signs again. It was a minus, so now
I go back to plus. So I do that guy, so
plus 3 times the determinant of his submatrix. Get rid of that row and get
rid of that columm, I get a 1, 0, 0. I get a 0, 1, 3. I skip this column every time. Then I get a 2, 3, 0,
just like that. We’re almost done. One more in this column. Let me switch to
another color. I haven’t used the
blue in this yet. So then I’m going
to do a minus 4. Remember, it’s plus, minus,
plus, minus 4 times the determinant of its submatrix. That’s going to be
that right there. So it’s 1, 0, 2; 0, 1, 2;
2, 3, 0, just like that. And now we’re down to
the 3-by-3 case. We could use the definition of
the 3 by 3, but we could just keep applying this recursive
definition. So this is going to be equal
to– let me write it here. It’s 1 times– what’s
this determinant? This determinant’s going to be
0 times the determinant of that submatrix, 2, 3, 0, 0. That was this one right here. And then we have minus 2, minus
this 2– remember, we switched signs– plus, minus,
plus, so minus 2 times its submatrix, so it’s 1, 3, 3, 0. And then finally plus 0 times
its submatrix, which is this thing right here: 1, 2,
3, 0, just like that. And then we have this
next guy right here. As you can see, this can get a
little bit tedious, but we’ll keep our spirits up. So minus 2 times 1 times its
submatrix, so that’s this guy right here– times the
determinant of its submatrix 2, 3, 0, 0. Then minus 2 times– get
rid of that row, that column– 0, 3, 2, 0. And then plus 0 times
0, 2, 2, 0. That’s this one right there. Halfway there, at
least for now. And then we get this next one,
so we have a plus 3. Bring out our parentheses. And then we’re going to have 1
times its sub– I guess call it sub-determinant. So 1 times the determinant
1, 3, 3, 0, right? You get rid of this guy’s row
and column, you get this guy right there. And then minus 0– get rid
of this row and column– times 0, 3, 2, 0. Then you have plus 0 times its
sub-determinant 0, 1, 2, 3. Three-fourths of
the way there. One last term. Let’s hope we haven’t made
any careless mistakes. Minus 4 times 1 times 1,
2, 3, 0 right there. Minus 0 times– get rid of those
two guys– 0, 2, 2, 0. And then plus 2 times
0, 1, 2, 3, right? Plus 2– get rid of these
guys– 0, 1, 2, 3. Now, we’ve defined or we’ve
calculated or we’ve defined our determinant of this matrix
in terms of just a bunch of 2-by-2 matrices. So hopefully, you saw in this
example that the recursion worked out. So let’s actually find what
this number is equal to. A determinant is always just
going to be a number. So let me get a nice
vibrant color. This is 0 times–
I don’t care. 0 times anything’s
going to be 0. 0 times anything is
going to be 0. 0 times anything’s
going to be 0. 0 times anything’s
going to be 0. Just simplifying it. These guys are 0 because
it’s 0 times that. 0 times this is going
to be equal to 0. So what are we left with? This is going to be equal to 1
times– this is all we have left here is a minus 2 times–
and what is this determinant? It’s 1 times 0, which is 0. It’s 0– let me write this. This is going to be 1 times 0
is 0, minus 3 times 3 is 0 minus 9, so minus 9. This right here is
just minus 9. So minus 2 times minus 9. That’s our first thing, I’ll
simplify it in a second. Now let’s do this
term right here. So it’s minus 2 times– now
what’s this determinant? 2 times 0 minus 0 times 3. That’s 0 minus 0. So this is 0. That guy became 0, so we
can ignore that term. This term right here is
0 times 0, which is 0, minus 2 times 3. So it’s minus 6. So it’s minus 2 times– so this
is a minus 6 right here. You have a minus 2 times a minus
6, so that’s a plus 12. So I’ll just write
a plus 12 here. This minus 2 is that minus
2 right there. And then we have a plus 3. And then this first term is 1
times 0, which is 0, minus– let me make the parentheses
here– 1 times 0, which is 0, minus 3 times 3, which
is minus 9 times 1. So it’s minus 9. Everything else was a 0. We’re in the home stretch. We have a minus 4. Let’s see, this is 1 times 0,
which is 0, minus 3 times 2, so minus 6. So this is minus 6 right here. Minus 6, this is 0, and then we
have this guy right here. So we have 0 times 3, which
is 0, minus 2 times 1. So that’s minus 2, and then
you have a minus 2 times a plus 2 is minus 4. So now we just have
to make sure we do our arithmetic properly. This is 1 times plus 18,
so this is 18, right? Minus 2 times minus 9. This right here is minus 24. This right here is minus 27. And then this right here, let’s
see, this is minus 10 right here. That is minus 10. Minus 4 times minus
10 is plus 40. Let’s see if we can simplify
this a little bit. If we simplify this a little
bit– I don’t want to make a careless mistake right
at the end. So 18 minus 24, 24 minus 18 is
6, so this is going to be equal to minus 6, right? 18 minus 24 is minus 6. And then– let me do it in
green– now what’s the difference? If we have minus 27 plus
40, that’s 13, right? It’s positive 13. So minus 6 plus positive
13 is equal to 7. And so we are done! After all of that computation,
hopefully we haven’t made a careless mistake. The determinant of this
character right here is equal to 7. The determinant is equal to 7. And so the one useful takeaway,
we know that this is invertible because it has
a non-zero determinant. Hopefully, you found
that useful.

## 80 thoughts on “n x n determinant | Matrix transformations | Linear Algebra | Khan Academy”

1. dannyboy12357 says:

i appreciate your vids : )

2. Aghoriii says:

thank you Sal you are amazing

3. bass says:

It's Sal!

4. VelAmi19 says:

God bless you dude I really mean it ! =)

5. MrCalhoun says:

Lol I tried solving this via transforming it into an triangular matrix and then just taking the determinant by calculating the product of the primary diagonal elements. Turned out that I copied a number wrong and I kept wondering if I have done anything wrong since my determinant always became 0. 😀
I also once used Laplace to calculate the determinants in some homework. Turned out I've forgotten about basic determinant rules and so I calculated the easiest stuff with the most difficult way.

6. Jon Benedict says:

sal why dont you teach me the math behind electromagnetics. could sure use your help there haha

7. Person says:

Cool, I was making a Class Library in C# for matrices and needed a method for determining the determinant. It was much easier than I originally thought it would be to implement (because of recursion). Sal, you should do some Computer Science videos. I'm tired of everyone asking me to tutor them.

8. epgmw says:

Thanks a lot, very helpfull indeed. Keep up the good work

9. narical says:

sal u should post videos for computer science major !!!!!!!!

10. dilly karim says:

thank you so much, this is brilliant, it made such an impact!

11. ninjaturtle205 says:

<3

12. Daniel Masters says:

Multiplying by 0 is the shiznit.
Sal, you rock as usual.

13. 7orqu3 says:

the cramer method is fastest way of getting a 3×3

14. Michael T says:

great for nontraditional students who didn't do this stuff in high school. I need these things "dumbed down" (I mean that in the most respectful way). Thanks for the help!

15. Wilson Property says:

damn my brain wanna explode!!

16. MobiusCoin says:

I know this is just the natural function of numbers and has no sentient quality to it whatsoever but somehow this feels evil…

17. TRANsCEllular Sound says:

u rock!

18. Bat man says:

have an exam tommorow ..
Dosent matter you there ! my savior thank you !

19. Syeal7 says:

"We are afraid of what we don't understand." … Well I guess you dont get this then ;P Haha naah just kidding :))) Cheeers maan!

frickin awesome dude

21. William Reyes says:

Finally!!! I swear my linear algebra teacher sucks. 20 min on YouTube is better than an 1hr of lecture.

22. FourtwentySoldier says:

I'm glad I found your channel. It helps a lot. Thanks! and the subtitles are appreciated as well

23. Ido Zemach says:

But why does this work? I mean, why does when the det=0 when calculated this way makes the matrix not invertable?

24. Lord McSwain says:

Yes, but only because 1/0 is undefined.

25. Lord McSwain says:

How dare you insult your linear algebra teacher!

26. eow says:

yea, QQ some more like you know his algebra teacher

27. Zach O says:

Thank you so much.

28. Christopher Hunter Smith says:

Quiz tomorrow, thanks for your help!

29. mike vermeer says:

nice

30. Iman Moghimi says:

final exam in the next 3 hours, thanks 😀

31. Ry. Wax. says:

you get, you get…..YOU GET

sorry i had to make a snarky comment, thanks for the help!

32. OXYMON OXYGENIC says:

Hoooly shit, you just gifted me with the ability of enjoying the beauty of math! Thanks dude!

33. Miss chillax says:

still informative. thankyou

34. George Lambrakopoulos says:

Thank you! Very helpful and straightforward.

35. Tahlia Grace says:

I love you man!!!!!!

36. J says:

Why is the sound gone both for videos I watch of Khan and PatrickJMT? All other youtube videos have functional sound! Why must it target the two math gurus when I am in the most of need?? 🙁

37. Robin Engström says:

Wow, I actually get it! First math teacher who actually taught me anything! 😛

38. So Vatanak says:

thank you, Khan Academy, you saved my life!

39. Jacob Silcoff says:

This video was really helpful for my comp sci class. Thanks so much!

you are an angel from heaven

41. RazorX53 says:

would this work the same if there were negative coefficients?

42. Alex Kessler says:

gauss-jordan elimination determinant anyone?

43. Alma Anides says:

i keep getting -7 and cant find my error, anyone get the same thing?

44. Yato says:

16:07 how is 2×3 = -6 ?
it's supposed to be 6. Then -2×6 = -12 and -2x(-12) = 24 is the final result of that part.

45. Parth Mistry says:

which software do u use in this lesson and other lessons? +Khan Academy

thank you so much, finally I understood matrices

47. Paper Bag Man says:

Thanks! I wish my professors were as fluent in teaching as you are.

thank you so much

Great video! Thank you. I'm just wondering why you switch sides with minus, so you suddenly do an addition?

50. Junry Lisondra says:

sir.Khan at the yellow color 0-9 why u didn't multiply (-2 | -9)

51. njabulo mahlalela says:

that was awesome

52. Cheerfultrout says:

I noticed while I was watching that the recursive rule also applies to a 2×2 matrix. therefore I would argue that even more fundamental than the definition of the determinant for a 2×2 matrix (7:55) is the determinant for a 1×1 matrix, which is itself. (and the recursive rule can also be applied to the 2×2 matrix in this way) It's the same thing really, just thought I'd point it out for people like myself, for whom looking at it like this makes it easier to understand/remember.

53. Big Al says:

How is it exactly that after a few minutes of watching this I understand how to get a determinant but the professor at my school couldn't teach this in a week without fumbling the explanation???? You're the light at the end of the tunnel, Saul. Keep up the awesome work!

54. Jake C says:

55. christian cerda says:

Great, how would you code this on matlab using recursion.

56. Vincent V says:

This is Cofactor expansion?

57. Kan CK says:

How about the determinant of a 2 by n matrix which won't have a basic (ad-bc) when you ignore the first row.Then, how do you do it?

58. mahi aslam says:

Great,

59. Vanna6345 says:

Correct me if wrong. It's n-1 because it takes at least two factors to make a coefficient? Successive applications of multiplications (sign rules also) until a 2×2 matrix is isolated.. But the iterations are progressively going to multiply as well. A formula and help from a computer can lessen the burden of the signed arithmetic as well as the assure that a simple mistake won't bring the entire house of cards down..Plus in either case little is to be learned of the mechanics of matrices. If a 4×4 is under your belt then relax. Go back and ponder How this insane mess ever got started — Derive the reasoning or application at the origin. This is a fair attempt at running you through the game in a tiny amount of time. Although it's a good video it means reviewing recursively. :0)

60. Vanna6345 says:

… and may I add this must be considered a Magic Act. Keep your eyes directed to every change (..what was that for..) and listed to every word !..

61. Vanna6345 says:

… also the biggest mistake a teacher makes (#1) is assuming what's obvious to them is obvious to you. .. It takes a intuitive person with patience and time to make what appears overwhelming just a matter of the course..:0)

62. Vanna6345 says:

… Finally this little dip in the bottomless depths of mathematics should make all but the insane shy away unless having the type Brain geared for tedium and not allergic to chalk dust from a revolving blackboard..

63. Vanna6345 says:

.. personally I like computers because there's only '1's & '0's. math is no problemo.. :0)

64. Vanna6345 says:

Science, Mathematics together with even the statisticians can't explain the fact that a Pascal triangle has a marble which either balances on a peg or rockets out of the array. go figure ..

65. Vanna6345 says:

No no ! if this is dumbfounding just don't even consider Non-Linear Algebra.. If there really is a Hell, I'm sure it's non-linear. .. Arg

But why are we changing signs???)

67. M0vir says:

I see a previous exam is computing a 6×6 without a calculator, is it really that bad? Seems really time consuming, even if you understand it.

68. 汤庭瑍 says:

u r not going to done 5×5 and 6×6 matrix question in 20 mins!

69. י - says:

I was investigating n by n determinant, finally I have found and understood this type of determinant.

70. Alwi Hasan says:

Actually there is another way to express determinant of arbitrary square matrix, that is using the Leibniz formula. This way we use permutation function to pair any indices of matrix elements. For details see Wikipedia about determinant of n x n matrix

71. Counteris16 says:

Okay… The introduction to matrices and multiplation is enough for me for today…

72. Zenchiassassin says:

Thanks!

73. Đạt Phạm says:

you save my life

74. Ren Xinyan says:

OMG！！You save me

75. Pome Granate says:

I was about ready to drop out but now it all makes sense <3

76. SHRAVAN DK says:

but why is it that the determinant results in the same value regardless of the row or column from which it is expanded

Slow death

78. Іван Пилипко says:

Very useful

79. Itzak says:

O'boy, I can't wait to do these computations!