Determinants & inverses of large matrices
Inverting a 3x3 matrix using determinants Part 1: Matrix of minors and cofactor matrix
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.