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

Inverting a 3x3 matrix using determinants Part 1: Matrix of minors and cofactor matrix

Sal shows how to find the inverse of a 3x3 matrix using its determinant. In Part 1 we learn how to find the matrix of minors of a 3x3 matrix and its cofactor matrix. Created by Sal Khan.

Want to join the conversation?

  • leaf green style avatar for user Roma
    I didnt quite understand the end of the video, at . I got the cofactor Matrix, but then what's left to do to get to the inverse of matrix C? Multiply the cofactor Matrix by which determinant, the one from C or the one from the cofactor Matrix?
    (15 votes)
    Default Khan Academy avatar avatar for user
    • leafers ultimate style avatar for user Pipe
      Don't listen to sal at the end of part 1 your supposed to find the TRANSPOSE of the co-factor matrix. Then multiply the transpose of the co-factor matrix by the determinant of the original matrix. Then you have the inverse.
      (12 votes)
  • leafers ultimate style avatar for user Pipe
    What are applications for this in the world?
    (14 votes)
    Default Khan Academy avatar avatar for user
    • purple pi teal style avatar for user Lura Ercolano
      If you have ever been given a problem with three linear equations in three unknowns (x,y and z), and you worked through a big tedious mess of solving the system of equations by gathering like terms, expressing one variable in terms of the others, and substituting, etc, then you have already been doing this math!

      Working with matrices is a way of turning the methods you already know into an automated, orderly system.

      The real- world applications are any situation where there are three variables that relate to each other. The practical applications of setting up the math with matrices is that the steps can be programmed to be run by a computer.
      (12 votes)
  • male robot donald style avatar for user Divyansh Verma
    can determinant be found only for a square matrix?
    (9 votes)
    Default Khan Academy avatar avatar for user
  • duskpin ultimate style avatar for user tianshu.wang
    I'm just wondering, is it possible to find the determinant of a 1 by 1 matrix?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • mr pants teal style avatar for user Wrath Of Academy
    Does anyone else skip the whole "checkerboard" thing and just use determinants that are the correct signs to begin with? If you just imagine the original matrix repeats infinitely in every direction, you can always go to the bottom-right of the number and grab that determinant square. So, for the -2 entry, you'd go down and to the right and grab the square of:
    1 2
    5 3
    and take the determinant of that, which is -7. This immediately gets you the -7 in the cofactor matrix Sal writes at in the end, but avoids having to remember to do with checkerboard later. Any downside to that method?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • old spice man green style avatar for user jpl
      I quite like that approach. It makes it less likely to mess up the deletion of the row and column to get the minor, and the sign gets taken care of by the reversals, as appropriate, of the original two rows and columns. But, as Sal said, it's still not an operation I look forward to carrying out.
      (2 votes)
  • blobby green style avatar for user TDAndress
    Can you show an example of solving a 3x3 matrix solving for an X,Y,Z linear equation? I'm trying to work one out for the first time, I found the determinant, and the inverse, multiplied the inverse by the constants, and then multiplied that result by 1 over the determinant, my answer came out all messed up. I'm enjoying this, but it's frustrating when the substitution method is working better for me, and I want to be better than that.
    (3 votes)
    Default Khan Academy avatar avatar for user
    • aqualine seed style avatar for user Danny.YD.Tsai
      I think it's important to get a 'bigger picture' of why we use the inverse of the matrix to solve systems of linear equations. I'm guessing you're familiar with a system of equations like
      1x + 2y+3z = 5
      2x + 3y + 1z = 6
      3x + 7y + 2z = 8


      This is written in matrix form:
      A*x = b, where x in this example is a vector of variables [x ; y ; z]. To solve for x, we premultiply both sides of the equation by the inverse of A:
      inv(A)*A*x = inv(A)*b, and since inv(A)*A = I, the identity matrix,
      x = inv(A)*b.

      From your description, it looks like you accidentally multiplied by 1/det(A) when it wasn't necessary. The determinant is only used to find the inverse itself.

      However, finding the inverse is (as you found out first hand), pretty difficult and prone to error. So people have worked out ways of solving the same problem A*x=b using other methods, one of which is using what is called LU decomposition. Going into that will be another big can of worms, so if you're interested you can look into that online.
      (2 votes)
  • male robot hal style avatar for user Joel Dixon
    Unless I missed it, Sal never told us we first need to take the Transpose of the original matrix before doing the matrix of minors and multiplying by 1 over the Determinant. Is that covered in another video?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • primosaur ultimate style avatar for user Raymond Muller
    Matrices seem tailor-made to be solved by computers... But is there a place where matrices are used outside of computers?
    (i.e. a situation where I would have to solve if my computer broke)
    (2 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Demmer
    which method is used here? the one of cramer or gauss jordan?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Alexander Schott
      its definitly not gauss jordan. @ Gauss-Jordan you transform your matrix to be the identity matrix. 1. you write both matrix and the identity matrix side by side. So what you see is like a 3x6 matrix (first three columns are the matrix and second 3 columns are the identity) 2.Now you use simple operations on them to get the identity matrix on your left 3 columns, if you have done this, then the right 3 columns are now the inverse of your matrix. Hopefully its not too confusing. But thats the way how to build the inverse by gauss-jordan. This method that sal uses is the conclusion of the cramers rule I think.
      (4 votes)
  • leaf grey style avatar for user Susmito "Shyan" Rittik
    I don't understand why the process of inverting 3x3 matrices is so different from the process of inverting 2x2 matrices. Does the process change again when we move on to 4x4 matrices? I mean normally one would expect that when we are performing the same operation on two different entities, we would be following the same steps...but it does not appear to be the case when it comes to matrices! I can't seem to get any intuitive grasp over the content presented in this video.
    (2 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Sid
      It isn't. The method used to invert 3x3 matrices may also be used for 2x2 matrices. It may take a while to learn 3x3 though, and that is probably why they teach a simplified version for 2x2.

      3x3 is hard enough for me, I don't think I want to ever do a 4x4 manually.
      (2 votes)

Video transcript

I'm now going to do one of my least favorite things to do by hand, and that is to invert a 3 by 3 matrix. And it can be useful because you can solve systems that way. But you'll see it's very computationally-intensive. And it is better to be done by a computer. And the only thing that's more painful is doing a 4 by 4 or a 4 by 5 matrix, which would-- or a 4 by 4 or a 5 by 5 matrix, which could take all day. And I'd probably, definitely make a careless mistake. But let's just take it step-by-step. So the first thing I'm going to do, this is my 3 by 3 matrix, is I'm going to construct a matrix of minors. So let me construct here a matrix of minors. And I'm going to draw this really big, right over here, to give ourselves some real estate. And the matrix of minors, what you do is, for each element in this matrix, you cross out the corresponding row, the corresponding column. And you replace it with the determinant of the elements that are left. So what are left when you get rid of this row and this column, the minor is 1, 1, 4, 5. So the determinant of 1, 1, 4, 5. Let's keep doing that. This will be replaced-- well I'll let you think about that first. What is this going to be replaced with? Well it's going to be replaced-- this row, this column. The determinant of 2, 1, 3, 5. Let's keep going. Let's do this element. It's going to be replaced with the determinant of, we get rid of this row, this column, 2, 1, 3, 4. We're a third of the way done, at least with this first stage of it. So for this element right here, it's going to be replaced with its minor. So we get rid of this row, this column. The determinant of negative 2, 2, 4, 5. Then we have-- I'm trying to switch up the colors reasonably-- this element. Get rid of the middle row, middle column. You're left with the determinant negative 1, 2, 3, 5. Now we move on to-- and I'm really running out of colors-- this element right over here, where its minor is-- we'll get rid of this row, this column-- negative 1, negative 2, 3, 4. So let me see that. Sorry, someone's car alarm started ringing outside. So let me make sure I didn't lose my focus here. I don't want to make any careless mistakes. This row, this column, negative 1, negative 2, 3, 4. All right. Now let's move over here. Get rid of the first column, last row. You have negative 2, 2, 1, 1. So we have negative 2, 2, 1, 1. Now let's move to this one. The middle column, bottom row, you have negative 1, 2, 2, 1. So we have negative 1, 2, 2, 1. And then we are in the home stretch for at least the matrix of minors. And so we are looking at this element right over here. Get rid of the last column, last row. You're left with negative 1, negative 2, 2, 1. So the determinant of negative 1, negative 2, 2, 1. And from here we just have to evaluate each of these to get the actual matrix of minors. This is just a representation of it. So let's do that. So once again, we're still at the stage of getting our matrix of minors. And actually I don't have to write it as big anymore because now they're going to have numeric values. They're not going to be these little determinants of two-by-twos. So what is the determinant over here on the top left? Well it's going to be 1 times 5 minus 1 times 4. 1 times 5 minus 4 times 1. So it's going to be 5 minus 4, which is 1. What is the determinant over here, this blue determinant? Well it's going to be 2 times 5, which is 10, minus 3 times 1. So 10 minus 3 is 7. What is this determinant, on the top right, going to evaluate to? Well you have 2 times 4 is 8, minus 3 times 1. So it's 8 minus 3, which is 5. Then we go over here. What is this determinant going to evaluate to? We have negative 2 times 5 is negative 10, minus 4 times 2. So it's negative 10 minus 8, which is negative 18. Then we have negative 1 times 5, which is negative 5, minus 3 times 2. So it's negative 5 minus 6, which is negative 11. I want to do that in white, negative 11. What's this determinant going to evaluate to? We have negative 1 times 4, negative 4, minus negative 6. So that's negative 4 plus 6, which is positive 2. I want to do that in that-- so that is positive 2. We have three left. What does this evaluate to? Negative 2 times 1 is negative 2, minus 1 times 2. So it's negative 2 minus 2 gets us to negative 4. Home stretch now. Negative 1 times negative 1 is negative 1, minus 2 times 2. So it's negative 1 minus 4, which is negative 5. And then finally we have negative 1 times 1 is negative 1, minus 2 times negative 2, so minus negative 4. So it's negative 1 minus negative 4. That's the same thing as adding a 4. So it's negative 1 plus 4. So it's going to be a positive 3. So this right over here is our true matrix of minors. And from there we can get our cofactor. We can get our cofactor matrix just by remembering a checkerboard pattern. So a checkerboard pattern tells us positive, negative, positive, negative, positive, negative, positive, negative, positive. It's a little self-explanatory why that's called a checkerboard. So if we sign this matrix of minors in this pattern, then we get our cofactor matrix. So let's set up our cofactor matrix right over here. So this is our cofactor. A lot of terminology, but hopefully it's making a little bit of sense. Our cofactor matrix. So we just have to apply these signs to these values, to the matrix of minors. So 1 is now going to have applied a positive sign to it. So it's still just going to be a positive 1. You're going to have 7, but it's going to have a negative sign applied to it. So it's going to be a negative 7. You have a 5, positive 5. The 5 is already positive. You multiply it times a positive, it's going to be a positive. You have negative 18, but then we have to multiply that times a negative. So you get positive 18. You have negative 11, multiply that times a positive 1. And so you still have negative 11. You have positive 2, multiply by a negative 1. You're going to have negative 2. Then you have negative 4, multiply by a positive 1. You still have negative 4. And then you have negative 5. What is this going to be in the cofactor matrix? Well you take a negative 5, multiply by a negative 1. You have a positive 5. And then finally, you have a positive 3, multiply by a positive 1. You're still going to have a positive 3. So we've gone pretty far in our journey, this very computationally-intensive journey-- one that I don't necessarily enjoy doing-- of finding our inverse by getting to our cofactor matrix. Now we just have to take this determinant, multiply this times 1 over the determinant and we're there. We've figured out the inverse of matrix C.