Choose the learning badge you'll earn today

Current time:0:00Total duration:18:40

0 energy points

# n x n determinant

Defining the determinant for nxn matrices. An exampled of a 4x4 determinant. Created by Sal Khan.

Video transcript

So far we've been able to define
the determinant for a 2-by-2 matrix. This was our definition right
here: ad minus bc. And then we were able to broaden
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,
which was this matrix. Now let's see if we can
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
definition. I'll talk about that
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.