Matrix multiplication is somewhat more complicated than matrix addition because it does not work component-wise, and because the size and the order of the matrices in a matrix multiplication matter.
We define the product of two matrices and only if every row of is as long as each column . So if is a -matrix, then needs to be a -matrix for certain . If this is the case, then the matrix product is a -matrix. The element on the -th row and the -th column in the matrix product is defined as follows:
We can also write the right hand side of the definition of as the dot product of the -th row vector of and -th column vector of (interpreted as column vectors) or the matrix product of the -th row vector of and -th column vector of (interpreted as matrices):
The product of the matrices and can be visualized as follows:
then
is the
-matrix of which the element
is the dot product of the magenta colored row and column of the matrices
and
:
The definition of the product of matrices finds its inspiration in the writing of linear equations and systems of linear equations. A linear equation
can be written as the dot product of vectors
and
, or as
This then appears in matrix notation as
It suggests the concept of 'row vector times column vector'.
Similarly we can write a system of linear equations in matrix notation by stitching together linear equations in matrix notation. The system of linear equations with unknowns
can be written in matrix notation as
Solving the system of linear equations amounts to finding a column matrix which, when multiplied from the left by the coefficient matrix yields the column matrix . This solving of a system for the given coefficient matrix can be carried out for several column vectors at the same time and can be concisely recorded by replacing and by multiple columns, so in fact by matrices and . This forces a unique choice for : the matrix multiplication in the way it is defined.
If
and
, then
This shows that matrix multiplication is not commutative if the sizes are greater than
.
Use as many examples as you need to become familiar with the product of matrices.
By way of example, we calculate the matrix coefficient at entry
, that is to say, in the first row and second column. To this end we calculate the dot product of the pair of magenta colored row and column vector, the first row in the first factor and the second column in the second factor of the matrix product:
In the same way, the other matrix coefficients can be calculated.
Most calculation rules we already know from the multiplication of numbers, also apply to matrix multiplication, at least if the dimensions of the matrices are such that matrix multiplication is possible. We mention:
The first two lines and the last line follow directly from the definitions.
The proof of the third line with the definition of the product of matrices is much tedious paperwork. Later, when matrices are associated with linear maps, we will be able to give a short proof.
Thanks to the second rule we can write without parentheses; it does not matter if we calculate this expression as or as . Similarly, the third line enables us to write ; the order in which products are calculated matrix does not matter.