The idea
A matrix is a compact rule for transforming vectors: its columns show exactly where the basis vectors land. Scaling, rotation, reflection, and shear all become a single matrix multiplication — the same trick used throughout graphics, machine learning, and other data transformations.
Matrix multiplication composes transformations. If acts first and acts second, then : the rightmost matrix is applied first. This also explains why two linear layers without a nonlinearity collapse to one matrix product.
Real-world: stretching a game sprite
A 2D game doubles a character's width but keeps its height, so every point is transformed to by the matrix . The sprite point moves to — the -coordinate doubles while stays unchanged.
The matrix scales the vector’s x-coordinate by 2; y stays fixed.
Worked example
Apply the transform in one calculation:
Cheat sheet
- Each column of the matrix is where a basis vector ( or ) lands after the transform.
- The identity matrix leaves every vector unchanged.
- A diagonal matrix scales each axis independently by its diagonal entry.
- Matrix multiplication composes transformations right-to-left: applies first, then .
- Matrix multiplication applies the same linear transformation consistently to every point.