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:18:14

Video transcript

in the last video we learned what it meant to take the product of two matrices so if we have one matrix a and it's an M by n matrix and then we have some other matrix B let's say that's an N by K matrix then we've defined the product of a and B so a and B the product of a and B to be equal to and actually before I define the product let me just write B out as just a collection of column vectors so we know that B can be written as a column vector B 1 another column vector B 2 and all the way it's going to have K of them because it has exactly K columns so B K so the last video we defined the product of a and B and they have to have the columns of a have to be the same as the rows of B in order for this to be well-defined but we define this product to be equal to a times each of the column vectors of B so it's equal to let me switch back to that color is equal to a times due to the color that I did it a times B 1 and then the second column of our product is going to be a times B 2 a times B 2 our third product is going to be a times B 3 B 3 all the way to a times B K a times B K B K right there and the whole motivation for this you've probably seen this before maybe in your algebra 2 class it might have not been defined exactly this way but this is equivalent to what you probably saw in your algebra 2 class but the neat thing about this definition is that the motivation came from the composition of two linear transform transformations whose transformation matrices where the matrices a and B and I showed you that in the last video but with that said let's actually compute some matrix matrix products just so you get the hang of it so let's say that I have matrix a let's say that a is equal to the matrix 1 - 1 - 0 - 2 + 1 I'll keep the numbers low to keep our arithmetic fairly straightforward and let's say that I have the matrix B the matrix B and let's say that it is equal to 1 0 1 1 - 0 1 - 1 and then 3 1 0 2 so a is a 2 by 3 matrix is 2 by 3 2 rows 3 columns and B is a 3 by 4 matrix so by our definition what is the product a B going to be equal to well we know it's well-defined because the number of columns here is equal to the number of rows so we can actually take these matrix vector products you'll see that in a second so a B a B is equal to is equal to the matrix a time's the column vector 1 2 3 that's going to be the first column in our product matrix and the second one is going to be the matrix a time's the column 0 0 1 the third column is going to be the matrix a time's the column vector 1 1 0 and then the fourth column in our product vector is going to be the matrix a time's the column vector 1 minus 1 2 and this when we write it like this it should be clear why this has to be Y the number of columns in a have to be the number of rows and B because the column vectors in B are going to have the same number of components as the number of rows in B so all of the column vectors in B so if we call this b1 b2 b3 b4 all of my B is B right all of my bi is where this I could be one two or three or four are all members of our three so we only have matrix-vector products well defined when the number of columns in your matrix are equivalent to essentially the dimensionality of your vectors that's why that number and that number has to be the same well now we've reduced our matrix matrix product problem to just a bunch for different matrix vector product problems so we can just multiply these these is this is nothing new to us so let's do it let's do it and so what is this equal to so a B let me rewrite it a B my product vector is going to be equal to so this first column is the matrix a time's the column vector one two three and how did we define that remember one way to think about it is that this is equal to the you can kind of think of it as the each of the rows of a dotted with the column here of B or even better this is the transpose of some matrix right like let me let me write this this way if a if a is equal to sorry the transpose of some vector let's say that a is equal to the column vector 0 minus 1/2 then a transpose and I haven't talked about transposes a lot yet but I think you get the idea you just changed all of the columns into rows so a transpose will just be equal to 0 minus 1/2 you just go from a column vector to a row vector so if we call this thing here a transpose then when we take when we take the product of our matrix a times this vector we essentially are just taking the trend we're just sticking a and dotting with this guy for our first row in our first column so let me do it that way so let me write it in that notation so this is going to be the matrix or sorry the vector 1 minus 1/2 that's essentially that row right there represented a column dotted with dotted with one two three actually let me do it in that color just so I can later switch to one color to make things simple but dotted with one two three so we just took that row or I guess the column equivalent of that row and dotted with this and I wrote it like this because we've only defined dot products four column vectors I could do it maybe four row vectors but no need to make a new definition and then the next so that's going to be the first entry in this matrix vector product the second entry is going to be the second row of a the second row of a essentially dotted with this vector right there so it's going to be equal to zero minus two and one dotted with one two three dotted with one two three and we just keep doing that and I'll just switch maybe to one neutral color now so then a times zero zero one that's going to be the first row of a expressed as a column vector so we can write it like this 1 minus 1 2 dot 0 0 1 and then actually and then we have our and then the second row of a dotted with this column vector so we have 0 minus 2 1 dotted with 0 0 1 2 more rows left this can get a little tedious and I'm in it's inevitable that I'll probably make a careless mistake but as long as you understand the process that's the important date then the next one this row of a expresses a column vector 1 minus 1/2 we're going to dot it with this vector right there 1 1 0 and then this row of a I could just look over here as well 0 minus 2 1 dotted with 1 1 0 and then finally the last two entries are going to be the top row of a 1-1 two dotted with this column vector 1 minus 1 2 put a little dot there remember we're taking the dot product and then finally this second row of a so 0-2 one dotted with this column vector 1 minus 1 2 and that is going to be our mate product matrix and this looks very complicated right now but now we just have to compute it in dot products tend to simplify things a good bit so what is our matrix our product going to simplify to I'll do it in pink a B is equal to we draw the matrix right there so what's the dot product of these two things it's 1 times when I'll just write it out it's 1 times 1 1 I'll just write 1 times 1 is 1 plus minus 1 times ma 2 so minus 2 plus 2 times 3 plus 6 now we'll do this term right here 0 times 1 is 0 plus minus 2 times 2 so it's minus 4 plus 1 times 3 plus 3 now we're on to this term 1 times 0 is 0 plus minus 1 times 0 plus 0 plus 2 times 1 is equal to plus 2 this term 0 times 0 is 0 plus minus 2 times 0 let me write it is 0 plus minus 2 times 0 is 0 plus 1 times 1 so plus 1 then here you have 1 times 1 is 1 plus minus 1 times 1 is minus 1 plus 2 times 0 so plus 0 here 0 times 1 is 0 2 minus 2 times 1 is minus 2 and then 1 times 0 is plus 0 almost done 1 times 1 is 1 minus 1 times minus 1 is 1 2 times 2 is 4 finally 0 times 1 is 0 minus 2 times minus 1 is 2 1 times 2 is also 2 and we're in the homestretch now we just have to add up these values so our dot product of the two matrices is equal to the 2 by 4 matrix 2 by 4 matrix 1 minus 2 plus 6 that's equal to 5 minus 4 plus 3 is minus 1 this is just 2 this is just 1 then we have 1 minus 1 plus 0 is just 0 minus 2 right we just have a minus 2 there 1 plus 1 plus 4 is 6 and then 2 plus 2 is 4 and we are done the product of a B is equal to this matrix right here and let me get my a and B back we can talk a little bit more about what this product actually represented so let me copy and paste this then I'll paste it let me scroll down a little bit go down here paste there you go so this was our a and our B and when we took the product we got this matrix here now there's a couple of interesting things to notice remember I only said that I said this this product is only well-defined when the number of columns in a is equal to the number of rows in B so that was the case in this situation and then notice we got a 2 by 4 matrix which is the number of rows in a times the number of rows times the number of columns in B so we got a 2 by 4 matrix so another natural question is could we have found or is it even equal if we were to take the product B a if we were to even take the product B a so if you know if we tried to apply our definition there what would it be equal to it would be equal to the matrix B times the column 1 0 then the matrix B times the column minus 1 minus 2 and then it would be the matrix B times the column 2 1 now can we take this matrix vector product we have a 3 by 4 this right here is a 3 by 4 matrix and this guy right here is a member of our two so this is not well-defined we have more columns here than entries here so we have never defined a matrix vector product like this so this not only is this not equal to this it's not even defined so it's not not defined when you take a when you take a 3 by 4 matrix and you take the product of that with a 2 by 4 matrix it's not defined because that number and that number is not equal and so obviously since this is defined and this isn't defined you know that a B is not always equal to VA in fact it's not usually equal to PA and sometimes it's not even defined and the last point I want to make is you've probably learned you probably learn to do matrix matrix products in algebra 2 but you didn't have any motivation for what you were doing but now we do have a motivation because when you're taking the product of a and B we learned in the last video that if we have two transformations we have two transformations let's say we have the transformation let's say we have the transformation s is a transformation from r3 from r3 to r2 r2 and that s is represented by the matrix OS given some matrix in r3 it's if you apply the transformation s to it it's equivalent to multiplying that already given any vector in r3 applying the transformation s is equivalent to multiplying that vector times a we can say that and I used I used r3 and r2 because the number of columns in a is 3 so it can apply to a three dimensional vector and similarly we can imagine B as being the matrix transformation of some transformation T that is a mapping it is a mapping from R 4 R 4 to R 3 to R 3 where if you give it some vector X in R 4 it will produce you take the product of that with B and you're going to get some vector in r3 now we can if we think of the composition of the two so let's think about it a little bit if we have our 4 here let me switch colors we have our 4 here we have our R 3 here and then we have our are to here t is a transformation from our four to our three so T would look like that T is a transformation it's B times X that's what T is equal to so T is this transformation and then s is a transformation from r3 to r2 so s looks like that and s is equivalent to a times any vector in r3 so that is s so now we can we have a motive we know what how to visualize or how to think about what the product of a and B are the product of a and B is essentially you apply the transformation B first so let me think of it like the composition of s let me write it this way so what is the composition of s with T this is equal to of X this is equal to s of T of X so you take a transformation from our four to our three and then you take the S transformation from r3 to r2 so this is s of T s of T is a transformation from our 4 all the way to r2 and then the neat thing about this if you were to just write this out and it's matrix representations we do this in the last video this would be equal to the S matrix a times this vector right here which is which is B X but now we know that the matrix by our definition of matrix vector products that this guy this guy is right here is going to have a transformation it's going to be equal to so the composition s of T of X is going to be equal to the matrix a B based on our definition so the transformation a B times some vector X so the reason why I'm going all this is because we just did a matrix matrix product up here we took the pain of multiplying the matrix a times a matrix B and we got this value here and hopefully I didn't make any careless mistakes but the big idea here the idea that you we weren't exposed to in your algebra 2 class is that this is the matrix of the of the composition of the transformations s and T or so right here it's the matrix of the composition of s and T so you're not just blindly doing some you know matrix matrix products can be pretty tedious now you know what they're for they're actually for the composition of two transformations where each of a and B are the transformation matrices for each of the individual linear transformations anyway hopefully you found that useful