Matrix multiplication is a very common operation. Just like addition works only for matrices of the same size, there are conditions for when two matrices can be multiplied but in this case it is a little bit more complicated. Given two matrices and where is a x matrix, they can only be multiplied if is a x matrix with a result that is a x matrix. This means the number of columns of (the first matrix) must match the number of rows of (the second matrix) and the resulting matrix will have as many rows as and as many columns as . Note that the order of the matrices matters! The following illustrates this:
To calculate one entry in the result matrix , we look at row of and column of . The following diagram illustrates how each entry in is obtained from a row of and column of :
Let us see how is calculated. For that we look at row 1 of which is and column 1 of which is . We then calculate similar to how we calculate the dot product of two vectors:
We are given the following two matrices:
We can confirm that the number of rows of matches the number of columns of so we can multiply them. The resulting matrix be a 2×2 matrix (because has 2 rows and has 2 columns).
For we look at the first row of and first column of and multiply them:
For we look at the first row of and second column of and multiply them:
We repeat the same for and :
Now we calculated all entries of our result:
Matrix multiplication is not commutative. This means that the order of the multiplication is important. In general, this means for different matrices and . However, the identity matrix (explained later) is an exception so if one of the two matrices is the identity matrix and the other matrix is a square matrix, it can be pre-multiplied or post-multiplied to give the same result.
Matrix multiplication is associative. This means .
With regards to the transpose, the following operation is allowed for matrix multiplication: .
A square matrix that is multiplied with an identity matrix of the same order, gives the same matrix . The order of the multiplication does not matter in this case:
The identity matrix with regards to matrix multiplication is similar to the number 1 for normal multiplication. Just like any number multiplied by 1 gives the same number, the same is true for any matrix multiplied with the identity matrix.
Some matrices can be inverted. This means that given a matrix , there may be an inverse of it , such that:
The inverse for matrix multiplication is similar to normal multiplication. Take a number , then its inverse is , so . For matrix multiplication, the inverse is a bit more difficult to find and not every matrix has an inverse. Read more on inverse matrices.