# Solving linear systems with matrices

Sal solves a linear system with 3 variables by representing it with an augmented matrix and bringing the matrix to reduced row-echelon form. Created by Sal Khan.
Video transcript
I figure it never hurts getting as much practice as possible solving systems of linear equations, so let's solve this one. What I'm going to do is I'm going to solve it using an augmented matrix, and I'm going to put it in reduced row echelon form. So what's the augmented matrix for this system of equations? Three unknowns with three equations. I just have to do the coefficents. So the coefficients of x terms are just 1, 1, 1. Coefficients of the y terms are 1, 2, and 3. Coefficients of the z terms are 1, 3, and 4. And let me show that it's augmented. And then they equal 3, 0, and minus 2. Now, I want to get this augmented matrix into reduced row echelon form. So the first thing, I have a leading 1 here that's a pivot entry. Let me make everything else in that column equal to a 0. So I'm not going to change my first row. So it will just be a 1, a 1, a 1, and then my dividing line, and then I have a 3. Now, to zero this out, let me just replace the second row with the first row minus the second row. So 1 minus 1 is 0. 1 minus 2 is-- actually, a better thing to do, because I eventually want this to be 1 anyway, let me replace this row with this row, with the second row minus the first row instead of the first row minus the second row. I can do it either way. So the second row minus the first row. So 1 minus 1 is 0. 2 minus 1 is 1. 3 minus 1 is 2. And then 0 minus 3 is minus 3. Now I want to also zero this out. So let me replace this guy with this equation minus that equation. So 1 minus 1 is 0. 3 minus 1 is 2. 4 minus 1 is 3. Minus 2 minus 3 is minus 5. Fair enough. So I got my pivot entry here. I have another pivot entry here. It's to the right of this one, which is what I want for reduced row echelon form. Now, I need to target this entry and that entry. I need to zero them out. So let's do it. So I'm going to keep my second row the same. My second row is 0, 1, 2, and then I have a minus 3, the augmented part of it. And to zero this guy out, what I can do is I can replace the first row with the first row minus the second row. So I get 1 minus 0 is 1. 1 minus 1-- there's a bird outside. Let me close my window. So where was I? I'm replacing the first row with the first row minus the second row. So 1 minus 0 is 1. 1 minus 1 is 0. 1 minus 2 is minus 1. And then 3 minus minus 3, so that's equal to 3 plus 3, so that's equal to 6. 1 minus 0 is 1. 1 minus 1 is 0, negative 1. And then 3 minus negative 3, that's 6. I always want to make sure I don't make a careless mistake. Now, let me get rid of this entry right here. Let me zero that out. So let me replace the third row with the third row minus 2 times the second row. So we have 0 minus-- well, 2 times 0. That's just going to be 0. 2 minus 2 times 1, that's 2 minus 2, that's 0. 3 minus 2 times 2, that's 3 minus 4, or minus 1. And then finally, minus 5 minus 2 times minus 3. Let me write that down. That's minus 5, minus minus 6. That's minus 5 plus 6 is equal to 1. I really wanted to make sure I didn't make a careless mistake there. So that is equal to 1. So I'm almost done, but I'm still not in reduced row echelon form. This has to be a positive 1 in order to get there. It can't be anything other than a 1. That's just the style of reduced row echelon form. And then these guys up here have to be zeroed out. Well, the easy thing to do, let me just multiply this equation by minus 1. So then this becomes a plus 1 and that becomes a minus 1. And then I just need to zero out these two guys up here. So let's do it. So my equation, I'm going to keep my third row the same. My third row is now 0, 0, 1, minus 1. And now I want to zero this guy out. So what I can do is I could set my first row equal to my first row plus my last row, because if these two add up, they're going to be equal to 0. So what do I get? 1 plus 0 is 1. 0 plus 0 is 0. Minus 1 plus 1 is 0. 6 plus minus 1 is 5. Now, I want to zero this row out. And to zero this row out, what I can do is I'll replace it with the second row minus 2 times the first row. So 0 minus 2 times 0 is just 0. 1 minus 2 times 0 is just 1. 2 minus 2 times 1 is 0. Minus 3 minus 2 times negative 1. Let me write that down. Minus 3 minus 2 times minus 1. I don't want to make a careless mistake. So what is that equal to? This is equal to minus 3 minus minus 2, or minus 3 plus 2, which is equal to minus 1. So that's equal to minus 1. And now I have my augmented matrix in reduced row echelon form. My pivot entries are the only entries in their columns. Each pivot entry in each successive row is to the right of the pivot entry before it. And actually, I have no free variables. Every column has a pivot entry. So let's go back from the augmented matrix world and kind of put back our variables there. So what do we get? We get x plus 0y plus 0z is equal to 5. That's that row right there. We get 0x plus 1y plus 0z is equal to minus 1. That's that row right there. And then finally, we have 0x plus 0y plus 1z is equal to minus 1. That's that row right there. And just like that, we've actually solved our system of three equations with three unknowns. That's the solution right there. I just wrote it in this way just so you can see the corresponding, but obviously, I could have written them closer to their equal sign. So hopefully, you found that vaguely useful.