You multiplied matrices in precalculus with a row-times-column rule. Here we see where that rule comes from, which explains its strange features: sizes must match, and order matters.
Sums and scalar multiples work entry by entry (for matrices of the same size). The product is defined so that multiplying by $AB$ does the same as multiplying by $B$ and then by $A$: $$(AB)\mathbf{x} = A(B\mathbf{x}) \text{ for every } \mathbf{x}.$$ That forces the definition $AB$ $= [\,A\mathbf{b}_1\ A\mathbf{b}_2\ \cdots\ A\mathbf{b}_p\,]$: column $j$ of $AB$ is $A$ times column $j$ of $B$.
Why it works
Worked example: A product, column by column
- $A$ is $2 \times 3$ and $B$ is $3 \times 2$: inside sizes match (3), so $AB$ is $2 \times 2$.
- Column 1: $A\begin{bmatrix} 2 \\ 0 \\ 3 \end{bmatrix}$ $= 2\begin{bmatrix} 1 \\ -1 \end{bmatrix} + 0\begin{bmatrix} 2 \\ 3 \end{bmatrix} + 3\begin{bmatrix} 0 \\ 4 \end{bmatrix}$ $= \begin{bmatrix} 2 \\ 10 \end{bmatrix}$.
- Column 2: $A\begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix}$ $= \begin{bmatrix} 1 \\ -1 \end{bmatrix} - \begin{bmatrix} 2 \\ 3 \end{bmatrix} + 2\begin{bmatrix} 0 \\ 4 \end{bmatrix}$ $= \begin{bmatrix} -1 \\ 4 \end{bmatrix}$.
- Row-column check of one entry: $(AB)_{21}$ $= (-1)(2) + (3)(0) + (4)(3)$ $= 10$. ✓
Answer: $AB = \begin{bmatrix} 2 & -1 \\ 10 & 4 \end{bmatrix}$
Worked example: Order matters
- $CD = \begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}$.
- $DC = \begin{bmatrix} 1 & 1 \\ 1 & 2 \end{bmatrix}$.
- They differ. Even when both products exist and have the same size, $AB$ and $BA$ are usually different.
Answer: $CD \neq DC$
Rules that hold, and two that do not
| Holds | Does not hold in general |
|---|---|
| $A(BC) = (AB)C$ (associative) | $AB = BA$ |
| $A(B + C) = AB + AC$, $(B + C)A = BA + CA$ | If $AB = AC$, then $B = C$ (no cancelling) |
| $(A^{T})^{T} = A$, $(A + B)^{T} = A^{T} + B^{T}$ | If $AB = 0$, then $A = 0$ or $B = 0$ |
| $(AB)^{T} = B^{T}A^{T}$ | $(AB)^{T} = A^{T}B^{T}$ |
The transpose $A^{T}$ turns the rows of $A$ into columns. The product rule reverses the order: $(AB)^{T} = B^{T}A^{T}$. Sizes explain it: if $A$ is $2 \times 3$ and $B$ is $3 \times 2$, then $A^{T}B^{T}$ is $(3 \times 2)(3 \times 2)$, which is not even defined, while $B^{T}A^{T}$ is $(2 \times 3)(3 \times 2)$, which is. Entry $(i, j)$ of $(AB)^{T}$ is entry $(j, i)$ of $AB$: row $j$ of $A$ times column $i$ of $B$, which is row $i$ of $B^{T}$ times column $j$ of $A^{T}$.
Common mistake
Key idea