Professor Dave again, let’s multiply matrices.
We just learned how to add and subtract matrices, so let’s move on to the next logical operation.
It is also possible to mutiply two matrices together.
This is not as simple as matrix addition, as we will not simply be multiplying corresponding
entries to get new entries.
Instead we have to learn a totally different algorithm, so let’s check that out now.
The first thing we must learn is that in order for two matrices to be multiplied, they must
have a specific relationship in terms of their dimensions, and it is not the case that they
must have identical dimensions.
Rather, if two matrices, A and B, are being multiplied, with A listed first, followed
by B, it will be the case that A must have the same number of columns as B has rows.
The reason for this will be clear in a moment.
Let’s start with a pair of simple two by two matrices.
One, two, three, four, and then five, six, seven, eight.
The way we will get the product is by taking the first row and the first matrix and the
first column of the second matrix, and doing some multiplication.
One times five is five, and two times seven is fourteen.
Five plus fourteen is nineteen, so that goes in the first entry of the product matrix.
Now we stay in the first row of this matrix, but shift over to the second column of the other.
One times six is six, and two times eight is sixteen.
Six plus sixteen is twenty two, and that will go in the second entry for the first row of
the product matrix.
Now we shift to the second row of the first matrix, and go back the first column of the
second matrix.
Three times five is fifteen, four times seven is twenty eight.
Fifteen plus twenty eight is forty three, so that will go in the first entry for the
second row of the product matrix.
And lastly, we shift to the second column again.
Three times six is eighteen, four times eight is thirty two.
Eighteen plus thirty two is fifty, and that will go in the last entry here.
This is the algorithm we will follow for matrix multiplication.
We are using rows from the first matrix and columns from the second matrix, and we are
finding the sum of the products of the corresponding entries.
This explains why the first matrix has to have the same number of columns as the second
matrix has rows.
Take something like this two by three matrix times this other three by two matrix.
These can be multiplied in this order, and once we begin, we can see that the three entries
in the first row of this one correspond to the three entries in the first column of this one.
We add up the numbers, and there is our first entry in the product matrix.
Then we use the second column, and then we repeat this process for the second row of
the first matrix.
This gives us a product matrix that is two by two.
So the product matrix will always have a number of rows that is equal to the number of rows
in the first matrix, and a number of columns that is equal to the number of columns in
the second matrix.
This also tells us an important fact that may not have been immediately intuitive.
Although the multiplication of numbers is commutative, meaning that A times B is the
same as B times A, this will not be the case for matrix multiplication.
Take the two by three and three by two matrices we just multiplied together.
If we switch their order, we will get a completely different result, a product matrix that is
three by three rather than two by two.
As you can see, the three rows from the first one and the three columns from the second
one will determine these dimensions.
So matrix A times matrix B is not equivalent to matrix B times matrix A. However, matrix
multiplication is associative, meaning that if we are multiplying three matrices in a
specific order, it doesn’t matter which pair we multiply first.
In addition, the distributive property can apply in some cases.
If A and B are M by N matrices, and C and D are N by P matrices, meaning that A and
B can each be multiplied by C or D, then A times the quantity C plus D will equal AC
plus AD, and the quantity A plus B times C will equals AC plus BC.
Now that we know the algorithm associated with matrix multiplication, as well as some
associated properties, let’s check comprehension.