Transcript for:
Introduction to Linear Algebra

hi this is the first lecture in mi t--'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 the MATLAB codes the syllabus for the course is web dot mit.edu slash 18 point oh six and this is the first lecture lecture 1 so and later we'll say where 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 nice case and what I want to do is with examples of course to describe first what I call the Rope icture that's the picture of one equation at a time it's the picture you've seen before in two by two equations where lines meet so in a minute you'll see lines meeting the second picture I 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 in using a matrix that I'll call a Oh so can I do an example the whole semester will be examples and then see what's going on with it with the example so take an example two equations two unknowns so let me take 2x minus y equals zero let's say and minus X plus say two y equals three okay look I can even say right away what's the matrix that that is what's the coefficient matrix the matrix that involves these numbers a matrix is just a rectangular array of numbers here the here it's two rows and two columns so two and minus one in the first row minus 1 and 2 in the second row that's the matrix and the right-hand 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 0 3 I couldn't resist writing the matrix form right or even before the 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 extra bold and the right-hand side is also a vector that I'll always call B so linear equations are ax 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 satisfied 2x minus y equals 0 I'm often it's often good to start with which point on the horizontal line on this horizontal line y is 0 the x axis has y is 0 and that in this case actually then x is 0 so the point the origin the point with coordinates 0 0 is on the line it solves that equation ok tell me and well I guess I have to tell you another point that solves this same equation let me suppose X is 1 so I'll take X to be 1 then Y should be 2 right so there's the point 1 2 that also solves this equation then 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 of the of solutions to 2x minus y equals 0 my first row first equation so typically maybe X equal 1/2 y equal 1 will work and it's sure enough it does okay that's the first one now the second one is not going to go through the origin it's always the important do we go through the origin or not in this case yes because there's a 0 over there in this case we don't go through the origin because if x and y are 0 we don't get 3 so let me again say suppose Y is 0 what X do we actually get if y is 0 then I get X is minus 3 so if Y is 0 I go along minus 3 so there's one point on this second line now let me say well suppose X is minus 1 just to take another X if X is minus 1 then this is a 1 and I think Y should be a 1 because if X is minus 1 then I think why should be a 1 and we'll get that point is that right if X is minus 1 that's a 1 if Y is a 1 that's a 2 and the one in the to make 3 and that points on the equation ok now I should just draw the line right connecting those two points that 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 happened 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 shall we just checked at that point which which is the point X equal 1 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 1 I have a minus 1 plus 4 equals 3 ok apologies for drawing this picture that you've seen before but this seeing the row picture first of all for n equal to 2 equations in two unknowns it's the right place to start okay 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 P 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 that the X part is really so so 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 and in the first equation it's multiplying a minus one and in second equation of 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 some how to combine that vector and this one in the right amounts to get that much 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 okay now I want to draw a picture that represents what this this is algebra what's the geometry what's the picture that goes with it okay 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 do a combination of them so the first column is over 2 and down 1 right so there's the first column the first column column 1 it's the vector 2 minus 1 the second color is C I go over minus 1 is the first component and up to its here there's column 2 so this again you see what its components are its components are minus 1/2 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 okay so what the combination I'm going to take is the right one to produce 0 3 and then we'll see it happen in the picture so the right combination is to take X is 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 this linear combination so I start with this vector that's already here so that's one of column 1 that's 1 times column 1 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 add it 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 two there maybe I'll do dotted line for that ok that's one of column to tuck down to the end but I wanted to tuck on to of column 2 so that the second one will go up left 1 and up 2 also it'll probably end there and there's another one so so what I've put in here is 2 of column 2 added 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 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 2 and a minus 2 that produces a zero and in the second component I have a minus 1 and a 4 they combine to give the 3 but look at this picture so that 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 0 3 okay so that idea of linear combinations is crucial and 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 this is a question for really it's 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 just 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 okay 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 okay call I'll sort of start it the same way say maybe 2x minus y and maybe I'll take no no Z's is a zero and maybe a minus X and a 2y and maybe a minus Z is a oh let me make that a minus one and just for variety let me take minus 3z 2-3 wise I should keep the Y's in that line and for these is say 4 okay that's three equations I'm in three dimensions XYZ and I don't have a solution yet so I want to understand the equations and then solve them okay so how do i 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 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 0 minus 1/4 okay so that's the way we'll 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 & Z and I want to take those equations one at a time and s and make a picture of all the points that satisfy let us take equation number two if I make a picture of all the points that satisfy all the XYZ points that solve this equation well first of all the origin is not one of them XYZ being zero zero zero would not solve that equation so what what are some points that do solve the equation let's see maybe if X is one 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 Z could be 1x 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 zero let's say X to be zero Z to be zero then Y would be minus 1/2 right so there's a third point somewhere omma okay 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 things that 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 draw that that plane is all the points it 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 3x3 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 some somewhere ok those three things meet at a point now I don't know where that point is frankly but linear algebra will find it main point is that there is that the three planes because they're you know they're not parallel they don't they're not special there they do meet in one point and that's a solution but maybe you can see that this row picture is getting a little hard to see the road picture was a cinch when we looked at to 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 there that the row picture consists of three planes and if everything works right three planes meet in one point and that's a solution now you can tell I prefer the column picture okay so let me take the column picture that's x times so there were two x's in the first equation minus 1 X's I just take and no X's in the third 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 the x no Z's - onesies and four Z and it's those three columns right that I have to combine to produce the right-hand side which is 0-1 4 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 3-dimensional vector so we want to 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 2 and Y is minus 1 maybe maybe there's the first column Y the second column has maybe a minus 1 and a 2 and the Y's and minus 3 some somewhere there possibly column 2 and the third column has no no 0 minus 1/4 so how shall I draw that so nothing in this this was that this is the first component the second component was a minus 1 maybe up here that's column 3 that's that's the column 0 minus 1 and for this guy so again what's my problem my 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 0 y should be 0 and these should be what the come that's the combination none of that none of that one of those is obviously the right one so this column 3 is actually the same as B in this particular problem I made it work that way just so we would get an answer 0 0 1 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 every bit of software to a production large scale software would solve the equations so the lecture that's coming up if I was to add that to the the syllabus will be about how to find XYZ in in all cases can I just think again though about the big picture the big buy 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 1 and a 1 and a minus 3 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 so actually it just changed around to this when I took this new right hand side ok so that in there in the role picture I have three different planes three three 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 the new beak okay so that's like we squeezed in an extra example but now think about all bees all right hand sides could I get can I solve these equations for every right hand side and can I say that asset question so that's the algebra 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'm just 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 in different words solving a ax oh that's very important a times X when I multiply a matrix by a vector I get a combination of the columns let me 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 this this matrix that 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 this 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 be off here when when could it go wrong do you see that the combinations suppose 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 1 and column 2 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 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 okay I don't know given so 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 there linear combinations so we 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 some sometimes the answer will be yes if I picked a random matrix it would be yes actually if I use MATLAB and just use the random command picked out a 9 by 9 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 the ninth column is the same as the 8th column then it contributes nothing new and there would be right-hand sides B that I couldn't get okay can you sort of think about nine vectors in nine dimensional space and take their combinations that's really the central thought that that you get kind of used to in linear algebra even so you can't really visualize if 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 come 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 eventually for now let's stay with a nice case where the matrices work we can get every right-hand side B and here we see how to do it with columns okay there was one step that I real at which 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 about my equation of my might system is some matrix a times some vector X equals some right-hand side B okay 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 okay so I'm just going to create a a matrix let me take 2 5 1 3 and let me take a vector X to be say 1 & 2 how do I multiply a matrix by a vector and just we'll 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 a its columns again it's a column at a time for me that matrix mode 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 and let's just see what we get so in the first component I'm getting a two and a 10 I'm getting a 12 there and the second component I'm giving a 1 and a 6 I'm getting a 7 so that that matrix times admixture is 12:7 now you could do that another way you could do it a row at a time you could do and you would get this 12 and actually I pretty much did it here this way too I could take that row times my vector this is this is all the time this is the idea of a dot product this vector times this vector 2 times 1 plus 5 times 2 is the 12 this vector times this vector 1 times 1 plus 3 times 2 is the 7 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 okay so that's a the picture for two-by-two system and if the right-hand side B happened to be 12 7 then of course the correct solution would be 1 2 okay 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 the system because eliminate elimination fails find out when there isn't a solution ok thanks you