Further Maths/Lessons/Matrices/Matrix Multiplication
Core Pure · Matrices · Year 1

Matrix Multiplication

A row-times-column rule with a genuine surprise: order matters, and swapping two matrices being multiplied generally gives a completely different answer.

16 min read 5 worked examples

The multiplication rule

Definition 19.1 — matrix multiplication

For $AB$ to be defined, the number of columns of $A$ must equal the number of rows of $B$: an $m\times n$ matrix times an $n\times p$ matrix gives an $m\times p$ matrix. Each entry of $AB$ is the sum of products of a row of $A$ with a column of $B$: entry $(i,j)$ of $AB$ is (row $i$ of $A$) $\cdot$ (column $j$ of $B$).

Example 1 · Multiplying two 2×2 matrices
Given $A=\begin{pmatrix}1&2\\3&4\end{pmatrix}$ and $B=\begin{pmatrix}0&1\\-1&2\end{pmatrix}$, find $AB$.

Row 1 of $A$ with column 1 of $B$: $1(0)+2(-1)=-2$. Row 1 with column 2: $1(1)+2(2)=5$.

Row 2 with column 1: $3(0)+4(-1)=-4$. Row 2 with column 2: $3(1)+4(2)=11$.

$$AB=\begin{pmatrix}-2&5\\-4&11\end{pmatrix}$$
The key surprise — matrix multiplication is not commutative

In general, $AB\neq BA$ — even when both products are defined. Order matters, and it must always be stated explicitly which side a matrix is multiplying from.

Example 2 · Confirming AB ≠ BA
Using the same matrices as Example 1, find $BA$ and compare with $AB$.

Row 1 of $B$ with column 1 of $A$: $0(1)+1(3)=3$. Row 1 with column 2: $0(2)+1(4)=4$.

Row 2 with column 1: $-1(1)+2(3)=5$. Row 2 with column 2: $-1(2)+2(4)=6$.

$$BA=\begin{pmatrix}3&4\\5&6\end{pmatrix} \neq AB=\begin{pmatrix}-2&5\\-4&11\end{pmatrix}$$

Multiplying rectangular matrices, and the identity matrix

Example 3 · Multiplying non-square matrices
Given $A=\begin{pmatrix}1&2&0\\3&-1&4\end{pmatrix}$ (order $2\times3$) and $B=\begin{pmatrix}2&1\\0&3\\-1&2\end{pmatrix}$ (order $3\times2$), find $AB$.

$A$ is $2\times3$ and $B$ is $3\times2$, so $AB$ is defined and has order $2\times2$.

Row 1 of $A$ with column 1 of $B$: $1(2)+2(0)+0(-1)=2$. Row 1 with column 2: $1(1)+2(3)+0(2)=7$.

Row 2 with column 1: $3(2)+(-1)(0)+4(-1)=2$. Row 2 with column 2: $3(1)+(-1)(3)+4(2)=8$.

$$AB=\begin{pmatrix}2&7\\2&8\end{pmatrix}$$
Definition 19.2 — the identity matrix

The $n\times n$ identity matrix $I_n$ has $1$s on the leading diagonal and $0$s elsewhere. It behaves like the number $1$: $AI=IA=A$ for any compatible matrix $A$. For $2\times2$: $I_2=\begin{pmatrix}1&0\\0&1\end{pmatrix}$.

Example 4 · Verifying the identity property
Confirm that $AI_2=A$ for $A=\begin{pmatrix}5&-2\\1&3\end{pmatrix}$.

$AI_2=\begin{pmatrix}5&-2\\1&3\end{pmatrix}\begin{pmatrix}1&0\\0&1\end{pmatrix}=\begin{pmatrix}5(1)+(-2)(0)&5(0)+(-2)(1)\\1(1)+3(0)&1(0)+3(1)\end{pmatrix}=\begin{pmatrix}5&-2\\1&3\end{pmatrix}=A$ ✓

Common mistake

Matrix multiplication is not found by multiplying corresponding entries together — that is a different operation entirely. Always use the row-times-column rule, and always check the orders are compatible before starting.

Associativity and distributivity

Theorem 19.3 — properties that still hold

Although multiplication is not commutative, it is still associative, $A(BC)=(AB)C$, so brackets can be dropped or moved as long as the left-to-right order of the matrices stays the same. Multiplication is also distributive over addition: $A(B+C)=AB+AC$ and $(A+B)C=AC+BC$, provided the orders are compatible.

Example 5 · Checking associativity numerically
Given $A=\begin{pmatrix}1&2\\0&1\end{pmatrix}$, $B=\begin{pmatrix}2&0\\1&3\end{pmatrix}$ and $C=\begin{pmatrix}1&1\\2&0\end{pmatrix}$, confirm that $(AB)C=A(BC)$.

$AB=\begin{pmatrix}1(2)+2(1)&1(0)+2(3)\\0(2)+1(1)&0(0)+1(3)\end{pmatrix}=\begin{pmatrix}4&6\\1&3\end{pmatrix}$, so $(AB)C=\begin{pmatrix}4&6\\1&3\end{pmatrix}\begin{pmatrix}1&1\\2&0\end{pmatrix}=\begin{pmatrix}16&4\\7&1\end{pmatrix}$.

$BC=\begin{pmatrix}2(1)+0(2)&2(1)+0(0)\\1(1)+3(2)&1(1)+3(0)\end{pmatrix}=\begin{pmatrix}2&2\\7&1\end{pmatrix}$, so $A(BC)=\begin{pmatrix}1&2\\0&1\end{pmatrix}\begin{pmatrix}2&2\\7&1\end{pmatrix}=\begin{pmatrix}16&4\\7&1\end{pmatrix}$.

Both routes give the same matrix, so $(AB)C=A(BC)$ ✓ — this means a chain of matrix products like $ABC$ can be evaluated in either order without ambiguity, which is useful when one grouping is much quicker to compute than the other.

Exam-style questions

Question 1 6 marks

Given $A=\begin{pmatrix}2&-1\\0&3\end{pmatrix}$ and $B=\begin{pmatrix}1&4\\2&-2\end{pmatrix}$, find $AB$ and $BA$, and state whether $AB=BA$.

$AB=\begin{pmatrix}2(1)-1(2)&2(4)-1(-2)\\0(1)+3(2)&0(4)+3(-2)\end{pmatrix}=\begin{pmatrix}0&10\\6&-6\end{pmatrix}$ (M1, A1)

$BA=\begin{pmatrix}1(2)+4(0)&1(-1)+4(3)\\2(2)-2(0)&2(-1)-2(3)\end{pmatrix}=\begin{pmatrix}2&11\\4&-8\end{pmatrix}$ (M1, A1)

$AB\neq BA$ (B1, B1)

Question 2 6 marks

Given that $\begin{pmatrix}x&2\\1&y\end{pmatrix}\begin{pmatrix}3&0\\-1&4\end{pmatrix}=\begin{pmatrix}1&8\\2&4\end{pmatrix}$, find $x$ and $y$.

Row 1, column 1: $3x-2=1 \Rightarrow x=1$ (M1, A1)

Row 2, column 1: $3-y=2 \Rightarrow y=1$ (M1, A1)

Check row 2, column 2: $4y=4(1)=4$ ✓ consistent (A1, A1)

Question 3 7 marks

Given $A=\begin{pmatrix}1&1\\0&1\end{pmatrix}$, find $A^2$ and $A^3$, and suggest a general formula for $A^n$.

$A^2=\begin{pmatrix}1&1\\0&1\end{pmatrix}\begin{pmatrix}1&1\\0&1\end{pmatrix}=\begin{pmatrix}1&2\\0&1\end{pmatrix}$ (M1, A1)

$A^3=A^2A=\begin{pmatrix}1&2\\0&1\end{pmatrix}\begin{pmatrix}1&1\\0&1\end{pmatrix}=\begin{pmatrix}1&3\\0&1\end{pmatrix}$ (M1, A1)

General formula: $A^n=\begin{pmatrix}1&n\\0&1\end{pmatrix}$ (this can be proved rigorously by induction — see the Proof topic). (B1, B1, B1)