Mathematics · intro

Matrices & Linear Transformations

Matrix multiplication as composing linear maps: rotation, scaling, projection, and change of basis.

mathematicslinear-algebra

Mental model

A matrix is a machine that takes vectors in and pushes vectors out. Columns tell you where the basis vectors land. Matrix multiply chains machines — output of one feeds the next.

How to study Matrices & Linear Transformations

Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use MIT 18.06 Linear Algebra (Strang) to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.

Next, compare Matrices & Linear Transformations with Eigenvalues & Matrix Decomposition, Linear Regression, ML Math Foundations. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Multiply 2×2 matrices by hand and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.

Proof of understanding

  • Explain the mechanism from first principles and identify the state it reads or changes.
  • Give one situation where the concept is the right choice and one where it is not.
  • Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
  • Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.

Where it matters

Neural network layers, image transforms, PCA, solving linear systems.

Common mistakes

  • Multiplying matrices in the wrong order (not commutative)
  • Confusing rows vs columns when reading a transformation
  • Assuming every square matrix is invertible

Learn from primary sources

Practice and explain it back

Multiply 2×2 matrices by hand

Compute AB where A = [[1, 2], [0, 1]] and B = [[1, 0], [3, 1]]. Then apply A to vector x = [1, 1] and B to the result — does AB·x equal A·(B·x)?

Expected evidence: AB = [[7, 2], [3, 1]]; AB·x = [9, 4] = A·(B·x). Matrix multiplication is composition.

Open the interactive drill →

Review prompts

  • How do the columns of a matrix relate to a linear transformation?

Build evidence

Implement matrix multiplication from scratch

General m×n by n×p matmul with nested loops; apply to a 2D rotation + scale transform on points.

  • Correct matmul on 3×3 test case vs hand calculation
  • Apply transform to ≥4 points; verify orthogonality preserved for pure rotation

Least-squares regression from scratch

Fit y = Xβ via normal equations (XᵀX)β = Xᵀy using your matmul — no sklearn. Report β, residuals, R².

  • Matches sklearn/polyfit on a 2-feature toy dataset within 1e-6
  • Plot residuals; comment on one outlier's leverage

Prerequisites

Related concepts

Learning paths