Up Main page

Matrix multiplication and linear transformations

Let \(A\) be a \(p\times n\) matrix and \(B\) be a \(m\times p\) matrix. Define the product \(BA\) to be the matrix given by \(\begin{bmatrix} BA_1 & BA_2 & \cdots & BA_n\end{bmatrix}\) where \(A_i\) denotes the \(i\)th column of \(A\).

If \(S\) and \(T\) are linear transformations given by \(S(x) = Ax\) and \(T(x)= Bx\), then \(T(S(x)) = (BA)x\).

Matrix multiplication is defined in such a convoluted manner precisely to represent composition of linear transformations.

Examples

  1. Let \(A = \begin{bmatrix} 1 & 2\\3 & 5\end{bmatrix}\) and \(B = \begin{bmatrix} 1 & 0\\ -1 & 1\end{bmatrix}\).

    Then \(BA_1 = \begin{bmatrix} 1 & 0\\ -1 & 1\end{bmatrix} \begin{bmatrix} 1 \\3 \end{bmatrix}= \begin{bmatrix} 1(1) + 0(3)\\ -1(1) + 1(3) \end{bmatrix}= \begin{bmatrix} 1\\ 2 \end{bmatrix}\), and \(BA_2 = \begin{bmatrix} 1 & 0\\ -1 & 1\end{bmatrix} \begin{bmatrix} 2 \\5 \end{bmatrix}= \begin{bmatrix} 1(2) + 0(5)\\ -1(2) + 1(5) \end{bmatrix}= \begin{bmatrix} 2\\ 3 \end{bmatrix}\). Hence, \(BA = \begin{bmatrix} 1&2\\ 2 &3 \end{bmatrix}\).

  2. Let \(A = \begin{bmatrix} 1 & 2 & 3\end{bmatrix}\) and \(B = \begin{bmatrix} 1 & 4\\ -1 & 1 \\ 2 & -2\end{bmatrix}\).

    Then \(AB_1 = \begin{bmatrix} 1 & 2 & 3\end{bmatrix} \begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix} = \begin{bmatrix} 1(1) + 2(-1) + 3(2) \end{bmatrix} = \begin{bmatrix} 5\end{bmatrix}\), and \(AB_2 = \begin{bmatrix} 1 & 2 & 3\end{bmatrix} \begin{bmatrix} 4 \\ 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 1(4) + 2(1) + 3(-2) \end{bmatrix}= \begin{bmatrix} 0\end{bmatrix}\). Hence, \(AB = \begin{bmatrix} 5 & 0 \end{bmatrix}\).

  3. Let \(A = \begin{bmatrix} 1 \\ -2 \end{bmatrix}\) and \(B = \begin{bmatrix} 3 & 5\end{bmatrix}\).

    Then \(AB_1 = \begin{bmatrix} 1 \\ -2 \end{bmatrix} \begin{bmatrix} 3 \end{bmatrix} = \begin{bmatrix} 3 \\ -6 \end{bmatrix}\), and \(AB_2 = \begin{bmatrix} 1 \\ -2 \end{bmatrix} \begin{bmatrix} 5 \end{bmatrix} = \begin{bmatrix} 5 \\ -10 \end{bmatrix}\). Hence, \(AB = \begin{bmatrix} 3 & 5 \\ -6 & -10 \end{bmatrix}\).

Beware!

Note that the matrix product \(AB\) is defined only when the number of columns of \(A\) matches the number of rows of \(B\).

Also, in general \(AB\) and \(BA\) are not necessarily equal. For instance, it is possible that the product \(AB\) is defined while \(BA\) is not (when the number of columns of \(B\) is not the same as the number of rows of \(A\).)

Examples

  1. Let \(A = \begin{bmatrix} 1 & 0 \\ 2 & 0 \end{bmatrix}\). Let \(B = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\). Then \(AB = \begin{bmatrix} 0 & 1 \\ 0 & 2 \end{bmatrix}\) but \(BA = \begin{bmatrix} 2 & 0 \\ 1 & 0\end{bmatrix}\).

  2. Let \(A = \begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix}\). Let \(B = \begin{bmatrix} 1 \\ 0 \end{bmatrix}\). Then \(AB = \begin{bmatrix} 1 \\ 2\end{bmatrix}\) but the product \(BA\) cannot be formed since the number of columns of \(B\) is different from the number of rows of \(A\).

Quick Quiz

Exercises

  1. Compute each of the following matrix products.

    1. \(\begin{bmatrix} 1 & 3 \\ 2 & 4\end{bmatrix} \begin{bmatrix} -1 & 0 & 1 \\ 1 & 2 & 3\end{bmatrix}\)

    2. \(\begin{bmatrix} 0 & 1 & 2 & -1 \\ 4 & 3 & 0 & 2\end{bmatrix} \begin{bmatrix} -1 \\ 0 \\ 1 \\ 3\end{bmatrix}\)

    3. \(\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} \begin{bmatrix} -1 & 1 \end{bmatrix}\)

  2. Let \(A = \begin{bmatrix} 1 & 2 \end{bmatrix}\), \(B = \begin{bmatrix} 1 & 4\\ -1 & 1 \end{bmatrix}\), \(C = \begin{bmatrix} 1 & 0 & 1 \\ -1 & 1 & 0 \end{bmatrix}\).

    1. Compute \(AB\) and \(BC\).

    2. Using the results of the previous part, compute \((AB)C\) and \(A(BC)\). What can you say about these products?