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

# Matrix product associativity

## Video transcript

we know that if we have some linear transformations it's a transformation from X to Y and these are just sets the sets of vectors and T is a linear transformation from Y to Z that we could construct a composition of s with T that is a linear transformation from X all the way to Z we saw this several videos ago and the definition of our linear transformation or the composition of our linear transformation so asked the composition of s with T applied to some vector X in our set X our domain is equal to is equal to s of T of X this was our definition and then we went on and we said look if s of X if s of X can be represented as the matrix multiplication a X the matrix vector product and if P of X can be represented or the transformation T can be represented as the product of the matrix B with X we saw that this thing right here which is of course if we just write it this way this is equal to a times T times X which is just B X we saw in multiple videos now that this is equivalent to by our definition of matrix products this is equal to the matrix a B right when you take the product of two matrices you just get another matrix the product a B times X so you take essentially the first linear transformation in your composition its matrix which was a and then you take the product with the second one fair enough all of this is review so far so let's take three linear transformations let's say that I have the linear transformation H and when I apply that to a vector X it's equivalent to multiplying my vector X by the matrix a let's say I have the linear transformation G when I apply that to a vector X it's equivalent to multiplying that vector X that that vector there should be a new concept called a vetrix it's equivalent to multiplying that vector times the matrix B and then I have a final linear transformation F applied when it's applied to some vector X it's equivalent to multiplying that vector X times the matrix the matrix C now what I'm curious about is what happens when I take the composition of H with G I take the composition of H with G and then I take the composition of that with F and then I take the composition of that with F these are all linear transformations and then I apply that to some vector X and then I apply that to some vector X which is necessarily going to be in the domain of this guy I haven't actually drawn out their domain and codomain definitions but I think you get the idea so let's explore what this is a little bit well by the definition of what a let's go back by this definition right here of what composition even means we can just apply that to this right here so look we could just imagine this as being our s if we imagine this was our s and then this is our T right there then what is this going to be equal to if we just do a straight-up pattern match right there this is going to be equal to s the transformation s apply to the transformation F applied to X so s is H of G so it is H or I shouldn't say H of G the composition of H with G the composition of H with G that is our s and then I apply that I apply that to F applied to X F is RT I apply that to F applied to X just like that now what is this equal to what is this equal to now we can imagine that this is our this is our X if we just pattern match according to this definition that this is this guy right here that this is our t and that this is our s and that this is our s and so if we just pattern match here this is equal to what this is just three from the definition of a composition so it's equal to s of s SR H so H of T which in this case is G G applied to X but instead of an X we have a whole this this vector here which was the transformation F applied to X so G of f of X that's what this equal to the composition of H with G and the compass or the composition of F with H the composition of H and G all of that applied to X is equal to H of G of f of X now what is this equal to what is this equal to well this is equal to I'll do it right here this is equal to this is equal to H the transformation H apply to what is this term right here I'll do it in pink what is this that is the composition of G and F applied to X you can just replace s with G and F with T and you'll get that right there so this is just equal to a composition of G with F applied to X that's all that is now what is this equal to right there and it's probably confusing to see two parentheses in different colors but then you get the idea what is this equal to well just go back to your definition of the composition I just want to make it very clear what we're doing this is if you imagine this being your tea and then this being your s this is just the composition of s with T applied to X so this is just equal to alright like this way this is equal to I just shouldn't write s is this is the composition of H with the composition of G and F and then all of that applied to X now why did I do all of this well one to show you that the composition is associative I went all the way here and then I went all the way back and essentially it doesn't matter where you put the parenthesis the composition of the composition of H with G with F is equivalent to the composition of H with the composition of G and F that these two things are equivalent and essentially you can just these two things you can just rewrite them the parenthesis are essentially unnecessary you can write this as the composition of H with G with F all of that applied to X now I took the time to say that I can represent H is a matrix moment that each of these linear transformations I can represent as matrix multiplications why did I do that what we saw before that any composition when you take the composition of s with T the matrix version of this transformation of this composition is going to be equal to the product by our definition of matrix matrix products the product of the trend that the esses transformation matrix and T's transformation matrix so what are these going to be equal to so this one right here if you think of this transformation right here this statement right here it's its matrix version of it so let me write that the matrix version of the composition of H with G a plot and then the composition of that with F applied to X applied to X is going to be equal to is going to be equal to and we've seen this before first the first trick the the product of these matrices so this composition its matrix is going to be a B H and G they're matrices are a and B so it's going to be a B a B and I'll do it in parentheses and then you take that matrix and you take the product because so this guy's matrix represents a B right and this guy's matrix representation to C so the matrix representation of this whole thing is this guy taking the product of a B and then taking the product of that with C so a B and then C and then if you look at this guy right here and of course all of that times a vector X all of that time some vector X right there that's the vector X now let's look at this one right here if we take the compass the composition of H with the composition of G and F and apply all of that to some vector X what is that equivalent to well this composition right here the matrix version of it I guess we can say is going to be the product BC and we're going to apply that to X so we're going to have the product BC and then we're going to take the product of that with this guy's matrix representation which is a and we've shown this before we never showed it with three but it extends just I mean you know I kind of showed it extend so you can just keep applying the definition you can keep applying this property right here and so it'll just naturally extend because every time we're just taking the composition of two things even though it looks like we're taking the composition of three we're taking the composition of two things first here and then we get its matrix representation and then we take the composition of that with this other thing so the matrix representation of the entire composition is going to be this matrix times this matrix which I did here similarly here we take first the matrix the the composition of these two linear transformations and their matrix representation will be that right there and then we take the linear we take the composition of that with that so it's the entire matrix representation is going to be this guy's matrix times this guy's matrix so a times B C and of course all of that apply to the vector X now in this video I've showed you that these two things are equivalent if anything the two the parentheses are completely unnecessary and I showed you that they're they both essentially come boil down to H of G of f of X so these two things are equivalent so we could say essentially that these two things over here are equivalent or that a be the product a B and then taking the product of that matrix with the matrix C is equivalent to taking the product a with the matrix BC which is just a product another product matrix we're another way of saying is that these parentheses don't matter that all of these is just equal to a BC or this I mean this is just a statement that matrix products exhibit the associative property let associative property it doesn't matter where you put the parentheses and you know sometimes it's confusing the word associative it just means you doesn't matter where you put the parentheses matrix products do not exhibit the commutative property we saw that in the last video we cannot in general we cannot make the statement that a B is equal to B a we cannot do that and in fact in the last video I think it was the last video I showed you that this if a B is defined sometimes B a is not even defined or B a is defined sometimes a B isn't defined so it's not commutative it is associated though in the next video I'll see if matrix products are actually distributive