Wiki
Advanced14 min read

The SVD: every matrix is a rotate, a stretch, a rotate

The singular value decomposition exposes any matrix as a rotation, a diagonal scaling, and another rotation — the foundation of compression.

Eigenvectors are wonderful, but they only exist cleanly for square matrices — and even then only when there are enough of them. Real data matrices are rectangular, and image, embedding and vocabulary matrices are wildly so. The singular value decomposition rescues the entire idea: every matrix, of any shape, is a rotation followed by a non-uniform stretch followed by another rotation.

The eigens story, generalized

The SVD finds the directions in the input space that get stretched the most, the corresponding directions in the output space, and the stretch factors between them. Those stretch factors are the singular values, and they are always non-negative and ordered by size.

The matrix below is the sum of three rank-1 pieces with weights 4, 2 and 1. Slide the rank and watch how much of the original survives.

Keep the top k singular directions — how much of the matrix survives?

Original (rank 3)

1
1
1
0
0
1
1
1
1
0
1
0
1
1
1
0
0
0
0
0
0
1
1
1
0
1
0
1
1
1
1
0
0
1
1
1

Best rank-1 approximation

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
2
1
relative error
48.8%
energy kept
76%

Each bar is a singular value. Dropping the small ones costs almost nothing in error but can cut the storage dramatically — here rank 1 already keeps most of the energy, and rank 3 reproduces the matrix exactly. This is image and embedding compression, and it is also why low-rank structure shows up wherever data is redundant.

The decomposition

For any A∈Rm×nA \in \mathbb{R}^{m\times n} there exist orthogonal matrices U∈Rm×mU \in \mathbb{R}^{m\times m} and V∈Rn×nV \in \mathbb{R}^{n\times n}, and a diagonal matrix Σ∈Rm×n\Sigma \in \mathbb{R}^{m\times n} with non-negative entries, such that

A=UΣV⊤.A = U \Sigma V^\top.

Written term by term, this is a sum of rank-1 layers:

A=∑i=1rσi uivi⊤,σ1≥σ2≥⋯≥σr>0,A = \sum_{i=1}^{r} \sigma_i\, u_i v_i^\top, \qquad \sigma_1 \ge \sigma_2 \ge \cdots \ge \sigma_r > 0,

where rr is the rank of AA. The uiu_i are orthonormal left singular vectors (directions in the output space) and the viv_i are orthonormal right singular vectors (directions in the input space). Unlike eigenvectors, this sum always exists and the terms are always mutually orthogonal.

Low-rank approximation

The reason the SVD is everywhere is a theorem (Eckart–Young): truncating the sum at kk terms gives the best possible rank-kk approximation in the Frobenius norm,

Ak=∑i=1kσi uivi⊤.A_k = \sum_{i=1}^{k} \sigma_i\, u_i v_i^\top.

The squared error of the truncation is exactly the sum of the discarded squared singular values:

∥A−Ak∥F2=∑i=k+1rσi2.\lVert A - A_k \rVert_F^2 = \sum_{i=k+1}^{r} \sigma_i^2.

So a quickly decaying spectrum means the matrix is compressible. If the first few singular values dominate, you can store k(m+n)k(m + n) numbers instead of mnmn and lose almost nothing. That is image compression, and it is also why LoRA can fine-tune a large model by adding a tiny low-rank update rather than changing every weight.

Relationships worth knowing

  • With the eigendecomposition. The right singular vectors are eigenvectors of A⊤AA^\top A and the left are eigenvectors of AA⊤AA^\top; the singular values are the square roots of the (non-negative) eigenvalues of either. When AA is symmetric and positive semidefinite, SVD and eigendecomposition coincide.
  • With PCA. Center the data matrix, take its SVD, and the right singular vectors are the principal directions; the squared singular values divided by the sample size are the variances along them.
  • Condition number. σ1/σr\sigma_1 / \sigma_r measures how unequally the map stretches directions. A large value means small input changes can become large output changes — the source of numerical instability in solving systems.

Singular values are not eigenvalues

Singular values are always real and non-negative. Eigenvalues can be negative or complex. For a square matrix they are related but generally different; only for symmetric positive semidefinite matrices do they agree. Do not substitute one for the other in a formula.

Illustrative vs real

The widget uses a 6×66\times 6 rank-3 matrix so the truncation fits on screen. A 1024×7681024\times 768 image has up to 768 singular values, and a term "rank-1 layer" there is a whole outer-product image. The theorem is shape-independent; the picture is a convenient size, not the domain of the result.

Check yourself

Eduspheria wiki · Mathematics for AI, Linear algebra

0 / 5 answered

  1. 1The SVD factors a matrix into U, Σ and V. What are the diagonal entries of Σ called?
    Short answer
  2. 2A matrix has singular values 5, 3 and 1. What is the squared Frobenius error of its best rank-1 approximation?
    Numeric answer
  3. 3Which property do singular values always have?
    Multiple choice
  4. 4A 100×50 matrix is approximated by rank 3. How many numbers per term does one rank-1 layer store using its two vectors?
    Numeric answer
  5. 5Truncated SVD is optimal among all rank-k approximations in the Frobenius norm.
    True / false

Where next: probability — from transformations of space to the mathematics of uncertainty.