Hi. This is the first lecture in MIT's course 1806, linear algebra. And I'm Gilbert Strang. The text for the course is this book, Introduction to Linear Algebra. And the course web page, which has got a lot of exercises from the past, MATLAB codes, the syllabus for the course is web.mit.edu slash 18.06.
And this is the first lecture, lecture one. So, and later we'll say, which will give the web address for viewing these videotapes. OK, so what's in the first lecture?
This is my plan. The fundamental problem of linear algebra, which is to solve a system of linear equations. So let's start with the case when we have some number of equations, say n equations and n unknowns. So an equal number of equations and unknowns.
That's the normal NISQ case. And what I want to do Is with examples, of course, to describe first, what I call the row picture. That's the picture of one equation at a time. It's the picture you've seen before in two by two. two equations where lines meet.
So in a minute you'll see lines meeting. The second picture, I'll put a star beside that, because that's such an important one, and maybe new to you, is the picture. A column at a time.
And those are the rows and columns of a matrix. So the third, the algebra way to look at the problem, is the matrix form, using a matrix that I'll call A. OK.
So can I do an example? The whole semester will be examples, and then see what's going on with the example. So take an example. Two equations, two unknowns. So let me take two x minus y equals zero, let's say, and minus x plus, say, two y equals three.
Okay. I can even say right away, what's the matrix? That is, what's the coefficient matrix? The matrix that involves these numbers. A matrix is just a rectangular array of numbers.
Here it's two rows and two columns. So two and minus one in the first row, minus one and two in the second row, that's the matrix. And the unknown. Well, we've got two unknowns. So we've got a vector x with two components, x and y, and we've got two right-hand sides that go into a vector zero, three.
I couldn't resist writing the matrix form right even before the pictures. So I always will think of this as the matrix A, The matrix of coefficients. Then there's a vector of unknowns.
Here we've only got two unknowns. Later we'll have any number of unknowns. And that vector of unknowns, well, I'll often, I'll make that x extra bold. And the right-hand side is also a vector that I'll always call b. So linear equations are A x equal b, and the idea now is to solve this particular example, and then step back to see the bigger picture.
Okay, what's the picture for this example? The row picture. Okay, so here comes the row picture.
So that means I take one row at a time, and I'm drawing here the xy plane, and I'm going to put, plot all the points that satisfy that first equation. So I'm looking at all the points that satisfy 2x minus y equals zero. It's often good to start with which point on the horizontal line? On this horizontal line, y is zero. The x-axis has y is zero, and that in this case, actually, then x is zero.
So the point. The origin, the point with coordinates is on the line. It solves that equation. OK, tell me an, well, I guess I have to tell you, another point that solves this same equation.
Let me suppose x is one, so I'll take x to be one, then y should be two, right? So there's the point one, two that also solves this equation. And I could put in more points.
But let me put in all the points at once, because they all lie on a straight line. This is a linear equation, and that word linear got the letters for line in it. That's the equation, that's, this is the line that, of, that, of solutions to two x minus y equals zero.
My first row, first equation. So typically maybe x equal a half, y equal one will work. And it's sure enough it does.
OK. That's the first one. Now the second one is not going to go through the origin. It's always important, do we go through the origin or not? In this case, yes, because there's a zero over there.
In this case, we don't go through the origin, because if x and y are zero, we don't get three. So let me again, again say, suppose y is zero, what x do we actually get? If y is zero, then I get x is minus three. So if y is zero, I go along minus three. So there is one point on this second line.
Now let me say, well, suppose x is minus one. Just to take another x. If x is minus one, then this is a one. And I think y should be a one, because if x is minus one, then I think y should be a one and we'll get that point.
Is that right? If x is minus one, that's a one. If y is a one, that's a two, and the one and the two make three, and that point's on the equation.
OK, now I should just draw the line, right? Connecting those two points, that will give me the whole line. And if I've done this. Reasonably well.
I think it's going to happen to go through, well, not happen, it was arranged to go through that point. So I think that the second line is this one, and this is the all-important point that lies on both lines. Shelby just checked that that point, which, which is the point x equal one and y was two, right? That's the point there, and that, I believe, solves both equations.
Let's just check this. If x is one, I have a minus one plus four equals three. OK. Apologies for drawing this picture that you've seen before.
But, this, seeing the row picture, first of all, for n equal two, two equations and two unknowns, it's the right place to start. OK. So we've got the solution, the point that lies on both lines. Now can I come to the column picture?
Pay attention. This is the key point. So the column picture.
I'm now going to look at the columns of the matrix. I'm going to look at this part and this part. I'm going to say that the x part is really, so, so it is really x times, You see I'm putting the two, I'm kind of getting the two equations at once.
That part, and then I have a y, and in the first equation it's multiplying a minus one, and in the second equation a two, and on the right hand side, zero and three. You see the columns of the matrix? The columns of A are here, and the right-hand side, B, is there. And now what is the equation asking for? It's asking us to find, somehow to combine that vector and this one in the right amounts to get that one.
It's asking us to find the right linear combination. This is called a linear combination. And it's the most fundamental operation in the whole course. It's a linear combination of the columns. That's what we're seeing on the left side.
Again, I don't want to write down a big definition. You can see what it is. There's column one, there's column two.
I multiply by some numbers and I add. That's a combination, a linear combination, and I want to make those numbers the right numbers to produce zero three. OK.
Now I want to draw a picture that represents what this is. This is algebra. What's the geometry, what's the picture that goes with it? OK. So again, these vectors have two components, so I better Draw a picture like that.
So can I put down these columns? I'll draw these columns as they are, and then I'll do a combination of them. So the first column is over two and down one, right?
So there's the first column. The first column, column one. It's the vector two minus one. The second column.
Is, let's see, I go over, minus one is the first component, and up two, it's here. There's column two. So this, again, you see what its components are.
Its components are minus one, two. Good. That's this guy. Now what is, what, now I have to take a combination.
What combination shall I take? Why not the right combination? What the hell. OK.
So the combination I'm going to take is the right one to produce zero three, and then we'll see it happen in the picture. So the right combination is to take x as one of those, and two of these. It's because we already know that that's the right x and y, so why not take the correct combination here and see it happen? Okay, so how do I picture this linear combination?
So I start with this vector, that's already here, so that's one of column one, that's one times column one, right there. And now I want to add on, so I'm going to hook the next vector on to the front of the arrow, we'll start the next vector. and it'll go this way.
So let's see, can I do it right? If I added on one of these vectors, it would go left one and up two, so it would go left one and up two, so it would probably get us to there. Maybe I'll do dotted line for that.
OK. That's one of column two tucked onto the end, but I wanted to tuck on two of column two. So the second one will go up left one and up two also. It'll probably end there. there, and there's another one.
So what I've put in here is two of column two. Add it on. And where did I end up?
What are the coordinates of this result? What do I get when I take one of this plus two of that? I do get that, of course. There it is.
There it is. x is zero, y is three. That's b. That's the answer we wanted. And how do I do it?
You see, I do it just like the first component. I have a two and a minus two. That produces a zero.
And in the second component, I have a minus one and a four. They combine to give the three. But look at this picture.
So here's our key picture. I combined this column and this column to get, maybe I better, to get this guy. That was the b. That's the zero three. OK.
So that idea of linear combinations is crucial, and also, do we want to think about this question? Sure, why not? What are all the combinations?
If I took, can I go back to x's and y's? This is a question for really, it's going to come up over and over, but why don't we see it once now? If I took all the x's and all the y's, all the combinations, What would be all the results?
And actually, the result would be that I could get any right-hand side at all. The combinations of this and this would fill the whole plane. You can tuck that. away, we'll explore it further.
But this idea of what linear combination gives b, and what do all the linear combinations give, what are all the possible achievable right-hand sides b, that's going to be basic. OK. Can I move to three equations and three unknowns?
Because it's easy to. Picture the two by two case. Let me do a three by three example.
OK, I'll sort of start it the same way, say maybe 2x minus y, and maybe I'll take no z's as a zero, and maybe a minus x and a 2y, and maybe a minus z is a, oh, let me make that a minus 1, and just for variety, let me take minus 3z. Minus three y's, I should keep the y's in that line, and four z's is, say, four. OK.
That's three equations. I'm in three dimensions, x, y, z, and I don't have a solution yet. So I want to understand the equations and then solve them.
OK. So how do you understand them? The row picture is one way, the column picture is another very important way.
Just let's remember the matrix form here, because that's easy. The matrix form, what's our matrix A? Our matrix A is this right-hand side, the 2 and the minus 1 and the 0 from the first row, the minus 1 and the 2 and the minus 1 from the second row, the 0, the minus 3, and the 4. From the third row. So it's a three by three matrix. Three equations, three unknowns.
And what's our right hand side? Of course it's the vector zero minus one four. OK.
So that's the way, well that's the shorthand to write out the three equations. But it's the picture that I'm looking for today. OK.
So the row picture. All right, so I'm in three dimensions, x, y, and z, and I want to take those equations one at a time and ask, and make a picture of all the points that satisfy. Let's take equation number two. If I make a picture of all the points that satisfy, all the x, y, z points that solve this equation, Well, first of all, the origin is not one of them. x, y, z being 0, 0, 0 would not solve that equation.
What are some points that do solve the equation? Let's see, maybe if x is 1, Y and z could be zero. That would work, right?
So there's one point. I'm looking at this second equation here, just to start with. Let's see, also I guess if z could be one, x and y could be zero, so that would just go straight up that axis.
And probably I want a third point here. Let me take x to be a. 0, say x to be 0, z to be 0, then y would be minus a half, right? So there's a third point somewhere.
OK. Let's see. I want to put in all the points that satisfy that equation. Do you know what that bunch of points will be?
It's a plane. If we have a linear equation, then fortunately, the graph of the thing, the plot of all the points that solve it, are a plane. So I, and three, these three points determine a plane, but Your lecture is not Rembrandt, and this, the art, is going to be the weak point here. So I'm just going to draw a plane, right? There's a plane somewhere.
That's my plane. That plane is all the points that solves this guy. Then what about this one?
2x minus y plus zero z. So z actually can be anything. Again, it's going to be another plane. Each row in a three by three problem gives us a plane in three dimensions. So this one is going to be some other plane, maybe it, maybe I'll try to draw it like this.
And those two planes meet in a line. So if I have two equations, Just the first two equations in three dimensions, those give me a line, the line where those two planes meet. And now the third guy is a third plane, and it goes somewhere.
OK, those three things meet in a point. Now I don't know where that point is, frankly, but linear algebra will find it. The main point is That there is, that the three planes, because they're, you know, they're not parallel, they're not special, they do meet in one point, and that's the solution. But maybe you can see that this row picture is getting a little hard to see. The row picture was a cinch when we looked at two lines meeting.
When we look at three planes meeting, it's not so clear, and In four dimensions, probably a little less clear. So can I quit on the row picture? I'll quit on the row picture before I've successfully found the point where the three planes meet. All I really want to see is that the row picture consists of three planes, and if everything works right, three planes meet in one point, and that's the solution. Now, you can tell I prefer the column picture.
OK? So let me take the column picture. That's x times, so there were two x's in the first equation, minus one x's, I'm just taking, and no x's in the third. It's.
It's just the first column of that. And how many y's are there? There's minus one in the first equation, two in the second, and maybe minus three in the third. Just the second column of my matrix.
And z times no z's, minus one z's, and four z's. And it's those three columns, right, that I have to combine to produce The right-hand side, which is zero minus one, four. Okay. So what have we got on this left-hand side?
A linear combination. It's a linear combination now of three vectors, and they happen to be, each one is a three-dimensional vector. So we want to know what combination of those three vectors produces that one. Shall I try to draw the column picture then? So since these vectors have three components, so it's some multiple.
Let me draw in the first column as before. So I x is two and y is minus one. Maybe there's the first column. Y, the second column has maybe a minus one and a two in the y's and minus threes, somewhere there possibly, column two.
And the third column has no zero minus one four. So how shall I draw that? So nothing in this was the first component.
The second component was a minus one, maybe up here. That's column three, that's the column zero, minus one, and four. This guy.
So again, what's my problem? What this equation is asking me to do is to combine these three vectors with the right combination to produce this one. Well.
You can see what the right combination is. Because in this special problem, especially chosen by the lecturer, that right-hand side that I'm trying to get is actually one of these columns. So I know how to get that one.
So what's the solution? What combination will work? I just want one of these and none of these.
So x should be zero, y should be zero, and z should be one. That's the combination. None of that, none of that, one of those is obviously the right one. So this column three is actually the same as b in this particular problem. I made it work that way just so we would get an answer, zero, zero, one, so somehow that's the point that, where those three planes met and I couldn't see it before.
Of course, I won't always be able to see it from the column picture either. It's the next lecture, actually, which is about elimination, which is the systematic way that everybody Every bit of software, too, production, large-scale software would solve the equations. So the lecture that's coming up, if I was to add that to the syllabus, will be about how to find x, y, z in all cases.
Can I just think again, though, about the big picture? The big, by the big picture I mean, let's keep this same matrix on the left, but imagine that we have a different right-hand side. Oh, let me take a different right-hand side. So I'll change that right-hand side to something that actually is also pretty special.
Let me change it to, suppose I, if I add those first two columns, that would give me a one and a one and a minus three. There's a very special right-hand side. I just cooked it up by adding this one to this one. Now, what's the solution with this new right-hand side? The solution with this new right-hand side is clear.
It took, now I took one of these, one of these, and none of those, so actually it just changed around to this, when I took this new right-hand side. OK. So in the row picture, I have three different planes.
Three new planes meeting now at this point. In the column picture I have the same three columns, but now I'm combining them to produce this guy, and it turned out that column one plus column two, which would be somewhere there, there is the right column. One of this and one of this would give me the new b.
OK. So that's like we squeezed in an extra example. But now think about all b's, all right-hand sides. Could I get, can I solve these equations for every right-hand side? Can I say that, ask that question?
So that's the algebraic question. Can I solve Ax equal b for every b? Let me write that down.
Can I solve Ax equal b for every right-hand side b? I mean, is there a solution? And then if there is, elimination will give me a way to find it.
I really wanted to ask, is there a solution for every right-hand side? So now, can I put that in different words? In this linear combination words, so in linear combination words, do the linear combinations of the columns fill three-dimensional space? Every b. Means all the b's in three-dimensional space.
So do you see that I'm just asking the same question in different words? Solving A x, oh, that's very important. A times x, when I multiply a matrix by a vector, I get a combination of the columns. I'll write that down in a moment.
So that you see, but in my column picture, that's really what I'm doing. I'm taking linear combinations of these three columns, and I'm trying to find b. And actually, the answer for this matrix will be yes.
For this matrix, for this, for this matrix A, for these columns, the answer is yes. This matrix is, this matrix that I chose for an example, Is a good matrix, a non-singular matrix, an invertible matrix. Those will be the matrices that we like best.
There could be other, and we will see other matrices, where the answer becomes no. Oh, actually, you can see when it would become no. When could What could go wrong?
How could it go wrong that out of these, out of three columns and all their combinations, when would I not be able to produce some b off here? When could it go wrong? Do you see that the combinations, let me say when it goes wrong. If these three columns all lie in the same plane, Then their combinations will lie in that same plane. So then we're in trouble.
If the three columns of my matrix, if those three vectors happen to lie in the same plane, for example, if column three is just the sum of column one and column two, I would be in trouble. That would be a matrix A where the answer would be no. Because the combinations, if column three is in the same plane as column one and two, I don't get anything new from that.
All the combinations are in the plane, and the only right-hand sides, B, that I could get would be the ones in that plane. So I could solve it for some right-hand sides. when B is in the plane, but most right-hand sides would be out of the plane and unreachable.
So that would be a singular case. The matrix would be not invertible. There would not be a solution for every B.
The answer would become no for that. OK. Shall we take just a little shot at thinking about Nine dimensions. Imagine that we have vectors with nine components. Well, it's going to be hard to visualize those.
I don't pretend to do it. But somehow, Pretend you do. Pretend we have, if this was nine equations in nine unknowns, then we would have nine columns, and each one would be a vector in nine-dimensional space, and we would be looking at their linear combinations. So we'd be having the linear combinations of nine vectors in nine-dimensional space, and we would be trying to find the combination that hit the correct right-hand side B. And we might also ask the question, can we always do it?
Can we get every right-hand side B? And certainly it will depend on those nine columns. Sometimes the answer will be yes.
If I picked a random matrix, it would be yes, actually. If I used MATLAB and just use the random command, picked out a nine by nine matrix, I guarantee it would be good. It would be non-singular, it would be invertible, all beautiful.
But if I choose those columns so that they're not independent, so that they're there, so that the ninth column is the same as the eighth column. Then it contributes nothing new and there would be right-hand sides b that I couldn't get. Can you sort of think about nine vectors in nine-dimensional space and take their combinations? That's really the central thought that you get kind of used to. In linear algebra, even though you can't really visualize it, you sort of think you can after a while.
Those nine columns and all their combinations may very well fill out the whole nine-dimensional space. But if the ninth column happened to be the same as the eighth column and gave nothing new, then probably what it would fill out would be I hesitate even to say this. It would be a sort of plane, an eight-dimensional plane inside nine-dimensional space.
And it's those eight-dimensional planes inside nine-dimensional space that we have to work with eventually. For now, let's stay with the nice case where the matrices work, we can get every right-hand side b, and here we see how to do it with columns. OK.
There was one step that I realized I was saying in words that I now want to write in letters. Because I'm coming back to the matrix form of the equation, so let me write it here. The matrix form of my equation, of my system, is some matrix A times some vector x equals some right hand side B.
OK. So this is a multiplication, A times x, matrix times vector, and I just want to say, how do you multiply a matrix by a vector? OK, so I'm just going to create a matrix. Let me take two, five, one, three, and let me take a vector, x to be, say, one and two. How do I multiply a matrix by a vector?
And just think a little bit about matrix notation and how to do that multiplication. So let me say how I multiply a matrix by a vector. Actually, there are two ways to do it.
Let me tell you my favorite. way. It's columns again.
It's a column at a time. For me, this matrix multiplication says I take one of that column and two of that column and add. So this is, in my, the way I would think of it, is one of the first column and two of the second column. And let's just see what we get.
So in the first component I'm getting a two and a ten, I'm getting a twelve there. In the second component I'm getting a one and a six, I'm getting a seven. So that matrix times that vector is twelve seven. Now you could do that another way.
You could do it a row at a time. You could do, and you would get this twelve, and actually I pretty much did it here, this way. Two, I could take that row times my vector.
This is all the time, this is the idea of a dot product. This vector times this vector. Two times one plus five times two is the twelve.
This vector times this vector. One times one plus three times two is the seven. So I can do it by rows.
And in each row, each row times my x is what I'll later call a dot product. But I also like to see it by columns. I see this as a linear combination of the columns. So here's my point.
A times x is a combination of the columns of A. That's. That's how I hope you'll think of A times x when we need it. Right now we've got, with small ones, we can always do it in different ways, but later think of it that way.
OK. So that's the picture for a two by two system. And if the right-hand side B happened to be twelve-seven, then of course the correct solution would be one-two. OK.
So let me come back next time to a systematic way, using elimination, to find the solution, if there is one, to any, a system of any size, and find out Because if elimination fails, find out when there isn't a solution. OK, thanks.