If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Simpler 4x4 determinant

Calculating a 4x4 determinant by putting in in upper triangular form first. Created by Sal Khan.

Want to join the conversation?

  • blobby green style avatar for user Paul Bondin
    Hello Sal. I know I'm wrong and the answer is probably staring me in the face! Where's the fallacy in my thinking: As I understand it, a square matrix whose determinant is not zero is invertible. Therefore, using row operations, it can be reduced to having all its column vectors as pivot vectors. That's equvialent to an upper triangular matrix, with the main diagonal elements equal to 1. If normal row operations do not change the determinant, the determinant will be -1. HELP! :)
    (9 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user Diego Oliveira
      Sal was a bit unfortunate when he said that "row operations do not change the determinant". The proof he gave was that row operations of the form [Ri -c*Rj -> Ri] (that is, replacing row i with row i minus row j times a scalar c) do not change the determinant.

      But there are row operations of different kind, such as
      k*Ri -c*Rj -> Ri (That is, replacing row i with row i times a scalar k minus row j times a scalar c).

      What can be proved is that operations of this kind do change the determinant. In fact, they multiply the determinant by k.

      And when you put an invertible matrix in RREF (that is, you turn it into an identity matrix), you must do these kinds of operations that scale the determinant. And they always end up scaling the determinant back to one, which is the determinant of any identity matrix.
      (2 votes)
  • piceratops sapling style avatar for user Melinda Zsori
    If i do two swaps, does the second essentially cancel out the first and thus the determinant becomes positive again?
    (6 votes)
    Default Khan Academy avatar avatar for user
  • ohnoes default style avatar for user francis
    Can i use this method for any square matrices? thanks
    (4 votes)
    Default Khan Academy avatar avatar for user
  • leafers seed style avatar for user armoorsravan51
    Det A =5. B=4A.then find Det B=?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • primosaur ultimate style avatar for user Derek M.
      It depends on the size of A and B. Multiplying a matrix by a scalar, is the same as multiplying every row of that matrix by that scalar, and note, that multiplying a single row by a scalar is equivalent to multiplying the determinant of the original matrix by that scalar. For example, the determinant of
      [1 0] = 1, the determinant of [2 0] = 2, and the determinant of [2 0] = 4.
      [0 1] [0 1] [0 2]
      Notice with each step, I multiplied a single row by 2, and the determinant increased by a factor of that scalar 2. And the last step, I multiplied all of the rows by 2, which had the same result as multiplying the entire matrix by 2.
      Long story short, multiplying by a scalar on an entire matrix, multiplies each row by that scalar, so the more rows it has (or the bigger the size of the square matrix), the more times you are multiplying by that scalar.
      Example, if A is 3x3, and Det(A) = 5, B=2A, then Det(B) = 2^3*5=40.
      The formula for Det(kA), where k is a scalar, and A is an nxn matrix is as follows:
      Det(kA)=k^n*Det(A).
      (7 votes)
  • blobby green style avatar for user Andrew
    can someone please tell me where is the proof of determinant when swapping rows? I can't find it:(
    (4 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Yeo Kheng Huang
    How do I find a determinant of a 4x4 matrix that has an unknown "k" in the last row?
    Its not possible to do it by the upper triangular method as that would take away the "k" i'm trying to find. Help!
    (1 vote)
    Default Khan Academy avatar avatar for user
  • hopper jumping style avatar for user Pedro IPF
    Can I swap any row and the determinant will be negative? Or just the mid ones?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Harsh  K
    At he swaps a row with another and add a -ve sign. If further down the computation process, if we have to swap another row, do we add another "-" sign thus making the Det. positive again..or does the minus stay no matter the no. of row-swaps?

    Thanks
    (2 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user zach.mears
      I also have this same question! Is anybody able to clear this up for us? Sal states that switching two rows (once) means we must multiply the resulting determinant by -1 to get the determinant of the original matrix. What if we switch rows more than once? Do we have to multiply the resulting determinant by -1 for each row swap?
      (1 vote)
  • blobby green style avatar for user Mirage Miraj D'Ave
    If i have found the Det of the Matrix Det A how do you find the Det A^3
    (1 vote)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Harsh Thakker
    Thank you, Is this the only way to find the determinant of a 4 X 4 matrix. Do we have a straightaway Formula for doing this ? PLEASE HELP
    (1 vote)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user danielschaefer01
      No. We can just calculate the determinant of a 4 x 4 matrix using the "conventional" method, i.e. taking the first element of the first row, multiplying it by the determinant of its "augmented" 3 x 3 matrix and so on and so forth.

      The only problem is that for every dimension we go up, the whole process takes longer and longer. This is literally just a short-cut. If you feel a little uneasy about this new method, I'd personally just stick to the old, standard method of calculating a matrix for now.
      (2 votes)

Video transcript

I have this 4 by 4 matrix, A, here. And let's see if we can figure out its determinant, the determinant of A. And before just doing it the way we've done it in the past, where you go down one of the rows or one of the columns-- and you notice, there's no 0's here, so there's no easy row or easy column to take the determinant by. We could have gone down this row and do all the submatrices, but this becomes pretty involved. You end up doing four 3 by 3 determinants, and then each of those are composed of three 2 by 2 determinants. It becomes a pretty hairy process. Let's see if we can use some of the realizations we've discovered in the last two videos to simplify this process. Well, one of the realizations is that row operations, or if you subtract-- let me write it this way-- if you replace row j with, let's say, row j minus some scale or multiple, times row i, it does not change the determinant of A. We saw that, I think it was two videos ago. So this is a pretty big realization. We can do these type of row operations and it won't change the determinant. The other realization we had was that these upper triangular matrices, you can figure out their determinant. So what does upper triangular look like? Let me just review it. The upper triangular-- everything below the diagonal. So let's say the diagonal has-- let me just draw its terms like that. These are some non-zero terms. Oh, they don't have to be. Then upper triangular, everything below the diagonal is a 0, and everything above the diagonal probably isn't a 0, but you never know. But they're non-zero terms, so all the red stuff here is non-zero, all this stuff in green is 0. And I didn't touch on it in that video, but there is also such a thing as a lower triangular, that you might have guessed how it looks. Everything above the main diagonal is 0, so this is the main diagonal right here, all the way down like that. All of these guys are going to be non-zero. All of that's going to be non-zero, and then the 0's are going to be above the diagonal, like that. We saw in the last video that the determinant of this guy is just equal to the product of the diagonal entries, which is a very simple way of finding a determinant. And you could use the same argument we made in the last video to say that the same is true of the lower triangular matrix, that its determinant is also just the product of those entries. I won't prove it here, but you can use the exact same argument you used in the video that I just did on the upper triangular. So given this, that the determinant of this is just the product of those guys, and that I can perform row operations on this guy and not change the determinant, maybe a simpler way to calculate this determinant is to get this guy into an upper triangular form, and then just multiply the entries down the diagonal. So let's do that. So we want to find the determinant of A. Let me rewrite A right here. It's 1, 2, 2, 1, 1, 1, 2, 4, 2, 2, 7, 5, 2, minus 1, 4, minus 6, 3. Now let's try to get this into upper triangular form. So let's replace the second row with the-- so I'm just going to keep the first row the same. 1, 2, 2, 1. And let's replace the second row with the second row minus the first row. The second row minus the first row is going to be equal to 1 minus 1 is 0. So in this case the constant is just 1. So 1 minus 1 is 0. 2 minus 2 is 0. 4 minus 2 is 2. 2 minus 1 is 1. Now let's replace the third row with the third row minus 2 times the second row. So 2 minus 2 times 1 is 0. 7 minus 2 times 2 is 3. 5 minus 2 times 2 is 1. 2 minus 2 times 1 is 0. Let me get a good color here. I'll do pink. Let's replace the last row with the last row, essentially, plus the first row. You could say minus minus 1 times the first row is the same thing as the last row plus the first row. So minus 1 plus 1 is 0. 4 plus 2 is 6. Minus 6 plus 2 is minus 4. And then 3 plus 1 is 4. So there we have it like that. And this guy has two 0's here, so maybe I want to swap some rows. So let me swap some rows. So if we swap rows, what happens? I'm going to swap the middle two rows just for fun. Well, not just for fun. Because I want a pivot entry right here. I shouldn't say a pivot entry. I want to do it in upper triangular form. So I want a non-zero entry here. This is a 0, so I'm going to move this guy down. So I'm going to keep the top row the same. 1, 2, 2, 1. I'm going to keep the bottom row the same. 0, 0, 6, minus 4, 4. And I'm going to swap these guys right here. So this is going to be 0, 3, 1, 0. And then 0, 0, 2, 1. Now, can I just swap entries like that? Well, I can, but you have to remember that when you swap entries, your resulting determinant is going to be the negative of your original determinant. So if we swap these two guys, the determinant of this is going to be the negative of this determinant. When you swap two rows, you just flip the sign of the determinant. We saw that. That was one of the first videos we did on these, kind of messing with the determinants. Now, what do we want to do here? To get this guy into upper triangular form, it'd be nice to get this to be a 0. So to get that to be a 0, let me keep everything else the same. So I have a 1, 2, 2, 1. I have a 0, 3, 1, 0. The third row is 0, 0, 2, 1. And now this last row, let me replace it with the last row minus 3 times this row. So let me write it like this. I have to carry that negative sign as well. So I'm going to replace this last row with the last row minus 2 times the second row. want to zero it out. So 0 minus 2 times 0 is 0. 6 minus 2 times 3 is 0. Minus 4 minus 2 times 1 is minus 6. And then 4 minus 2 times 0 is just 4. We're almost there. Now we want to zero this guy out, so let's replace this one. So I'm going to keep my top three rows the same again. And let me see if I can write it a little bit neater. So my first row is 1, 2, 2, 1. My second row is 0, 3, 1, 0. Fourth row is 0, 0, 2, 1. And I'm going to take the matrix. I haven't written the fourth row yet. And, of course, the negative of this is going to be determinant of our original matrix, because we had swapped those rows. But let's replace this last row with the last row, plus 3 times the third row. So we get 0 plus 3 times 0 is 0. 0 plus 3 times 0 is 0. Minus 6 plus 3 times 2 is 0. 4 plus 3 times 1 is 7. And just like that, we have a determinant of a matrix in upper triangular form. So this is going to be equal to the product of these guys. We can't forget our negative sign. Let's throw our negative sign out there and put a parentheses just like that. This is going to be the product of that diagonal entry. 1 times 3, times 3, times 2, times 7, which is 6 times 7, which is 42. So the determinant of this matrix is minus 42, which was pretty fast. This was a pretty fast shortcut. And it actually turns out it tends to be computationally more efficient to use these takeaways to put things into upper triangular form first. And then, you know, if you do swaps, you have to remember to make the determinant negative. And then just multiply down the diagonal. And we did that there, and we got the determinant as being minus 42.