Matrix Multiplication
Composing transformations through matrices
Matrices as Transformations
Before we can understand matrix multiplication, we need to see what a single matrix does. A 2×2 matrix is not just a grid of numbers—it is a complete description of how to transform space.
When we multiply a matrix by a vector, we are asking: where does this vector land after the transformation? The answer comes from a beautifully simple rule: the columns of the matrix tell you where the basis vectors and end up.
Interactive: Matrix-Vector Multiplication
Drag the white vector to see how the matrix transforms it
The formula for transforming a vector is:
Read this carefully: we take copies of the first column and copies of the second column, then add them together. The columns of the matrix are literally the transformed basis vectors.
Reading a Matrix
This insight changes how we should think about matrices. Instead of memorizing a formula, we can read what a matrix does directly from its columns.
The first column tells us where lands. The second column tells us where lands. Everything else follows from linearity.
Interactive: Build Your Own Transformation
The columns of the matrix are where î and ĵ land after transformation
Try setting . You will see a 90° rotation. Set for uniform scaling. The numbers directly encode the geometry.
Composition: One Transformation After Another
Now for the key insight that unlocks matrix multiplication. Suppose we have two transformations, each described by its own matrix. What if we want to apply one, then the other?
We could transform a vector by the first matrix, then take that result and transform it by the second matrix. But there is a better way: we can combine the two matrices into a single matrix that captures the entire composed transformation.
Interactive: Composing Two Transformations
Rotation
Scaling
When we write , we mean: first apply , then apply . The resulting matrix is computed by asking where the basis vectors land after both transformations.
The product matrix captures this composition. Its first column is where ends up after both transformations. Its second column is where ends up.
The Multiplication Formula
To compute the product, we transform each column of the second matrix by the first matrix:
Each column of the result comes from multiplying the left matrix by the corresponding column of the right matrix. This is not an arbitrary formula—it is the natural consequence of composing transformations.
Order Matters
Here is something crucial that catches many people off guard: matrix multiplication is not commutative. In general, .
Think about it geometrically. Rotating then shearing gives a different result than shearing then rotating. The order of transformations matters, so the order of matrix multiplication must matter too.
Interactive: AB vs BA
Shear
90° Rotation
Notice how the results are completely different!
This is not a quirk of the notation—it reflects a deep truth about transformations in space. When you shear first, you are shearing the original coordinate system. When you rotate first, the shear operates on an already-rotated system. The outcomes are genuinely different.
The Identity Matrix
There is one special matrix that deserves attention: the identity matrix. It leaves every vector exactly where it is.
The identity matrix sends to and to —exactly where they started. For any matrix :
Multiplying by the identity is like multiplying a number by 1. It is the do-nothing transformation, and it plays the role of the neutral element in matrix multiplication.
Interactive: From Identity to Transformation
Full transformation applied
Why This Matters
Matrix multiplication is the engine behind countless applications. In computer graphics, we chain transformations (translate, rotate, scale) into a single matrix. In machine learning, neural networks are essentially long compositions of linear transformations.
The geometric interpretation gives us intuition. The algebraic formulas give us computation. Together, they make matrices one of the most powerful tools in applied mathematics.
Key Takeaways
- A matrix transforms space by moving the basis vectors to new positions
- The columns of a matrix are where î and ĵ land after the transformation
- Matrix multiplication composes transformations: means first , then
- Order matters: in general
- The identity matrix leaves all vectors unchanged