Skip to content
BIASED

The singular value decomposition

Block 1 of 7~3 min

When eigenvectors are not enough

The topic Symmetric matrices and quadratic forms gave symmetric matrices a perfect description: an orthonormal basis of eigenvectors along which the matrix only stretches. Real data matrices are neither square nor symmetric. A dataset of NN examples with dd features is a matrix X∈RN×dX \in \mathbb R^{N \times d}, and a linear layer maps Rdin\mathbb R^{d_{\text{in}}} to Rdout\mathbb R^{d_{\text{out}}}. For a rectangular matrix the equation Av=λvAv = \lambda v does not even make sense: AvAv and vv live in different spaces.

Even a square matrix can let us down. Take the running example of this topic:

A=(22−21)A = \begin{pmatrix} 2 & 2 \\ -2 & 1 \end{pmatrix}

Its trace is 33 and its determinant is 66, so its eigenvalues are 1.5±1.936i1.5 \pm 1.936i. No real direction is merely stretched. Yet the geometry is simple: AA sends the unit circle to an ellipse, and an ellipse has two perpendicular axes.

The fix is to allow two orthonormal bases, one for the inputs and one for the outputs. Every matrix A∈Rm×nA \in \mathbb R^{m \times n} of rank rr factors as

A=UΣV⊤=∑i=1rσi uivi⊤.A = U \Sigma V^\top = \sum_{i=1}^{r} \sigma_i\, u_i v_i^\top.

Here U∈Rm×mU \in \mathbb R^{m \times m} and V∈Rn×nV \in \mathbb R^{n \times n} are orthogonal. Their columns uiu_i and viv_i are the left and right singular vectors. The matrix Σ∈Rm×n\Sigma \in \mathbb R^{m \times n} has the same shape as AA and is zero except for its diagonal. The diagonal starts with the singular values σ1≥σ2≥⋯≥σr>0\sigma_1 \ge \sigma_2 \ge \dots \ge \sigma_r > 0 and continues with zeros. This is the singular value decomposition, or SVD. Unlike an eigendecomposition, it exists for every real matrix of any shape.

The sum on the right reads as a recipe. Each term takes the component of the input along viv_i, scales it by σi\sigma_i and writes the result along uiu_i. So AA is a sum of rr rank-one pieces, sorted from the most important to the least.

For a tall data matrix most columns of UU meet only the zero rows of Σ\Sigma. Libraries can skip them: np.linalg.svd(X, full_matrices=False) returns just the first min⁡(m,n)\min(m, n) columns.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • SVD rank-1 reconstructionoptional

    Build σ1 u1 v1ᵀ; compare Frobenius error to the full matrix.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.