Lesson 3.7 · Stage 03: The maths behind machine learning

Maths chapter 5: Matrix decompositions: eigenvectors and SVD

A matrix moves most arrows to new directions. A few special arrows only get longer or shorter. Those are eigenvectors, and they reveal what the matrix really does.

Published 27 November 2026

A matrix moves most arrows to new directions. A few special arrows only get longer or shorter. Those are eigenvectors, and they reveal what the matrix really does.

5.1 Eigenvectors and eigenvalues

An eigenvector v of matrix A is an arrow that A only stretches, never turns. The stretch amount is the eigenvalue λ (Greek “lambda”).

Av=λvA\mathbf{v} = \lambda \mathbf{v}

Easy example. A = [[2, 0], [0, 3]] stretches the x-direction by 2 and the y-direction by 3. So (1, 0) is an eigenvector with λ = 2, and (0, 1) is an eigenvector with λ = 3.

Worked example. A = [[2, 1], [1, 2]].

  • Try v = (1, 1): Av = (2 + 1, 1 + 2) = (3, 3) = 3 × (1, 1). Eigenvector, λ = 3.
  • Try v = (1, −1): Av = (2 − 1, 1 − 2) = (1, −1) = 1 × (1, −1). Eigenvector, λ = 1.
  • Try v = (1, 0): Av = (2, 1). That is not a multiple of (1, 0), so it is not an eigenvector.

5.2 How to find eigenvalues (2 × 2)

Solve this equation, which turns into a class 10 quadratic:

det⁡(A−λI)=0\det(A - \lambda I) = 0

For A = [[2, 1], [1, 2]]: (2 − λ)(2 − λ) − 1 × 1 = 0. That gives (2 − λ)² = 1, so 2 − λ = ±1, and λ = 1 or λ = 3. These match what we found by trying.

5.3 Eigendecomposition

If you know a matrix’s eigenvectors and eigenvalues, you can rebuild it. The matrix is “turn to the eigenvector directions, stretch by the eigenvalues, turn back”. Breaking a matrix into simple pieces like this is called a decomposition, like writing 12 = 2 × 2 × 3.

5.4 SVD: every matrix is rotate, stretch, rotate

Eigenvectors only work nicely for some square matrices. The singular value decomposition (SVD) works for every matrix, any shape:

A=UΣVTA = U \Sigma V^{\mathsf{T}}
  • Vᵀ turns (rotates) the input.
  • Σ (capital sigma) stretches along each axis. Its numbers are the singular values, largest first.
  • U turns the result to its final direction.

Picture it: any matrix turns a circle of arrows into an ellipse. The singular values are the ellipse’s long and short radii.

Why ML needs it: keep only the biggest singular values and you keep most of the information. A photo stored as a matrix can be shrunk this way with little visible loss. Recommendation systems use the same trick.

5.5 PCA: the most important direction in data

Imagine heights and weights of 100 students plotted as dots. The cloud is long and thin, tilted upward. Principal component analysis (PCA) finds the direction along which the cloud is longest. That direction is the top eigenvector of the data’s covariance matrix (Chapter 9), which you can get from the SVD.

Project every dot onto that one line (Chapter 4’s shadow) and two numbers per student become one, with little information lost. This is how ML squeezes data with hundreds of features down to a few.

Try it

  1. Is (1, 0) an eigenvector of [[4, 0], [0, 7]]? If yes, what is λ?
  2. For A = [[3, 1], [0, 2]], work out A × (1, 0). Is it an eigenvector?
  3. For A = [[2, 1], [1, 2]], is (1, 2) an eigenvector?
  4. Find both eigenvalues of [[4, 1], [2, 3]].