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

# Solving a system of 3 equations and 4 variables using matrix row-echelon form

## Video transcript

I have here three equations of four unknowns and you can already guess or you already know that if you have more unknowns than equations you're probably not constraining it enough so you're actually going to have an infinite number of solutions but those infinite number of solutions could still be constrained within well let's say that this is let's say we're in four dimensions in this case we have four variables maybe we're constrained into a plane in four dimensions or if we're in three dimensions maybe we're constrained to a line a line is an infinite number of solutions but it's kind of a more constrained set so let's solve this set of linear equations and we've done this by elimination in the past but what I want to do is I want to introduce the idea of matrices and the matrices are really just a raise of numbers that are shorthand for this system of equations so let me create a matrix here so I could just create a coefficient matrix where the coefficient matrix would just be let me write it neatly the coefficient matrix would just be the coefficients on the left hand side of these linear equations so the coefficient there is one coefficient there is one coefficient there is two you have two two four two two four one two zero one two there's no coefficient on the x three term here because it's there's no x3 term there so we'll say the coefficient on the x3 term there is 0 and then we have one minus one one minus one and six now if I just did this right there that would be the coefficient matrix for this system of equations right there but what I want to do is I want to augment it I want to augment it with what these equations need to be equal to so let me uncomment it and what I'm going to do is I'll just draw a little line here and write the 7 the 12 and the 4 and I think you can see that whatever this right here is just another way of writing this and just by the position we know that these are the coefficients on the x1 terms we know that these are the coefficients on the x2 terms and what this does it really just saves us from having to write x1 and x2 every time but we can essentially do the same operations on this that we otherwise would have done on that so what we can do is we can replace any equation with that equation times some scalar multiple plus another equation we can divide an equation or multiply an equation by scalar we can subtract them from each other we can swap them so let's do that in an attempt to solve this equation so the first thing I want to do just like I've done in the past is I want to get this equation to the form of where if I can I have a one my kind of leading coefficient in any of my rows is a 1 and that every other every other every other entry in that column is a 0 and in the past I made sure that every other entry below it is a 0 that's what I was doing in some of the previous videos when we tried to figure out if things were linear and linearly independent or not but now I'm going to make sure that if there's a 1 and if there's a leading one in any of my rows that everything else in that column is a 0 and that what I'm calling with that that form I'm doing is called reduced row echelon form let me write that reduced row echelon form and if we call this augmented matrix matrix a then I want to get it into the reduced row echelon form of matrix a and matrices the convention is just like vectors you make them nice and bold but use capital letters instead of lowercase letters and we'll talk more about how matrices relate to vectors in the future but let's just solve this system of equations so the first thing I want to do is in an ideal world I would get all of these guys right here to be 0 so let me let me replace this guy with that guy with the first entry minus the second entry so let me do that so I am just going to the first row isn't going to change it's going to be 1 2 1 1 then I get a 7 right there that's my first row now the second row I'm going to replace it with the first row minus the second row so what do I get 1 minus 1 is 0 2 minus 2 is 0 1 minus 2 is minus 1 and then 1 minus minus 1 is 2 right that's 1 plus 1 and then 7 minus 12 is minus 5 all right now I want to get rid of this row here all right I don't wanna get rid of it I want to get rid of this 2 right here I want to turn it into a 0 so let's replace this row with this row minus 2 times that row so what I'm going to do is this row minus 2 times the first row I'm going to replace this row with that so 2 minus 2 times 1 is 0 that was the whole point 4 minus 2 times 2 is 0 0 minus 2 times 1 is minus 2 6 minus 2 times 1 is 6 minus 2 which is 4 and then 4 minus 2 times 7 is 4 minus 14 which is minus 10 all right now what can I do next well I D let's see I don't have any well this guy you can kind of see this Row is kind of what we'll talk more about what this rule means when all of a sudden it's just all been zeroed out there's nothing here if I had a nonzero term here that I'd want to 0 this guy ad although it's already zeroed out so I'm just going to move over to this row so the first thing I want to do is I want to make this leading this leading coefficient here or 1 so what I want to do is I'm going to multiply I'm going to multiply this entire row by minus 1 so if I multiply this entire row times minus 1 in fact I don't know I even have to rewrite the matrix this becomes plus 1 minus 2 plus 5 I think you can accept that all right now what can we do well let's turn this right here into a 0 so let me rewrite my Augmented matrix and the new form that I have so I'm going to keep the middle row the same this time so my middle row is 0:01 - - and then it's augmented and I get a five there and what I want to do is I want to lit I want to eliminate this - - here so why don't I add this row - two times that room right then I would have minus two plus two and that'll work out so what do I get I get a well these are just leading zeros and then I have minus two plus two times one well that's just 0 4 plus 2 times minus 2 4 plus 2 times minus 2 that's minus 4 so that's 4 plus minus 4 that's 0 as well and then you have minus 10 plus 2 times 5 well that's just minus 10 plus 10 which is 0 so that one just got zeroed out and what I want to do when normally when I just did regular elimination I was happy just you know having this situation where I just had these leading ones everything below it where zeros but I wasn't too concerned about what was above our ones but what I want to do is I want to make those into a zero as well so I want to make this guy a zero as well so what I can do is I can replace this first row with that first row minus the second row so what is 1 minus 0 well that's just 1 2 minus 0 is 2 1 minus 1 is 0 1 minus minus 2 is 3 7 minus 5 is 2 and there you have it we have our matrix in reduced row echelon form this is the reduced row echelon form of our matrix I'll write it in bold of our matrix a right there and you know it's in reduced row echelon form because all of your leading ones in each row so what are my leading ones in each row I have this one and I have that one there the only nonzero and three in their columns and these are called the pivot entries these are let me label that for you that's called a pivot entry pivot entry they're the only nonzero entry in their respective columns if I have any zeroed out rows and I do have a zero dot row it's right there so this is zeroed zeroed out row just the style door just the convention is that it for reduced row echelon form that has to be your last row so we have the leading entries are the only they're all one that's one case you can't have this a five you'd want to divide both you want to divide that equation by five this was a five so your leading entries in each row are one that the leading entry in each successive row is to the right of the leading entry of the row before it right this guy right here is to the right of that guy this is just a style the convention of reduced row echelon form and if you have any zeroed out rows it's in the last row and then finally of course and I think I've said this multiple times this is the only nonzero entry in the row now what does this do for me well now I can go back from this world back to my linear equations because we remember that these were the coefficients on x1 these were the coefficients on next to these were the coefficients on x3 on x4 and then these were my constants out here so I can rewrite this system of equations using my reduced row echelon form as X 1 X 1 plus 2 X 2 there's no X 3 there so plus 3 X 4 is equal to 2 and then this equation know x1 know x2 I have an X 3 I have X 3 minus 2 X 4 is equal to 5 and then I have no other equation here this one got completely zeroed out so I was able to reduce this set of this system of equations to this system of equations now the variables that you associate with your pivot entries we call these pivot variables so X 1 and X 3 are pivot variables pivot variables and then the variables that aren't associated with the pivot we call them free variables so x2 and x4 are free variables but now let's let's solve for essentially you have to only you can only solve for your pivot variables the free variables we can set to any variable and you can I said that in the beginning of this equation we have fewer equations than unknowns so this is going to be a not well constrained solution you're not going to have just one point in R for that solves this equation you're going to have multiple points so let's solve let's solve for our pivot variables because that's all we can solve for so this equation tells us right here it tells us X 3 let me do it in a good color X 3 X 3 is equal to is equal to 5 plus 2 X 4 and then we get X 1 X 1 is equal to 2 minus X 2 2 minus 2 X 2 sorry 2 minus 2 X 2 plus sorry minus 3 X 4 right I just subtracted these from both sides of the equation now this right here is essentially as far as we can go to the solution of the system of equations I can pick really any values for my free variables I can pick any values for my X 2's and my x fours and I can solve for an X 3 but what I want to do right now is write this in a slightly different form so that we can visualize a little bit better and of course it's always hard to visualize things in four dimensions but so we can visualize things a little bit better as to kind of the set of this solution so let's write it this way if I were to write it in vector form our solution is the vector X 1 X 2 X 3 X 4 and what is it equal to what is it equal to well it's equal to let me write it like this it's equal to I'm just rewriting I'm just essentially rewriting this solution set in vector form so X 1 is equal to - let me write a little column there plus x2 let me write it this way plus x2 times something plus x4 times something plus x4 times something so how do I so x1 x1 is equal to 2 minus 2 times X 2 or plus x2 times minus 2 so I put a minus 2 there and then I can say plus x4 times minus 3 so I can put a minus 3 there this right here this first entries of these vectors just literally represent that equation right there x1 is equal to 2 plus x2 times minus 2 plus X 4 times minus 3 now what is X 3 equal what does X 3 equal X 3 X 3 is equal to 5 put that 5 right there plus X 4 times 2 plus X 4 times 2 it zx2 doesn't apply to it so we can just put a 0 0 times X 2 plus 2 times X 4 now what is X 2 equal well you could say X 2 is equal to 0 plus 1 times X 2 plus 0 times X 4 right X 2 is just equal to X 2 it's a free variable and similarly what is X 4 equal to X 4 is equal to 0 plus 0 times X 2 plus 1 times X 4 now what does this do for us well all of a sudden here we've expressed our solution set as essentially the linear combination of well of the linear combination of 3 vectors this is a vector in you could view it as a almost a coordinate in either a position vector it is a it is a vector in R 4 you can do it as a position vector or coordinate in R 4 and then you could say look our solution set is essentially this is an hour for each of these have 4 components but you could imagine it in r3 that I have my solution set is equal to some vector some vector there that you know that's the vector if you think of it as a position vector would be the coordinate - comma zero comma 5 comma zero which obviously this is four dimensions right there but it's equal to multiples of these two vectors so let's call this vector right here let's call this vector vector a and let's call this vector right here vector B so our solution set is all of is all of this point which is right there or I guess we could call it that that position vector right that position vector will look like that where you're starting it the origin right there plus multiples of these two guys so if a if this is vector a let's you can do vector a in a different color vector a looks like that so let's say vector a looks like that and then vector B looks like that this is vector B and this is vector a and I don't know if this is going to be easier or harder for you to visualize because obviously we're dealing in four dimensions right here and I'm kind of just drawing it on a two-dimensional surface but what you can imagine is is that the solution set is equal to this fixed point this position vector plus linear combinations of a and B and we're dealing of course in our four let me write that down we're dealing in our four but linear combinations of a and B are going to create a plane right you can just take you know you could you can multiply a times two and B times three or a times -1 and B times minus 100 and you can just keep adding and subtracting these linear combinations of a and B and they're going to construct a plane that contains the the position vector that contains the point 2 0 5 0 so the solution for this for this for these three equations with four unknowns is a plane in r4 a plane in r4 and I know that's really hard to visualize and maybe I'll do another one in three dimensions but hopefully this at least gets you a gives you a decent understanding of what an Augmented matrix is what reduced row echelon form is and what are kind of the valid operations I can perform on a matrix without kind of messing up the system