When you add or subtract matrices, the two matrices that you add or subtract must have the same number of rows and the same number of columns. In other words, both must have the same shape.
For matrix multiplication, all that is required is that the number
of columns of the first matrix be the same as the number of
rows of the second matrix. In other words, you can multiply an
matrix by a
matrix, with the
matrix on the left and the
matrix on the right. The
example on the left below represents a legal multiplication since
there are three columns in the left multiplicand and three rows
in the right one; the
example on the right doesn't make sense--the left matrix has
three columns, but the right one has only 2 rows. If the matrices
on the right were written in the reverse order with the
martix on the left, it would represent a valid matrix multiplication.
So now we know what shapes of matrices it is legal to multiply, but how do we do the actual multiplication? Here is the method:
If we are multiplying an
matrix by a
matrix,
the result will be an
matrix. The element in the
product in row
and column
is gotten by multiplying termwise
all the elements in row
of the matrix on the left by all the
elements in column
of the matrix on the right and adding them
together.
Here is an example:
To find what goes in the first row and first column of the product,
take the number from the first row of the matrix on the left:
, and multiply them, in order, by the numbers in the
first column of the matrix on the right:
. Add the results:
. To get the
228 in the third row and second column of the product, the use the
numbers in the third row of the left matrix:
and the
numbers in the second column of the right matrix:
to
get
.
Check your understanding by verifying that the other elements in the product matrix are correct.
In general, if we multiply a general
matrix by a general
matrix to get an
matrix as follows:
Then we can write
(the number in row
, column
) as: