Matrix multiplication is the operation that turns matrices from static tables into composable linear maps. It is the algebraic core behind coordinate transforms, linear systems, neural network layers, and many numerical algorithms.
Dimension Rule
Let \(A\in\mathbb{R}^{n\times m}\) and \(B\in\mathbb{R}^{p\times q}\). The product \(AB\) exists exactly when
\[ m=p. \]
The result then has shape
\[ AB\in\mathbb{R}^{n\times q}. \]
A practical memory rule: inner dimensions must match, outer dimensions remain.
Entrywise Definition
For \(C=AB\), each entry \(c_{ij}\) is
\[ c_{ij}=\sum_{k=1}^{m} a_{ik}b_{kj}. \]
This is row \(i\) of \(A\) dotted with column \(j\) of \(B\), i.e. the dot product of the two vectors.
Two Complementary Pictures
Row-Column Picture
Compute one output entry at a time: pick a row from \(A\), pick a column from \(B\), take their dot product.
Column Combination Picture
Write \(A=[\mathbf{c}_1\ \mathbf{c}_2\ \dots\ \mathbf{c}_m]\) by columns and \(\mathbf{x}\in\mathbb{R}^m\). Then
\[ A\mathbf{x}=x_1\mathbf{c}_1+\dots+x_m\mathbf{c}_m. \]
So matrix-vector multiplication is a linear combination of columns. This interpretation is crucial for span, rank, and solvability.
Worked Example: Matrix-Matrix Product
\[ A=\begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix}, \qquad B=\begin{bmatrix} 5 & 6\\ 7 & 8 \end{bmatrix}. \]
Then
\[ AB= \begin{bmatrix} 1\cdot5+2\cdot7 & 1\cdot6+2\cdot8\\ 3\cdot5+4\cdot7 & 3\cdot6+4\cdot8 \end{bmatrix} = \begin{bmatrix} 19 & 22\\ 43 & 50 \end{bmatrix}. \]
Composition of Linear Maps
Matrix multiplication represents function composition. If \(B\) maps \(\mathbf{x}\mapsto B\mathbf{x}\) and \(A\) maps \(\mathbf{y}\mapsto A\mathbf{y}\), then
\[ \mathbf{x}\mapsto A(B\mathbf{x})=(AB)\mathbf{x}. \]
The right matrix acts first.
Geometric Interpretation in 2D
A \(2\times2\) matrix transforms the plane linearly: it can rotate, scale, shear, reflect, or combine these actions.
If \(A=[\mathbf{a}_1\ \mathbf{a}_2]\), then \(A\mathbf{e}_1=\mathbf{a}_1\) and \(A\mathbf{e}_2=\mathbf{a}_2\). So the matrix is fully determined by where it sends the basis vectors.
Determinants connect directly to multiplication:
\[ \det(AB)=\det(A)\det(B). \]
Area scaling factors therefore multiply under composition.
Algebraic Properties
For compatible sizes:
\[ A(BC)=(AB)C, \]
\[ A(B+C)=AB+AC, \]
\[ (A+B)C=AC+BC, \]
\[ I_nA=A, \qquad AI_m=A, \]
and generally
\[ AB\ne BA. \]
Order Matters: A Concrete 2D Example
Let \(R=\begin{bmatrix}0&-1\\1&0\end{bmatrix}\) (rotation by \(90^\circ\)) and \(S=\begin{bmatrix}2&0\\0&1\end{bmatrix}\) (x-scaling by \(2\)).
\[ RS= \begin{bmatrix} 0 & -1\\ 2 & 0 \end{bmatrix}, \qquad SR= \begin{bmatrix} 0 & -2\\ 1 & 0 \end{bmatrix}, \]
so \(RS\ne SR\). Rotating then scaling is different from scaling then rotating.
Complexity and Practical Computation
Naive multiplication of two \(n\times n\) matrices uses \(O(n^3)\) arithmetic operations. Highly optimized libraries use cache-friendly blocking and, for very large problems, asymptotically faster algorithms.
In applied work, always prefer tested linear algebra libraries over hand-written loops.
Common Pitfalls
- Ignoring the inner-dimension requirement.
- Confusing matrix multiplication with Hadamard (elementwise) multiplication.
- Assuming commutativity.
- Losing track of operation order in transformation chains.
Connections
The broader toolkit is developed with matrices. Solving linear systems and invertibility then build directly on matrix inversion.