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

Current time:0:00Total duration:21:10

in the last couple of videos I already exposed you to the idea of a matrix which is really just an array of numbers into usually a two-dimensional array actually it's always a two-dimensional array for our purposes so if I have an M by n matrix M by n the M is just the number of rows rows and then the N is just the number of columns columns so let me write out the M by n matrix so I'll just specify let say I have the M by n matrix a to capital bold a and it's equal to I'll be as general as possible first entry is in its I'll just call that lowercase a it's in Row one column one the next entry is Row one column two and you go all the way to Row one column n right you have n columns and then when you go down you go to the next row will be Row two column one and then you keep going all the way down to row m column N and then of course what this this entry is going to be Row two let me write that a little smaller Row two column two and you go all the way and you're going to have row em column n and so if you think about it you're going to have how many total entries here you're going to have M entries this way and that way so you're gonna have M times n total entries and I think you're pretty familiar with this idea already of a matrix you probably saw this in your algebra 2 classes so what we want to do now in this video is relate our notion of a matrix to everything we already know about vectors or maybe introduce some operations that allow matrix and vectors to interact with each other and maybe the most natural one is multiplication or taking the product so what I'm going to do in this video is is define I'm going to define what it means when we take the product of our matrix a of any matrix a I've written this as general as possible with some vector X and our definition will only work will only work is only defined if X if the vector we're multiplying a by has the same number of components has the same number of components as a has columns so this is only that valid for an X that looks like this an X that looks like this x1 x2 all the way down to X and so let me be very clear this this make this vector right here it's going it could be a different I guess you could do it a different height than this vector what matters is is that the same number of A's you have in this direction you have n A's here then you have n components of this vector right here and if you have that constraint if the length of your of your vector the number of components in vector is equal to the number of columns in your matrix then we define this product to be equal to so this is my that's my vector X so this is a definition there's nothing in nature that told us it had to be defined this way it's just human beings or mathematicians decided that this is a useful convention to define the multiplication or the product of a matrix and a vector so we will define a times our vector X these are both bold or this is a matrix that's a vector and the convention if I didn't draw a little vector symbol your textbooks will just bold out the X so it'll be a lowercase X lowercase is vector uppercase as matrix both of them are bolded that tells you that you're not just dealing with regular numbers so we're defining these this to be equal to let me write it out fairly large you're going to take each row you're going to take each one we're going to show you that there's multiple ways to kind of visualize this but it's going to be a 1 1 times X 1 let me write that down so a 1 1 times X 1 plus a 1 2 A 1 2 so a 1 1 times X 1 plus a 1 2 times X 2 times X 2 all the way to plus a 1/n times xn so that's just the first so the product of V of this matrix this M by n matrix and this n component vector will be a new vector the first entry the first entry of which is essentially each of these entries times the corresponding entry here and you add them all up and as you can see that's already looking fairly similar to a dot product I'll discuss that in a second but let me finish my definition before I start talking about what it means or what it might be related to so that was that first row right there it'll just look like that we just multiply that times this thing to get that row there now the second row I'll do it in this I'm going to want to do it in a different color the second row remember this is a definition human beings came up with this nothing about nature said we had to do it this way but it's just nice and convenient so our second row will have a to 1 times x1 we'll just do the whole thing over again but this time we're multiplying this row times this column vector so 8 to 1 times x1 plus a2 2 times X 2 times x2 all the way until we get to a 2 I wanted to do that in magenta a to n times X n so we multiplied this entire row times that entire column this term times that term Plus this term Plus this term all the way down to this last term times that last all the way down to plus this last term times that last term and then we keep doing this for every row until we get to the enth row until we get to the M throw and then the M throw will be a M 1 oh sorry this is am one right this is the M throw first column am 1 times x1 plus it's hard to keep switching colors plus am 2 times x2 all the way until we get to a M n x xn all the way until we get to a M n - x times X n so what does this vector going to look like it's essentially going to have if we call this vector let's say we call this vector let's say it's equal to vector B what does vector B look like how many entries is going to have well it has an entry for each row of this right we're taking each row and we're multiplying we're essentially taking the dot product of this row vector with this column vector and I'll be a little bit more formal with the notation in a second but I think you understand this is a dot product we're taking each corresponding the first component times the first component plus the second component times the second component plus the third component times the third component all the way to the nth component plus the nth component times the nth component so this is essentially the dot product of this row vector row vector is just a fad it's just you're writing a row we've been writing all of our vectors as columns so we could call them column vectors you're just writing them as rows and we can be a little bit more specific with the notation in a second but what's this going to look like what we're doing this M time so we're going to have M entries is you're going to b1 b2 all the way to B n if you viewed these as all as matrices you can kind of view it as you have a u v and this will eventually work for the matrix math we're going to learn this is an M by n matrix and we're multiplying it by how many rows does this guy have he has an he has n rows right he has n components and he has one column so M by n times an N by one you get essentially you can kind of ignore these middle two terms and they will result with how many rows is this guy have he has m rows and one column so if you take out these these middle two terms have to be equal to each other just for the multiplication to be defined and then you're left with an M by one matrix so this was all abstract let me actually apply it to some actual numbers but it's important to actually set the definition set the definition now that we have the definition we can apply it to some actual matrices and vectors so let's say we have the matrix let's say I want to multiply the matrix - 3 zero three two I'll do this one in yellow one seven minus one nine and I want to multiply that by the vector now how many components or rows does this vector have to have well my matrix times vector product or multiplication is only defined if my vector has as many components as this as this matrix has columns so we have one two three four columns so this guy's got to have four components first even be able to multiply them otherwise it wouldn't be defined so let me put four entries here let's say it's two minus three four and then minus one so what is this going to be equal to this is equal to we just we essentially take the dot the first term of this is going to be the dot product of this first row with this first with this vector and then the second entry here is going to be the dot product of this column vector this row vector with this column so let's do it so it's going to be minus three times two minus three times two I'm not going to color-coded minus three times two plus 0 times minus 3 0 times minus 3 plus 3 times 4 3 times 4 plus 2 times minus 1 plus 2 times minus 1 and now my second row or I guess my second component in this vector is going to be 1 times 2 so 1 times 2 plus 7 times negative 3 7 times minus 3 plus minus 1 times 4 minus 1 times 4 plus 9 times minus 1 9 times minus 1 and so what does this simplify to this is equal to minus 3 times 2 is minus 6 plus 0 plus 0 plus 12 right this is 12 minus 2 and then this is simplify to 2 minus 21 minus 21 minus 4 that look like a - -21 - 4 - 9 so this is equal to this top term let's see I have a minus 6 plus 12 the 6 minus 2 is 4 and then I have 2 minus 21 is minus 19 I want to make sure I get the math right here let me see minus 21 minus 9 is minus 30 and if a minus 34 and then I have a plus 2 so minus 32 so that's my product right there and like I said you can view it and let me be very clear right here well everything we've been used to right now we've been writing our vectors as column vectors but you can view these you can view each of these right here you could view each of these guys right here as a row vector but let me be even better let's say that let's say that vector let me call vector a a 1 so let me define vector a 1 is equal to is equal to minus 3 0 3 2 and let me define vector a 2 to be equal to vector a 2 is equal to 1 7 minus 1 9 so all I did is I wrote these guys but I wrote them in our standard vector form I wrote them as column vectors so what we can write what we can define to turn these guys into row vectors is the transpose function and transpose you just turn the rows into columns and the columns into rows so this is a 1 then with a 1 transpose a 1 transpose will just be the row version of this so it's minus 3 0 3 2 and then a 2 transpose would be equal to 1 7 minus 1 + 9 and then this multiplication right here we can rewrite it as this matrix we can rewrite it as we have vector a 1 transpose for the first row a 1 transpose that's a vector these are vectors now row vectors and then this is a to transpose a to transpose the transpose should be the superscript this this vector can be rewritten exactly like this right because it's the first rows is the second row x times the vector x let me just call this vector and let me just call this vector X that right there is vector X so this is right here vector X we can now rewrite the definition as this is this would be equal to what this first row right here that we wrote out the first row that we wrote out right here this was a a 1 dot X right a 1 dot X and you know that all about the dot products this was the first row was a 1 dot dot X right it's minus 3 x minus x 2 plus 0 times minus 3 plus 3 times 4 right it's a 1 dot X and this is useful because we haven't when I define the dot product I only defined it with column vectors like this and all I'm dotting two column vectors I haven't formally defined a row vector times a column vector so now I can say look if this is a this is just a standard column vector like we've been working with I can write my matrix as each row is the transpose of a column vector or it's a row vector then I can write this product as just the dot products of each of these transpose or I guess you could say the inverse transpose with this vector right here and then obviously the second row it's going to be a 2 a 2 vector a 2 dot X dot X right the second row is a 2 X is 1 times 2 plus 7 times minus 3 right there minus 1 times 4 plus 9 times minus 1 so just just like that so this is one way to view it use its kind of matrix times the vector is just like the transpose of its rows dotted with the vector you're multiplying it by is one way to perceive matrix multiplication now the other way the other way to perceive it let me do it this way if you maybe I'll do it with a different with a different example those numbers are getting a little bit tiresome let's say I have the matrix a nice bold is equal to it's equal to you know I don't know let me say it's 3 1 0 3 2 4 7 0 minus 1 2 3 & 4 and I need to multiply this I have to multiply this times a 4 component vector so let me call vector X is equal to I don't know it's equal to 5 actually let me just keep it general let's say it's equal to X 1 X 2 X 3 and X 4 now we instead of viewing these as row vectors we could view a as a set of column vectors right we could call this thing right here we could call that vector 1 we call this thing right here vector 2 we call this thing right here vector 3 and we call this thing right here vector 4 then we could rewrite our matrix a as being equal to just a bunch of column vectors so we could rewrite it as vector 1 vector 2 vector 3 is vector 1 and vector 4 that's vector 4 right there so how can the matrix multiplication be interpreted in this context well what did we do we multiplied when we multiply these guys we always do all of the elements in here always get multiplied by X 1 right it's three let me start some of the multiplication here just from our definition so if I multiply a times X I'll start it off maybe I won't do the whole thing I just want you to see the pattern it's 3 times X 1 3 times X 1 plus +1 times X 2 plus 0 times X 3 plus 3 times X 4 that's the first entry and then you have 2 times X 1 2 times X 1 plus 4 times X 2 all the way and then you finally have minus 1 times X 1 plus 2 times X 2 you get the idea but what's happening here this guy this first vector is always being multiplied by the scalar X 1 in fact you can view this this and this part of the entries right here right we're just multiplying this guy times the scalar of X 1 in every case right you have 3 2 minus 1 3 2 minus 1 we're multiplying by the scalar of X 1 and then we're multiplying and then we're adding that to this guy times the scalar X 2 right and then we're multiplying and then we're adding that to this guy times the scalar X 3 so we can rewrite a we can rewrite a times X a times X as being equal to the scalar X 1 the scalar X 1 times the vector V 1 times the vector V 1 plus the scalar X 2 right this is the scalar X 1 times the vector V 1 plus the scalar X 2 times the vector V 2 I want to do that in yellow times the vector V 2 plus X 3 times the vector V 3 plus the scalar X 4 times the vector V 4 V 4 and obviously if we had n terms here we'd have to have n vectors here and we could just take this make this more general 2n but what's interesting here is now the product the product ax it can be interpreted as a linear combination right this is just a these are just arbitrary numbers depending on depending on what our vector X is so depending on our vector X we're taking a linear combination of the column vectors of a so this is a linear combination linear combination of column vectors column vectors of a so this is really interesting I'm sure you've been exposed to matrix multiplication in the past but I really want you to kind of to absorb these two ways of interpreting it because they'll be important when we talk about column spaces and and and things like that in the future is that you can interpret matrix multiplication and actually there's other ways you can read you can actually interpret it as a transformation of this vector X but I won't cover that in this video just for brevity but you can interpret it as a as combat as a weighted combination or linear combination of the column vectors of a where the matrix X dictates what the weights on each of the columns are or you can interpret it as essentially the dot product of the row vectors or you can define the row vectors as the transpose of column vectors the dot product of those column vectors each of the corresponding column vectors with your metric matrix X so these are both completely valid interpretations and hopefully at least this video at least gives you a a working knowledge of what matrix multiplication is and even better gives you a little bit deeper sense of all of the different ways that it can be interpreted