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 Gaussian elimination

## Video transcript

I will now show you my preferred way of finding an inverse of a 3x3 matrix and I actually think it's a lot more fun and you're less likely to make careless mistakes but if I remember correctly for mild or true they didn't teach they didn't teach it this way in algebra 2 and that's why I taught the other way initially but let's go through this and in a future video I will teach you why it works because that's always important but in linear algebra this is one of the few subjects where I think it's very important to learn how to do the operations first and then later we'll learn the why because the how is very mechanical and really just involve some basic arithmetic for the most part but though the Y is tends to be quite deep so I'll leave that to later videos and you can often think about the depth of things when you know when you have confidence that you at least understand the house so anyway let's go back to our original matrix and what was that original matrix that I did in the last video it was 1 0 1 0 2 1 1 1 1 and we wanted to find the inverse of this matrix so this is what we're going to do is called Gauss Jordan elimination to find the inverse of the matrix and the way you do it and it might seem a little bit like magic it might seem a little bit like voodoo but I think if what you'll see in future videos it makes a lot of sense what we do is we augment this matrix and what does augment mean it means you just add something to it so what I dried you're I draw a dividing line some people don't so if I put a dividing line here and what I put on the other device on the other side of the dividing line I put the identity matrix of the same size so this is 3x3 so I put a 3 by 3 identity matrix so that's 1 0 0 0 1 0 0 0 1 alright so what are we going to do what I'm going to do is perform a series of elementary row operations and I'm about to tell you what are valid elementary row operations on this matrix but whatever I do to any of these rows here I have to do to the corresponding rows here and my goal is essentially to perform a bunch of operations on the left-hand side and of course the same operations will be applied to the right-hand side so that I eventually end up with the identity matrix on the left hand side and then when I have the identity matrix on the left hand side what I have left on the right hand side will be the inverse of this original matrix and when you put this in in when you this becomes an identity matrix that's actually called reduced row echelon form and I'll talk more a lot about that there's a lot of a lot of names and labels and linear algebra but they're really you know just fairly simple concepts but anyway let's get started and this should become a little clearer at least the process will become clearer maybe not why it works so first of all I said I'm going to perform a bunch of operations here what are legitimate operations they're called elementary row operations so there's a couple of things I can do I can replace any row with that row multiplied by some number so I can do that I can swap any two rows and of course if I swap SIG's the first or the second or I'd have to do it here as well and I can add or subtract one row from another row so when I do that so for example I could take this row and replace it with this row added to this row and you'll see what I mean in a second and you know if you combine it you could you could say well I'm going to multiply this row times negative one and add it to this row and replace this row with that so if if you if you start to feel like this is something like what you learned when you learn system of equations or solving systems of linear equations that's no coincidence because matrices are actually a very good way to represent that and I will show you that soon but anyway let's do some elementary row operations to get this left-hand side into reduced row echelon form which is really just a fancy way of saying let's turn it into the identity matrix so let's see what we want to do we want to have ones all across here we want these to be 0 so let's see how we can do this efficiently so let me draw the matrix again so let's let's let's let's get a I want to get a 0 here right that would be convenient so I'm going to keep the top two rows the same 1 0 1 I have my dividing line 1 0 0 I didn't do anything there I'm doing anything to the second row 0 to 1 0 to 1 0 1 0 and what I'm going to do I'm going to replace this row and just you know my motivation my goal is to get a 0 here so I'm a little bit closer to you know having a the identity matrix here so how do I get a 0 here well what I could do is I can subtract I can replace this row with this row minus this row so I can replace the third row with the third row minus the first row so what's the third row minus the first row 1 minus 1 is 0 1 minus 0 is 1 1 minus 1 is 0 well I did it on the left hand side so I have to do it on the right hand side I have to replace this with this minus this so 0 minus 1 is minus 1 0 minus 0 is 0 and 1 minus 0 is 1 fair enough now what can I do well this this this row right here this third row it has 0 1 0 it looks a lot like what I want for my second row and the identity matrix so why don't I just swap these two rows why don't I just swap the first and second row so let's do that I'm going to swap at the first and second rows so the first row stays the same 1 0 1 and then on the other side is tastes the same as well and I am swapping the first sorry the second and third rows so now my second row is now 0 1 0 and I have to swap it on the right-hand side so it's minus 1 0 1 right I'm just I'm just swapping these two so then my third row now becomes what the second row was here is 0 2 1 and 0 1 0 fair enough now what do I want to do well it would be nice if I had a 0 right here that would get me that much closer to the identity matrix so how could I put it get a 0 here well what if I subtracted 2 times Row 2 from Row 1 right because then this would be 1 times - is - and if I subtracted if I if I subtracted that from this I would get a zero here so let's do that so the first row the first row has has been very lucky it hasn't had to do anything it's just sitting there one zero one one zero zero and the second row is not changing for now - one zero one now what did I say I was going to do I'm going to subtract two times Row two from Row three so this is 0 minus 2 times 0 is 0 2 minus 2 times 1 well that's 0 1 minus 2 times 0 is 1 0 minus 2 times negative 1 is so 0 let's remember 0 minus 2 times negative 1 so that's 0 minus negative 2 so that's positive 2 1 minus 2 times 0 well that's just still 1 0 minus 2 times 1 so that's minus 2 right have I done that right now I just want to make sure oh minus 2 times right 2 times minus 1 is minus 2 and I'm subtracting it so it's plus okay so I'm close this almost looks like you're the identity matrix or reduced row echelon form except for this one right here so I'm finally going to have to touch the top row and well hot what can I do well how about I replace the top row with the top row minus the bottom row right because if I subtract this from that this will get a 0 there so let's do that so I'm replacing the top row with the top row minus the third row so 1 minus 0 is 1 0 minus 0 is 0 1 minus 1 is 0 that was our whole goal and then 1 minus 2 is negative 1 0 minus 1 is negative 1 zero minus negative two well that's positive two and then the other rows stay the same right 0 1 0 minus 1 0 1 and then 0 0 1 2 1 negative 2 and there you have it we have performed a series of operations on the left hand side and we perform the same operations on the right hand side this became the identity matrix or reduced row echelon form and we did this using Gauss Jordan elimination and what is this well this is the inverse of this original matrix this times this will equal the identity matrix so this if this is a inverse I'm sorry if this is a then this is a inverse and that's all you have to do and as you can see this took me half the amount of time it required a lot less hairy mathematics than when I did it using you know the adjoint and the cofactors and the determinant and if you think about it I'll give you a little a hint of why this worked every one of these operations I did on this on the left-hand side every one of those operations you could kind of view them as multiplying you know to get from here to here I multiplied you can kind of say that there's a matrix that if I multiplied by that matrix it would have perform this operation and then I would have had to multiply by another matrix top to do this operation so essentially what we did is we multiplied by a series of matrices to get here and when if you multiplied all of those what we call elimination matrices together you essentially multiply this times the inverse so what am I saying so if we have a if to go from to go from here to here we have to multiply a times the elimination matrix and this might be completely confusing for you so ignore it if it is but it might be insightful so we you know they called we eliminated what did we eliminate in this we eliminated 3 1 we multiplied by the elimination matrix 3 1 to get here right and then we to go from here to here we multiplied sub-matrix and I'll tell you more I'll show you how we can construct these elimination matrixes we multiplied by elimination matrix well actually we we had a row swap here I don't know what you want to call that we could call that you know the swamp matrix I don't know we swapped 2 for 3 row 2 for 3 and then here we had a limit elate we multiplied by elimination matrix what did we do this was we eliminated this so this was Row 3 column 2 3 2 and then finally to get here we have to multiply by elimination matrix we have to eliminate this right here so we eliminated Row 1 column 3 so elimination with Row 1 column 3 now I want you to know right now that it's not important what these matrices are I'll show you how we can construct these matrices but I just want you to have kind of a leap of faith that each of these operations could have been done by multiplying by some matrix matrix right but we do know is by multiplying by all of these matrices we essentially got the identity matrix back here so the combination of all of these matrices when you multiply by the each other this must be the inverse matrix if I were to multiply each of these elimination and swap Row swap matrices this must be the inverse matrix of a right because you multiply all of them times a you get the inverse well well what happened if these matrices are collectively the inverse matrix if I do them if I multiply the identity matrix times them you know the elimination matrix you know this one times that equals that this one times that equals that this one times that equals that and so forth I'm essentially multiplying when you combine all of these a inverse times the identity matrix right so if you think about it just very big picture and I don't want to confuse you it's good enough at this point if you just understood what I did but what I'm doing from all of these steps I'm essentially multiplying both sides of this augmented matrix you could call it by a inverse so I multiply this by a inverse to get to the identity matrix but then of course if I multiply the inverse matrix times the identity matrix I'll get the inverse matrix but anyway I don't want to confuse you hopefully that give you a little intuition I'll do this later with some more concrete examples but but hopefully you see that this is a lot less hairy than the way we did it with the adjoint and the cofactors and the minor matrices and the determinants etc anyway I'll see you in the next video