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

Sal solves a linear system with 3 equations and 4 variables by representing it with an augmented matrix and bringing the matrix to reduced row-echelon form. Created by Sal Khan.

Want to join the conversation?

  • hopper cool style avatar for user lavanya.jeewa
    What is a leading entry?
    (44 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user dlucio20032093
    what is the difference between using echelon and gauss jordan elimination process
    (61 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user Lee Merrick
      Gauss-Jordan is augmented by an n x n identity matrix, which will yield the inverse of the original matrix as the original matrix is manipulated into the identity matrix.

      In the case that Sal is discussing above, we are augmenting with the linear "answers", and solving for the variables (in this case, x_1, x_2, x_3, x_4) when we get to row reduced echelon form (or rref).
      (9 votes)
  • At , why is the 4th dimension denoted by R4?
    Why the letter R?
    (15 votes)
    Default Khan Academy avatar avatar for user
    • leaf red style avatar for user Johan Litsfeldt
      R is the set of all real numbers. The real numbers can be thought of as any point on an infinitely long number line. Examples of these numbers are -5, 4/3, pi etc. An example of a number not included are an imaginary one such as 2i.

      R4 means that points in the space has 4 coordinates of real values. Points in this space are written on the form (x1, x2, x3, x4) where xi is a real number.
      (37 votes)
  • blobby green style avatar for user Alex Péruk
    This might be a side tract, but as mentioned in "" does that mean, for any plane in any dimension the equation defining one is "point in that plane + vector 1 + vector 2"? Or for higher dimensions, will it need more vectors?
    (16 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user John Deeble
      I think you are basically correct in the notion that you can define a plane with a point and two vectors, however I think it would be wise if you said "+ a linear combination of two non-zero independent vectors" instead of just "+ vector 1 + vector 2".
      I disagree with Jeffrey for two reasons:
      1.It can be dangerous to think of a vector as a line with two points. Vectors aren't defined by position. Really (1,1,1) -> (10,1,1) should just be the vector ( 9,0,0) and (2,2,2) -> (2,10,2) should just be the vector (0,8,0). You can make a plane out of a linear combination of these two vectors.
      2. The two vectors in the video do not just "happen" to intersect at the point (2,0,5,0). Any two vectors added to the point (2,0,5,0) would intersect at this point because the two vectors both have that point as a starting position.
      (18 votes)
  • blobby green style avatar for user farhadr09
    Is there a reason why line two was subtracted from line one, and (line one times two) was subtracted from line three? what I'm saying is why didn't we subtract line 3 from two times line one
    (18 votes)
    Default Khan Academy avatar avatar for user
  • mr pink red style avatar for user vanshreebhalotia
    onward : i don't get this whole visualisation thing..
    can anyone post a link / explain it?
    plz reply ASAP
    Thx!!
    (9 votes)
    Default Khan Academy avatar avatar for user
    • mr pants teal style avatar for user Tim
      It's not easy to visualize because it is in four dimensions! It is hard enough to plot in three!

      So Sal has some vector [x1, x2, x3, x4]' = [2 0 5 0]' + x2*[-2 1 0 0]' + x4*[-3 0 2 1]'

      Let's ignore the last two terms for the moment. We can do that by pretending that x2 = 0 and x4 = 0. Then we get [x1, x2, x3, x4]' = [2 0 5 0]'. That's one possible answer, which Sal shows by marking a big blue spot. We can't plot it exactly because it has to be in four dimensions! In any case, if we lived in some crazy four dimensional universe (let's leave time out of this), then we could plot this as a line coming from the origin [0, 0, 0, 0]' to the point [2 0 5 0]'. That's what Sal's blue line represents.

      But wait, that's not all! We still have those last two terms. Each of those vectors represents a line. Let's ignore the last term for now. So we have:
      [x1, x2, x3, x4]' = [2 0 5 0]' + x2*[-2 1 0 0]'

      OK, so that last vector is a line. Because we can have any value for x2, that means any multiple of that line PASSING THROUGH [2 0 5 0] is an answer. So if x2 is 0, we get [2 0 5 0] as an answer. If x2 is 1, we get [0 1 5 0] is an answer. This makes a line that goes through [2 0 5 0]. However, this line is in four dimensions, so is still really hard to plot!

      But wait, there's more! We have another term we have been ignoring. The last term has another vector. What do we get when we can move in two different directions? We get a plane!

      If you would like an analogy (in 3D), think of yourself as being in a multi-storey building. The first term gives you floor. The second and third terms give you some amount north and some amount east (they could be negative). The first term is fixed; you aren't allowed to change floors. However, the last two terms vary as much as you like, so you can go north, east, south (negative north), west (negative east) or any combination as much as you like.

      Sorry, confusing I know, but four dimensions can do that!
      (26 votes)
  • blobby green style avatar for user dangriffin13
    Is there a video or series of videos that shows the validity of different row operations? I'm looking for a proof or some other kind of intuition as to how row operations work.
    (13 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Udith Kavisinghe
    Hi, Could you guys explain what echelon form means? Like the things needed for a system to be a echelon form?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Darrin Williams
      A rectangular matrix is in echelon form if it has the following three properties:

      1. All nonzero rows are above any rows of all zeros
      2. Each leading entry of a row is in a column to the right of the leading entry of the row above it.
      3. All entries in a column below a leading entry are zeros.

      For it to be in reduced echelon form, it must satisfy the following additional conditions:

      4. The leading entry in each nonzero row is 1
      5. Each leading 1 is the only nonzero entry in its column
      (23 votes)
  • blobby green style avatar for user Hal.Hauder
    at , how did you get X2 = 0 1 0
    X4=0 0 1
    i dont understand how did you get that . we only know X1 ans X3 ??
    thanks
    Hal
    (7 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user InnocentRealist
      Sal has assumed that the solution is in R^4 (which I guess it is if it's in R2 or R3). I'm also confused.

      What he's doing implies that the free variables x2 and x4 are on their own x2 and x4 axes of R^4, which I have doubts about.

      1) The original 3x4 transformation matrix is from R^4 to R^3.
      2) The rref matrix has only 2 rows, which seems to mean there are only x1 and x3 coordinates in the solution.
      (1 vote)
  • leafers ultimate style avatar for user yiriBRIGGS
    at int the video sal says a matrices is a rays of numbers, what is a rays?
    (3 votes)
    Default Khan Academy avatar avatar for user

Video transcript

I have here three equations of four unknowns. You can already guess, or you already know, that if you have more unknowns than equations, you are probably not constraining it enough. You actually are going to have an infinite number of solutions. Those infinite number of solutions could still be constrained. Let's say we're in four dimensions, in this case, because we have four variables. Maybe we were constrained into a plane in four dimensions, or if we were in three dimensions, maybe we're constrained to a line. A line is an infinite number of solutions, but it's a more constrained set. Let's solve this set of linear equations. We've done this by elimination in the past. What I want to do is I want to introduce the idea of matrices. The matrices are really just arrays of numbers that are shorthand for this system of equations. Let me create a matrix here. 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. The coefficient there is 1. The coefficient there is 1. The coefficient there is 2. You have 2, 2, 4. 2, 2, 4. 1, 2, 0. 1, 2, there is no coefficient the x3 term here, because there is no x3 term there. We'll say the coefficient on the x3 term there is 0. And then we have 1, minus 1, and 6. Now if I just did this right there, that would be the coefficient matrix for this system of equations right there. 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. Let me augment it. What I am going to do is I'm going to just draw a little line here, and write the 7, the 12, and the 4. I think you can see that this 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. We can essentially do the same operations on this that we otherwise would have done on that. 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 a scalar. We can subtract them from each other. We can swap them. Let's do that in an attempt to solve this equation. The first thing I want to do, just like I've done in the past, I want to get this equation into the form of, where if I can, I have a 1. My leading coefficient in any of my rows is a 1. And that every other entry in that column is a 0. 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 of things were linearly independent, or not. Now I'm going to make sure that if there is a 1, if there is a leading 1 in any of my rows, that everything else in that column is a 0. That form I'm doing is called reduced row echelon form. Let me write that. Reduced row echelon form. 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. We'll talk more about how matrices relate to vectors in the future. Let's just solve this system of equations. The first thing I want to do is, in an ideal world I would get all of these guys right here to be 0. Let me replace this guy with that guy, with the first entry minus the second entry. Let me do that. The first row isn't going to change. It's going to be 1, 2, 1, 1. And 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. That's 1 plus 1. And then 7 minus 12 is minus 5. Now I want to get rid of this row here. I don't want to get rid of it. I want to get rid of this 2 right here. I want to turn it into a 0. Let's replace this row with this row minus 2 times that row. What I'm going to do is, this row minus 2 times the first row. I'm going to replace this row with that. 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. 4 minus 2 times 7, is 4 minus 14, which is minus 10. Now what can I do next. You can kind of see that this row, well talk more about what this row means. When all of a sudden it's all been zeroed out, there's nothing here. If I had non-zero term here, then I'd want to zero this guy out, although it's already zeroed out. I'm just going to move over to this row. The first thing I want to do is I want to make this leading coefficient here a 1. What I want to do is, I'm going to multiply this entire row by minus 1. If I multiply this entire row times minus 1. I don't even have to rewrite the matrix. This becomes plus 1, minus 2, plus 5. I think you can accept that. Now what can we do? Well, let's turn this right here into a 0. Let me rewrite my augmented matrix in the new form that I have. I'm going to keep the middle row the same this time. My middle row is 0, 0, 1, minus 2, and then it's augmented, and I get a 5 there. What I want to do is I want to eliminate this minus 2 here. Why don't I add this row to 2 times that row. Then I would have minus 2, plus 2, and that'll work out. What do I get. Well, these are just leading 0's. Then I have minus 2, plus 2 times 1. That's just 0. 4 plus 2 times minus 2, that is minus 4. That's 4 plus minus 4, that's 0 as well. Then you have minus 10 plus 2 times 5. Well, that's just minus 10 plus 10, which is 0. That one just got zeroed out. Normally, when I just did regular elimination, I was happy just having the situation where I had these leading 1's. Everything below it were 0's. I wasn't too concerned about what was above our 1's. What I want to do is, I want to make those into a 0 as well. I want to make this guy a 0 as well. What I can do is, I can replace this first row with that first row minus this second row. What is 1 minus 0? 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. 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. You know it's in reduced row echelon form because all of your leading 1's in each row-- so what are my leading 1's in each row? I have this 1 and I have that 1. They're the only non-zero entry in their columns. These are called the pivot entries. Let me label that for you. That's called a pivot entry. Pivot entry. They're the only non-zero entry in their respective columns. If I have any zeroed out rows, and I do have a zeroed out row, it's right there. This is zeroed out row. Just the style, or just the convention, is that for reduced row echelon form, that has to be your last row. We have the leading entries are the only -- they're all 1. That's one case. You can't have this a 5. You'd want to divide that equation by 5 if this was a 5. So your leading entries in each row are a 1. That the leading entry in each successive row is to the right of the leading entry of the row before it. This guy right here is to the right of that guy. This is just the style, the convention, of reduced row echelon form. If you have any zeroed out rows, it's in the last row. And finally, of course, and I think I've said this multiple times, this is the only non-zero entry in the row. What does this do for me? Now I can go back from this world, back to my linear equations. We remember that these were the coefficients on x1, these were the coefficients on x2. These were the coefficients on x3, on x4, and then these were my constants out here. I can rewrite this system of equations using my reduced row echelon form as x1, x1 plus 2x2. There's no x3 there. So plus 3x4 is equal to 2. This equation, no x1, no x2, I have an x3. I have x3 minus 2x4 is equal to 5. I have no other equation here. This one got completely zeroed out. I was able to reduce this system of equations to this system of equations. The variables that you associate with your pivot entries, we call these pivot variables. x1 and x3 are pivot variables. The variables that aren't associated with the pivot entry, we call them free variables. x2 and x4 are free variables. Now let's solve for, essentially you can only solve for your pivot variables. The free variables we can set to any variable. I said that in the beginning of this equation. We have fewer equations than unknowns. This is going to be a not well constrained solution. You're not going to have just one point in R4 that solves this equation. You're going to have multiple points. Let's solve for our pivot variables, because that's all we can solve for. This equation tells us, right here, it tells us x3, let me do it in a good color, x3 is equal to 5 plus 2x4. Then we get x1 is equal to 2 minus x2, 2 minus 2x2. 2 minus 2x2 plus, sorry, minus 3x4. I just subtracted these from both sides of the equation. This right here is essentially as far as we can go to the solution of this system of equations. I can pick, really, any values for my free variables. I can pick any values for my x2's and my x4's and I can solve for x3. What I want to do right now is write this in a slightly different form so we can visualize a little bit better. Of course, it's always hard to visualize things in four dimensions. So we can visualize things a little bit better, as to the set of this solution. Let's write it this way. If I were to write it in vector form, our solution is the vector x1, x3, x3, x4. 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 x1 is equal to 2-- let me write a little column there-- plus x2. Let me write it this way. Plus x2 times something plus x4 times something. x1 is equal to 2 minus 2 times x2, or plus x2 minus 2. I put a minus 2 there. I can say plus x4 times minus 3. I can put a minus 3 there. This right here, the first entries of these vectors literally represent that equation right there. x1 is equal to 2 plus x2 times minus 2 plus x4 times minus 3. What does x3 equal? x3 is equal to 5. Put that 5 right there. Plus x4 times 2. x2 doesn't apply to it. We can just put a 0. 0 times x2 plus 2 times x4. Now what does x2 equal? You could say, x2 is equal to 0 plus 1 times x2 plus 0 times x4. x2 is just equal to x2. It's a free variable. Similarly, what does x4 equal to? x4 is equal to 0 plus 0 times x2 plus 1 times x4. What does this do for us? Well, all of a sudden here, we've expressed our solution set as essentially the linear combination of the linear combination of three vectors. This is a vector. You can view it as a coordinate. Either a position vector. It is a vector in R4. You can view it as a position vector or a coordinate in R4. You could say, look, our solution set is essentially-- this is in R4. Each of these have four components, but you can imagine it in r3. That my solution set is equal to some vector, some vector there. That's the vector. Think of it is as a position vector. It would be the coordinate 2, 0, 5, 0. Which obviously, this is four dimensions right there. It's equal to multiples of these two vectors. Let's call this vector, right here, let's call this vector a. Let's call this vector, right here, vector b. Our solution set is all of this point, which is right there, or I guess we could call it that position vector. That position vector will look like that. Where you're starting at the origin right there, plus multiples of these two guys. If this is vector a, let's do vector a in a different color. Vector a looks like that. Let's say vector a looks like that, and then vector b looks like that. This is vector b, and this is vector a. I don't know if this is going to be easier or harder for you to visualize, because obviously we are dealing in four dimensions right here, and I'm just drawing on a two dimensional surface. 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. We're dealing, of course, in R4. Let me write that down. We're dealing in R4. But linear combinations of a and b are going to create a plane. You can multiply a times 2, and b times 3, or a times minus 1, and b times minus 100. You can keep adding and subtracting these linear combinations of a and b. They're going to construct a plane that contains the position vector, or contains the point 2, 0, 5, 0. The solution for these three equations with four unknowns, is a plane in R4. I know that's really hard to visualize, and maybe I'll do another one in three dimensions. Hopefully this at least gives you a decent understanding of what an augmented matrix is, what reduced row echelon form is, and what are the valid operations I can perform on a matrix without messing up the system.