Main content

## Properties of matrix multiplication

Current time:0:00Total duration:7:32

# Is matrix multiplication commutative?

## Video transcript

Voiceover:We know that the multiplication of scalar quantities is commutative. For example, 5 times 7 is
the same thing as 7 times 5, and that's obviously just
a particular example. I could give many, many more. 3 times negative 11 is the same
thing as negative 11 times 3 and the whole point of commutativity ... I could never say it ... is that it doesn't matter what order that I'm multiplying in. This is the same thing
as negative 11 times 3. 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 a. Now what I want to do in
this video is think about whether this property of commutativity, whether the commutative property of multiplication of scalars, whether there is 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, 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. 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? I encourage you to pause this video and think about that for a little bit. Let's just think through a few things. First of all, let's just
think about matrices of different dimensions. Let's say I have a matrix here. Let's say that matrix
A is a, I don't know, let's say it is a 5 by 2 matrix, 5 by 2 matrix, and matrix B is a 2 by 3 matrix. The product AB is going
to have what dimensions? If I multiply these two, you're
going to get a third matrix. Let's just call that C for now. You're going to get a third matrix C. What are going to be the dimensions of C? We know, first of all, that
this product 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 5 by 3 matrix, a 5 by 3 matrix. Now what about the other way around? What would B times A be? Once again, I encourage
you to pause the video. If you were to take B, 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. 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? The first question is, is matrix
multiplication even defined for these two matrices? 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 B and a different number of rows for A. 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, AB, the product AB is defined, and you'll end up with a 5 by 3 matrix. The product here, BA, isn't even defined. This is already ... We're already seeing that
this is not the case, that order matters when
you are multiplying, when you are multiplying matrices. To make things a little bit more concrete, let's actually look at a matrix. You might be saying, oh,
maybe this doesn't work only when it's not defined, but hey, maybe it works
if we're always to do square matrices or matrices
where both products are always defined in some way, or maybe some other case. Let's look at a case where we're dealing with 2 by 2 matrices and
see whether order matters. 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? Once again, I encourage
you to pause the video and think about that. Let's think it through, and
we've done this many times now. This first entry here is going to be, we're essentially going to look
at this row and this column, so it's 1 times negative
2, which is negative 2, plus 2 times 0. This is going to be negative 2. Now, for this entry, for this entry over here, we'll look at this row and this column, 1 times 0, which is 0,
plus 2 times negative 3, which is negative 6. Then for this entry, we
would look at this row and this column. Negative 3 times negative 2 is positive 6 plus negative 4 times 0,
which is just positive 6. We're going to have positive 6. Then finally, for this entry, it's going to be the second
row times the second column. Negative 3 times 0 is 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
negative 2, 0, 0, negative 3 times 1, 2, negative 3, negative 4? What's this going to be equal to? As always, it's a good
idea to try to pause it and work through it on your own. Let's think about this. Negative 2 times 1 is negative
2, plus 0 times negative 3, so that's going to be negative 2. So far, it's looking pretty good. Then if you have negative
2 times 2 is negative 4, plus 0 times negative 4 is negative 4. 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. This entry right over here is going to be the second row, first column, 0 times 1 plus negative 3
times negative 3 is positive 9. Once again, it doesn't match up. Then finally, 0 times 2 is 0 plus negative 3 times
negative 4 is positive 12. That one actually did match up, but clearly, these two products
are not the same thing. The order with which even those defined, it 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. Once again, another case showing that multiplication of
matrices is not commutative.