Hexa Scholar

Singular value decomposition

A round sheet of golden clay and a cream hand roller on a dark workbench.
A round sheet of clay and a roller suggest a workshop for changing shapes.

The question

Can you recreate a matrix's effect on a circle and its marked arrows?

  1. 1 SeeMatch the outline and its arrows.
  2. 2 TryTest what changes when directions collapse.
  3. 3 ProveBuild the factorization from dot products.
  4. 4 ApplyUse the factors on real data.
Before you start · 3 quick checks on matrix columns, dot products, and eigenvectors, about 3 min

Two ideas before you start

2 ideas

A turn preserves length

A fixed input arrow and its image after a plane rotation.

Turn angle

The dashed arrow turns about the origin. Its length stays the same.

Exact definition

A real square matrix \(Q\) is orthogonal if \(Q^TQ=I\), where \(Q^T\) swaps rows with columns and \(I\) is the identity map. Its columns form an orthonormal basis. Each column has length one, and any two distinct columns have dot product zero.

For any inputs \(x,y\), the dot product of their images is \((Qx)^T(Qy)=x^Ty\). Taking the same vector twice gives preservation of squared length. A plane rotation is an example.

A diagonal stretch changes coordinates separately

A fixed input arrow and its image with only the horizontal coordinate scaled.

Horizontal stretch

Change the horizontal stretch and watch the dashed tip move along a horizontal line.

Exact definition

In the plane, \(\operatorname{diag}(s,t)\) is a diagonal matrix with entries \(s,t\) on its diagonal and zero elsewhere. It sends \((x,y)\) to \((sx,ty)\). The same rule scales each coordinate in higher dimensions. A rectangular diagonal matrix also drops any extra input coordinates or pads the output with zeros as its dimensions require.

Refresher on symmetric matrices

A real square matrix \(G\) is symmetric when \(G^T=G\). The real spectral theorem says that its space has an orthonormal basis of eigenvectors \(v_i\), with real eigenvalues \(\lambda_i\) satisfying \(Gv_i=\lambda_i v_i\). Within a repeated eigenspace, choose any orthonormal basis. The proof uses this theorem for a symmetric matrix formed from the original map.

See symmetric matrices and their eigenvector directions for the spectral theorem and its geometry.

1 See

Match the target ellipse and its arrows

2 Try

Which operations does this map need?

Check your prediction to open the shape controls.

3 Prove

Find the input and output frames

Theorem

Let \(A\) be any real \(m\)-by-\(n\) matrix with \(m,n\ge1\). There are orthogonal matrices \(U\) of size \(m\)-by-\(m\) and \(V\) of size \(n\)-by-\(n\) and an \(m\)-by-\(n\) diagonal matrix \(\Sigma\) such that

\[A=U\Sigma V^T.\]

The \(\min(m,n)\) diagonal entries of \(\Sigma\), in nonincreasing order, are the singular values. They are the square roots of the largest \(\min(m,n)\) eigenvalues of \(A^TA\), counted with multiplicity. All are nonnegative, and the number of positive singular values is the rank of \(A\). The map can be rectangular, rank deficient, or zero.

Set \(G=A^TA\). Its orthonormal eigenvectors \(v_i\) have eigenvalues \(\lambda_i\). Pick the next statement at each step. When a line refers to a zero or positive eigenvalue, choose it for an index satisfying that condition.

4 Apply

Calculate with the factors

Choose a problem and enter a number, or open its hints. The cases below use three parts of the decomposition. The singular values describe lengths and area, the matching pairs of vectors describe patterns, and the positive singular values tell you which directions can be recovered.

How truncation and the pseudoinverse work

Write the matrix as a sum over its positive singular values. With \(r\) denoting its rank and \(u_i,v_i\) the matching unit vectors,

\[A=\sum_{i=1}^{r}\sigma_i u_iv_i^T.\]

Each outer product \(u_iv_i^T\) takes a dot product with \(v_i\) and sends that scalar along \(u_i\). Keeping the first \(k\) terms gives \(A_k\), whose rank is at most \(k\). Because the outer products are mutually orthonormal under the sum of entrywise products, the squared Frobenius error is the sum of the squares of the discarded singular values. For a real matrix and \(0\le k\le r\), the Eckart–Young theorem says this gives the smallest Frobenius error among matrices of rank at most \(k\).

When the target output vector is \(b\), its coordinates in the output basis are \(u_i^Tb\). For each positive \(\sigma_i\), divide that coordinate by \(\sigma_i\) to recover an input coordinate. The component of \(b\) orthogonal to the image cannot be reached and is left as a residual. Any remaining input coordinate lies in a direction that maps to zero. Setting it to zero makes the input as short as possible among least-squares minimizers.

The linear map taking \(b\) to that shortest input is the pseudoinverse \(A^+=V\Sigma^+U^T\). The rectangular diagonal \(\Sigma^+\) has the reversed dimensions of \(\Sigma\), with reciprocals in the positive positions and zeros elsewhere. Small positive singular values amplify changes in the corresponding output coordinates when you divide by them. For an invertible square matrix, the ratio of the largest to the smallest singular value is its condition number in the Euclidean norm. It compares the strongest and weakest stretches.

Key point The singular values tell you how strongly each independent input direction reaches the output. Keeping the largest ones retains the strongest patterns in a low-rank approximation. Taking reciprocals of the positive ones reverses the action along the reachable directions.
Level Intro Prerequisites Matrix-vector multiplication, dot products, and eigenvectors Time ~35 min

Further reading