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:7:32

Is matrix multiplication commutative?

Video transcript

we know that the multiplication of scalar quantities is commutative for example five times seven is the same thing as seven times five and that's obviously just a particular example I could give many many more three times negative 11 is the same thing as negative eleven times three and the whole point of commutativity I can ever say it is that it doesn't matter what order that I'm multiplying in this is the same thing as negative eleven times three or if we wanted to speak in general terms if I have the scalar a and I multiply it times the scalar B that's going to be the same thing as multiplying the scalar B times the scalar times the scalar a now what I want to do in this video is think about whether this property of commutativity of the whether the commutative property of multiplication of scalars whether there's a similar property for the multiplication of matrices whether it's the case that if I had two matrices let's say matrix capital a and matrix capital B and matrix capital B whether it's always the case that that product the resulting matrix here is the same as the product of matrix B and matrix a just swapping the order and I encourage you so is this always true it might be sometimes true but in order for us to say that matrix multiplication is commutative that it doesn't matter what order we are multiplying it we have to figure out is this always going to be true and I encourage you to pause this video and think about that for a little bit well let's just think through a few things first of all let's just think about matrices of different dimensions so let's say I have a matrix here let's say that matrix a matrix a is a I don't know let's say it is a s a it is a five by two matrix five by two matrix and matrix B matrix B is a 2 by it's a two by three matrix so the product a B is going to the product a B is have what dimensions so if I multiply these two you're going to get a third matrix let's just call that let's just call that C for now you're going to get a third matrix C and what are there going to be the dimensions of C well we know that the first of all that this that this product is is defined under our convention of matrix multiplication because the number of columns that a has is the same as the number of rows B has and the resulting rows and column are going to be the rows of a and the columns of B so C is going to be a five by three matrix a five by three matrix now what about the other way around what would be times a B and once again I encourage you to pause the video so if you took if you were to take B so let me copy and paste that and multiply that times a so I'm really just switching the order of the multiplication so copy and paste so if we take that product right over there what is that going to be equal to what is this what is this right over here going to be equal to well the first question is is maestra is matrix multiplication even defined for these two matrices and when you look at the number of columns that B has and the number of rows that a has you see that it actually is not defined that we have a different number of columns for being a different number of rows for a so here the product is not defined is not defined so this immediately is a pretty big clue that this isn't always going to be true here a B the product a B is defined and you'll end up with a five by three matrix the product here B a isn't even defined so this is already you know we're already seeing that this is not not the case that order matters when you are multiplying when you are multiplying matrices and to make things a little bit more concrete let's let's actually look at a matrix you might be saying oh maybe this doesn't work only when it's not defined but maybe it works if if we always do with square matrices or matrices where both products are all always defined in some way or maybe if they or some other case and so let's look at a case where we're dealing with two two by two matrices and see whether order matters so let's say I have the matrix let's say I have the matrix 1 2 negative 3 negative 4 and I want to multiply that by the matrix by the matrix negative 2 0 0 negative 3 what's that product going to be 9 once again I encourage you to pause the video and think about that well let's think about let's think it through and we've done this many times now so this first entry here is going to be or since you're going to look at this row and this column so it's 1 times negative 2 which is negative 2 plus 2 times 0 so this is going to be negative 2 and now for this entry for this entry over here we look at this row and this column so 1 times 0 which is 0 plus 2 times negative 3 which is negative 6 and then 4 and then for this entry we would look at this row and this column so negative 3 times negative 2 is positive 6 plus negative 4 times 0 which is just positive 6 so you're going to have positive 6 and then finally for this entry it's going to be the second row times the second column negative 3 times 0 0 negative 4 times negative 3 is positive 12 so fair enough now what if we did it the other way around what if we were to multiply what if we were to multiply negative 2 0 0 negative 3 times times 1 2 negative 3 negative 4 what's this going to be equal to and as always it's a good idea to try to pause it and work through it on your own so let's think about this so negative 2 times 1 is negative 2 plus 0 times negative 3 so that's going to be negative 2 so so far it's looking pretty good then if you have negative 2 times 2 is negative 4 plus 0 times negative four is negative four so we already see that these two things aren't going to be equal but let's just finish it just so that we have a feeling of completion so this entry right over is going to be the second row first column 0 times 1 plus negative 3 times negative 3 is positive 9 once again doesn't match up and then finally 0 times 2 is 0 plus negative 3 times negative 4 is is positive 12 so that one actually did match up but clearly these two products are not the same thing the order and with which even though it's defined you doesn't matter whether you take the yellow one times the purple one or the purple one times the yellow one both of those result in a defined product but we see it's not the same product so once again another case showing that isn't that multiplication of matrices is not commutative