1.3. Matrix multiplication#

We can multiply any two real numbers together but multiplication of two or more matrices is a much more complicated idea. Similarly to addition, which is only defined for matrices of the same size, matrix multiplication has constrains on the sizes of the multipliers:

Definition 1.6 (Matrix multiplication)

Let \(A\) be an \(m \times n\) matrix and \(B\) a \(p \times q\) matrix. The product \(AB\) is only defined if \(n = p\) and the resulting matrix has dimension \(m \times q\) (i.e., the number of columns in \(A\) has to equal the number of rows in \(B\)). The product of an \(m \times p\) matrix \(A\) and a \(p \times n\) matrix \(B\) is defined as

\[ [AB]_{ij} = \sum_{k=1}^n a_{ik}b_{kj}. \]

i.e., if \(A\) and \(B\) are two \(2\times 2\) matrices

\[\begin{split} \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{pmatrix} = \begin{pmatrix} a_{11} b_{11} + a_{12}b_{21} & a_{11}b_{12} + a_{12} b_{22} \\ a_{21} b_{11} + a_{22}b_{21} & a_{21}b_{12} + a_{22} b_{22} \end{pmatrix}. \end{split}\]

The technique used to multiply two matrices together requires us to move across the horizontal rows of the first matrix (the \(i\) index) and down the vertical columns of the second matrix (the \(j\) index). We multiply corresponding elements together and sum the result. For example, consider the multiplication of the two \(2\times 2\) matrices \(A\) and \(B\) given below

\[\begin{split} \begin{align*} A &= \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, & B &= \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}. \end{align*} \end{split}\]

The first thing we need to do is check whether matrix multiplication is defined for these matrices. An easy way to do this is to write the dimensions of the matrix underneath, e.g.,

\[\begin{split} \begin{align*} AB = \underset{2 \times \vec{\textcolor{red}{2}}}{\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}} \underset{\textcolor{red}{2} \times 2}{\begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}}. \end{align*} \end{split}\]

Here the two inside numbers are the same so this matrix multiplication is defined. Futhermore the dimensions of the product of these two matrices is given by the two outside numbers. To calculate the value of the element in row 1 and column 1 of \(AB\), i.e., \([AB]_{11}\), we use the elements from row 1 of \(A\) and column 1 of \(B\) multiplying corresponding elements and summing the result

\[\begin{split} \begin{align*} \begin{pmatrix} \textcolor{blue}{1} & \textcolor{blue}{2} \\ \textcolor{lightgray}{3} & \textcolor{lightgray}{4} \end{pmatrix} \begin{pmatrix} \textcolor{red}{5} & \textcolor{lightgray}{6} \\ \textcolor{red}{7} & \textcolor{lightgray}{8} \end{pmatrix} = \begin{pmatrix} \textcolor{blue}{1} \cdot \textcolor{red}{5} + \textcolor{blue}{2} \cdot \textcolor{red}{7} & \textcolor{lightgray}{\square} \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 5 + 14 & \textcolor{lightgray}{\square} \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 19 & \textcolor{lightgray}{\square} \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix}. \end{align*} \end{split}\]

The value of \([AB]_{12}\) is calculated using elements from row 1 of \(A\) and column 2 of \(B\).

\[\begin{split} \begin{align*} \begin{pmatrix} \textcolor{blue}{1} & \textcolor{blue}{2} \\ \textcolor{lightgray}{3} & \textcolor{lightgray}{4} \end{pmatrix} \begin{pmatrix} \textcolor{lightgray}{5} & \textcolor{red}{6} \\ \textcolor{lightgray}{7} & \textcolor{red}{8} \end{pmatrix} = \begin{pmatrix} 19 & \textcolor{blue}{1} \cdot \textcolor{red}{6} + \textcolor{blue}{2} \cdot \textcolor{red}{8} \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 19 & 6 + 16 \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ \textcolor{lightgray}{\square} & \textcolor{lightgray}{\square} \end{pmatrix}. \end{align*} \end{split}\]

Now that we have finished the first row of \(AB\) we now move to the second row. The value of \([AB]_{21}\) is calculated using elements from row 2 of \(A\) and column 1 of \(B\).

\[\begin{split} \begin{align*} \begin{pmatrix} \textcolor{lightgray}{1} & \textcolor{lightgray}{2} \\ \textcolor{blue}{3} & \textcolor{blue}{4} \end{pmatrix} \begin{pmatrix} \textcolor{red}{5} & \textcolor{lightgray}{6} \\ \textcolor{red}{7} & \textcolor{lightgray}{8} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ \textcolor{blue}{3} \cdot \textcolor{red}{5} + \textcolor{blue}{4} \cdot \textcolor{red}{7} & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 15 + 28 & \textcolor{lightgray}{\square} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & \textcolor{lightgray}{\square} \end{pmatrix}. \end{align*} \end{split}\]

Finally the value of \([AB]_{22}\) is calculated using elements from row 2 of \(A\) and column 2 of \(B\).

\[\begin{split} \begin{align*} \begin{pmatrix} \textcolor{lightgray}{1} & \textcolor{lightgray}{2} \\ \textcolor{blue}{3} & \textcolor{blue}{4} \end{pmatrix} \begin{pmatrix} \textcolor{lightgray}{5} & \textcolor{red}{6} \\ \textcolor{lightgray}{7} & \textcolor{red}{8} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & \textcolor{blue}{3} \cdot \textcolor{red}{6} + \textcolor{blue}{4} \cdot \textcolor{red}{8} \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 18 + 32 \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}. \end{align*} \end{split}\]
Arthur Cayley

Fig. 1.1 Arthur Cayley (1821 - 1895)#

This method of multiplying matrices together may seem unnecessarily convoluted when first encountered. The reason we perform matrix multiplication in this way is because English mathematician Arthur Cayley found that it allows for a convenient way to represent composite linear transformations.

Example 1.6

Given the matrices

\[\begin{split} \begin{align*} A &= \begin{pmatrix} 1 & 0 \\ -2 & 3 \end{pmatrix}, & B &= \begin{pmatrix} 2 & 3 \\ 1 & 5 \end{pmatrix}, \\ C &= \begin{pmatrix} 1 & 1 & 0 \\ 3 & -2 & 1 \end{pmatrix}, & D &= \begin{pmatrix} 1 \\ 3 \end{pmatrix}. \end{align*} \end{split}\]

calculate the following (where possible):

(i)   \(AB\);

Solution (click to show)
\[\begin{split} \begin{align*} AB &= \begin{pmatrix} 1 & 0 \\ -2 & 3 \end{pmatrix} \begin{pmatrix} 2 & 3 \\ 1 & 5 \end{pmatrix} \\ &= \begin{pmatrix} 1 \cdot 2 + 0 \cdot 1 & 1 \cdot 3 + 0 \cdot 5 \\ -2 \cdot 2 + 3 \cdot 1 & -2 \cdot 3 + 3 \cdot 5 \end{pmatrix} \\ &= \begin{pmatrix} 2+0 & 3 + 0 \\ -4+3 & -6+15\end{pmatrix} \\ &= \begin{pmatrix} 2 & 3 \\ -1 & 9 \end{pmatrix} \end{align*} \end{split}\]

(ii)   \(BC\);

Solution (click to show)
\[\begin{split} \begin{align*} BC &= \begin{pmatrix} 2 & 3 \\ 1 & 5 \end{pmatrix} \begin{pmatrix} 1 & 1 & 0 \\ 3 & -2 & 1 \end{pmatrix} \\ &= \begin{pmatrix} 2 \cdot 1 + 3 \cdot 3 & 2 \cdot 1 + 3 \cdot (-2) & 2 \cdot 0 + 3 \cdot 1 \\ 1 \cdot 1 + 5 \cdot 3 & 1 \cdot 1 + 5 \cdot (-2) & 1 \cdot 0 + 5 \cdot 1 \end{pmatrix} \\ &= \begin{pmatrix} 2+9 & 2-6 & 0+3 \\ 1+15 & 1-10 & 0+5 \end{pmatrix} \\ &= \begin{pmatrix}11 & -4 & 3 \\ 16 & -9 & 5 \end{pmatrix} \end{align*} \end{split}\]

(iii)   \(CD\).

Solution (click to show)

\(CD\) is undefined since \(C\) has 3 columns and \(D\) only has 2 rows.

1.3.1. Matrix exponents#

Just like with scalar quantities we can calculate the exponent of a number \(a^n\) by multiplying by itself \(n\) times, i.e., \(a^3 = a \cdot a \cdot a\), we can also do this for square matrices that have the same number of rows and columns.

Definition 1.7 (Matrix exponents)

Let \(A\) be a square \(n \times n\) matrix. Then we write \(A^2=AA\) and more generally:

\[ \begin{align*} A^n = \underbrace{A A \cdots A}_{n \text{ times}}. \end{align*} \]

Example 1.7

Given the matrix

\[\begin{split} A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \end{split}\]

evaluate:

(i)   \(A^2\);

Solution (click to show)
\[\begin{split} \begin{align*} A^2 &= AA = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \\ &= \begin{pmatrix} 1 + 6 & 2 + 8 \\ 3 + 12 & 6 + 16 \end{pmatrix} \\ &= \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix} \end{align*} \end{split}\]

(ii)   \(A^3\);

Solution (click to show)
\[\begin{split} \begin{align*} A^3 &= AA^2 = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix} \\ &= \begin{pmatrix} 7 + 30 & 10 + 44 \\ 21 + 60 & 30 + 88 \end{pmatrix} \\ &= \begin{pmatrix} 37 & 54 \\ 81 & 118 \end{pmatrix} \end{align*} \end{split}\]

(iii)   \(A^5\).

Solution (click to show)
\[\begin{split} \begin{align*} A^5 &= A^2A^3 = \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix} \begin{pmatrix} 37 & 54 \\ 81 & 118 \end{pmatrix} \\ &= \begin{pmatrix} 259 + 810 & 378 + 1180 \\ 555 + 1782 & 810 + 2596 \end{pmatrix} \\ &= \begin{pmatrix} 1069 & 1558 \\ 2337 & 3406 \end{pmatrix} \end{align*} \end{split}\]