Module 1 of 1 · Lesson 8 of 14

The Singular Value Decomposition

Singular value decomposition, and the best low-rank approximation it provides.

What you will be able to do

Given a small matrix, the learner can compute its singular values from A T A , construct the right and left singular vectors, verify the factorisation, read the rank and the four subspaces off it, and give the best low-rank approximation with its error.

Orientation

Diagonalization asks whether a map is a pure scaling in one basis. For a rectangular matrix the question does not even make sense, input and output live in different spaces, and for a defective square matrix the answer is no.

Weaken the question and it always has an answer. Is the map a pure scaling from one orthonormal basis to another? Yes, for every real matrix without exception: rectangular, singular, defective, any shape at all.

What comes back is a ranked list. The singular values say how much the map stretches along each of a set of orthogonal directions, in decreasing order, so they measure how much of the matrix each direction accounts for. Keeping the largest few and discarding the rest gives the best approximation of that rank, which is why this decomposition underlies compression, denoising and principal component analysis.

Figure

The unit circle mapped to an ellipse with semiaxes the singular values

The image of the unit circle under A is an ellipse

The grey circle is every unit vector; the blue curve is its image under A = ( 3 0 4 5 ) .

The image of the unit circle under a linear map of the plane is always an ellipse, and the singular values are the lengths of its semiaxes: here σ 1 = 45 ≈ 6.7 and σ 2 = 5 ≈ 2.2 , the square roots of the eigenvalues of A T A . This A is invertible, so the ellipse is a genuine one.

That is the decomposition read geometrically, for this map. V T turns the circle onto the axes A treats specially, Σ stretches along them by σ 1 and σ 2 , and U turns the result into place.

What this picture does not show: what happens when a singular value is zero, or when A is rectangular. Those cases are real and the theorem covers them, but nothing here depicts them. The definition and theorem blocks establish them.

Definition

Why A T A , and what is not unique

Why the construction starts with A T A . Suppose the factorisation A = U Σ V T exists. Then

A T A = V Σ T U T U Σ V T = V ( Σ T Σ ) V T ,

using U T U = I . That is a diagonalization of A T A with eigenvalues σ i 2 and eigenvectors the columns of V . So the right singular vectors and the squared singular values are forced. They are not a choice, they are read off a symmetric matrix that is guaranteed to be diagonalizable.

The guarantee comes from A T A being symmetric, which the spectral theorem handles, and positive semidefinite: x T A T A x = ‖ A x ‖ 2 ≥ 0 , so no eigenvalue is negative and every square root is real.

Why u i = A v i / σ i works. These are orthonormal when σ i , σ j > 0 :

⟨ u i , u j ⟩ = ( A v i ) T ( A v j ) σ i σ j = v i T A T A v j σ i σ j = σ j 2 v i T v j σ i σ j ,

which is 0 for i ≠ j and 1 for i = j . The definition divides by σ i precisely so the result has norm 1, which is why it is unavailable when σ i = 0 , those columns of U must be filled by extending to an orthonormal basis instead.

What is unique and what is not. The singular values are unique, including their multiplicities, and they are always nonnegative and conventionally listed in decreasing order.

The singular vectors are not. Replacing ( u i , v i ) by ( − u i , − v i ) leaves σ i u i v i T unchanged, so sign flips are always available, but they must be made in matched pairs, since flipping only v i would change A v i without changing σ i u i . When a singular value repeats, any orthonormal basis of its subspace will serve, so there is a continuum of valid answers.

The practical consequence: an answer that differs from a reference by signs, or by a rotation within a repeated singular value's subspace, may be entirely correct. The verification A v i = σ i u i decides the question, not agreement with a printed table.

Shapes. For A of size m × n : U is m × m , Σ is m × n , V is n × n . The reduced form keeps only the first r = rank ⁡ A columns of U and V and the r × r block of Σ , which is what the rank-one expansion uses and what an implementation returns by default.

Theorem

Existence, and the best low-rank approximation

Theorem (existence). Every real m × n matrix has a singular value decomposition.

Proof. A T A is symmetric, so by the spectral theorem it has an orthonormal basis of eigenvectors v 1 , … , v n with real eigenvalues λ i . Each is nonnegative, since λ i = λ i ‖ v i ‖ 2 = v i T A T A v i = ‖ A v i ‖ 2 ≥ 0 . Order them decreasingly and set σ i = λ i , with r of them nonzero.

For i ≤ r define u i = A v i / σ i ; the calculation in the definition block shows these are orthonormal. Extend { u 1 , … , u r } to an orthonormal basis of R m , which is possible because any orthonormal set extends.

Now check A = U Σ V T by applying both sides to each v j . For j ≤ r : the right side gives U Σ e j = σ j u j , and the left gives A v j = σ j u j by definition. For j > r : ‖ A v j ‖ 2 = λ j = 0 , so A v j = 0 , and the right side is also zero. Two linear maps agreeing on a basis are equal. ◼

Nothing in the argument assumed A square, invertible, or diagonalizable, which is why the decomposition exists for every real matrix.

Theorem (Eckart–Young). Let A = ∑ i = 1 r σ i u i v i T and let A k be the sum truncated after k terms. Then among all matrices B with rank ⁡ B ≤ k ,

‖ A − A k ‖ F = σ k + 1 2 + ⋯ + σ r 2

is the minimum of ‖ A − B ‖ F , and likewise in the spectral norm where the minimum is σ k + 1 .

Why the error takes that form. The rank-one pieces are mutually orthogonal in the Frobenius inner product ⟨ X , Y ⟩ = tr ⁡ ( X T Y ) , because the u i are orthonormal and so are the v i . The discarded terms therefore contribute their squared norms additively, and ‖ σ i u i v i T ‖ F = σ i . So truncation is a projection, and the error is the length of what was projected away. The same Pythagorean statement as in the orthogonality unit, one level up.

Corollary (rank). rank ⁡ A is the number of nonzero singular values, since A r = A and no smaller truncation reproduces it.

Corollary (invariants). ‖ A ‖ F 2 = ∑ i σ i 2 , and for square A , | det A | = ∏ i σ i . The second because det ( U Σ V T ) = det U det Σ det V T with the orthogonal determinants equal to ± 1 . Both serve as cheap checks on a computed decomposition.

Procedure

Computing an SVD by hand

  1. Form A T A . It is n × n , symmetric, and positive semidefinite.
  2. Find its eigenvalues λ 1 ≥ ⋯ ≥ λ n ≥ 0 and orthonormal eigenvectors v 1 , … , v n . These are the columns of V .
  3. Take σ i = λ i , in the same order. Let r be the count of nonzero ones.
  4. For i ≤ r , set u i = A v i / σ i . These are automatically orthonormal.
  5. If r < m , extend { u 1 , … , u r } to an orthonormal basis of R m for the remaining columns of U .
  6. Assemble U , Σ and V with matching index order.
  7. Verify A v i = σ i u i for each i ≤ r , which is cheaper than multiplying out U Σ V T and catches the same errors.

Choosing A T A or A A T . Both give the same nonzero eigenvalues. Use whichever is smaller: for a 100 × 3 matrix, A T A is 3 × 3 and A A T is 100 × 100 . Starting from A A T gives the u i directly, and then v i = A T u i / σ i .

Checks worth running.

CheckCost
∑ i σ i 2 = ∑ i j a i j 2 one pass over the entries
∏ i σ i = | det A | (square A )one determinant
σ i ≥ 0 , in decreasing orderinspection
count of nonzero σ i equals the rankcompare with a row reduction

The first two catch most arithmetic slips before any singular vector is computed, and they cost far less than discovering the error at step 7.

The rank-one expansion. Once assembled,

A = ∑ i = 1 r σ i u i v i T ,

where each u i v i T is an outer product. A full matrix of rank 1, not a scalar. Truncating after k terms gives the best rank- k approximation, with Frobenius error σ k + 1 2 + ⋯ + σ r 2 .

Why this route is for hand computation only. Forming A T A squares the condition number, so small singular values are computed with badly degraded accuracy. Numerical libraries bidiagonalise A directly and never form the product. The mathematics is identical; the arithmetic is not.

Worked example

A full decomposition, verified twice

A = ( 3 0 4 5 ) .

Step 1: form A T A .

A T A = ( 3 4 0 5 ) ( 3 0 4 5 ) = ( 25 20 20 25 ) .

Symmetric, as it must be.

Step 2: its eigenvalues. Trace 50, determinant 625 − 400 = 225 , so p ( λ ) = λ 2 − 50 λ + 225 . The discriminant is 2500 − 900 = 1600 = 40 2 , giving

λ = 50 ± 40 2 = 45    and    5 .

Step 3: the singular values.

σ 1 = 45 = 3 5 ≈ 6.7082 , σ 2 = 5 ≈ 2.2361 .

Check before going further. σ 1 2 + σ 2 2 = 45 + 5 = 50 = tr ⁡ ( A T A ) = 9 + 0 + 16 + 25 . And σ 1 σ 2 = 225 = 15 = | det A | = | 15 − 0 | . Both hold, so the singular values are right whatever happens next.

Step 4: right singular vectors. For λ = 45 : A T A − 45 I = ( − 20 20 20 − 20 ) , giving v 1 ∝ ( 1 , 1 ) . For λ = 5 : ( 20 20 20 20 ) , giving v 2 ∝ ( 1 , − 1 ) . Normalising,

v 1 = 1 2 ( 1 , 1 ) , v 2 = 1 2 ( 1 , − 1 ) ,

orthonormal since ⟨ v 1 , v 2 ⟩ = 1 2 ( 1 − 1 ) = 0 .

Step 5: left singular vectors.

A v 1 = 1 2 ( 3 9 ) , u 1 = A v 1 σ 1 = 1 3 5 ⋅ 2 ( 3 9 ) = 1 10 ( 1 3 ) ≈ ( 0.3162 0.9487 ) .
A v 2 = 1 2 ( 3 − 1 ) , u 2 = A v 2 σ 2 = 1 5 ⋅ 2 ( 3 − 1 ) = 1 10 ( 3 − 1 ) ≈ ( 0.9487 − 0.3162 ) .

Orthonormality. ⟨ u 1 , u 2 ⟩ = 1 10 ( 3 − 3 ) = 0 , and each has norm 1 10 1 + 9 = 1 .

Step 6: assemble.

U = 1 10 ( 1 3 3 − 1 ) , Σ = ( 3 5 0 0 5 ) , V = 1 2 ( 1 1 1 − 1 ) .

Step 7: verify. A v 1 = 1 2 ( 3 , 9 ) T and σ 1 u 1 = 3 5 ⋅ 1 10 ( 1 , 3 ) T = 3 2 ( 1 , 3 ) T = 1 2 ( 3 , 9 ) T . Similarly A v 2 = 1 2 ( 3 , − 1 ) T = σ 2 u 2 . Multiplying out U Σ V T returns ( 3 0 4 5 ) exactly.

The rank-one expansion.

σ 1 u 1 v 1 T = 3 5 ⋅ 1 10 ( 1 3 ) ⋅ 1 2 ( 1 , 1 ) = 3 2 ( 1 1 3 3 ) = ( 1.5 1.5 4.5 4.5 ) .

That is A 1 , the best rank-1 approximation of A . The error is

A − A 1 = ( 1.5 − 1.5 − 0.5 0.5 ) , ‖ A − A 1 ‖ F = 2.25 + 2.25 + 0.25 + 0.25 = 5 = σ 2

exactly as Eckart–Young predicts: discarding one term costs the singular value discarded, and no other rank-1 matrix does better.

A note on signs. Choosing v 1 ∝ − ( 1 , 1 ) instead would give u 1 with both signs flipped, and the products σ 1 u 1 v 1 T would be identical. An answer differing from this one by matched sign flips is correct; what is not correct is flipping one of a pair without the other.

Example

Four matrices diagonalization could not handle

A rectangular matrix. A = ( 1 0 0 0 2 0 ) is 2 × 3 , so it has no eigenvalues, A v = λ v compares a vector in R 2 with one in R 3 . It has singular values regardless: A T A = diag ⁡ ( 1 , 4 , 0 ) , so σ 1 = 2 , σ 2 = 1 , and the rank is 2. The third right singular vector ( 0 , 0 , 1 ) spans the kernel.

A singular square matrix. A = ( 1 2 2 4 ) has det = 0 . Its A T A = ( 5 10 10 20 ) has trace 25 and determinant 0, so eigenvalues 25 and 0, giving σ 1 = 5 and σ 2 = 0 . One nonzero singular value, so rank 1, and indeed A 1 = A exactly, with zero approximation error.

A defective matrix. The shear ( 3 1 0 3 ) is not diagonalizable over any field, as the diagonalization unit showed. It still has a singular value decomposition: A T A = ( 9 3 3 10 ) , trace 19, determinant 90 − 9 = 81 , so λ = 19 ± 361 − 324 2 = 19 ± 37 2 , giving λ ≈ 12.5414 and 6.4586 , both positive. The singular values are their square roots, σ 1 ≈ 3.5414 and σ 2 ≈ 2.5414 , whose product is 81 = 9 = | det A | .

This is the sharpest contrast available: a matrix with one eigenvector and two singular directions.

A rotation. ( 0 − 1 1 0 ) has no real eigenvalues. Its A T A = I , so both singular values are 1. It stretches nothing, which is exactly what a rotation does. Every orthogonal matrix has all singular values equal to 1, and conversely.

Rectangular, singular, defective, and eigenvalue-free over R : each defeats diagonalization for a different reason, and none defeats the SVD. The decomposition asks only that A T A be symmetric and positive semidefinite, which it is for every real matrix without exception.

Non-example

Five errors about singular values

Taking singular values to be eigenvalues. For A = ( 3 1 0 3 ) the eigenvalues are 3 and 3; the singular values are ( 19 ± 37 ) / 2 , roughly 3.54 and 2.54. They are different quantities: σ i = λ i ( A T A ) , not λ i ( A ) . They coincide only when A is symmetric positive semidefinite, and then only because A T A = A 2 .

Expecting negative or complex singular values. A matrix with eigenvalues − 2 and − 5 has singular values 2 and 5; a rotation with eigenvalues ± i has singular values 1 and 1. Singular values are square roots of nonnegative numbers and are always real and nonnegative, which is why they measure stretching rather than describing dynamics.

Concluding that a defective matrix has no decomposition. Diagonalization fails for the shear above; the SVD does not. The existence proof needs only that A T A is symmetric and positive semidefinite, which holds for every real matrix. "Not diagonalizable" and "no SVD" are unrelated claims, and the second is never true.

Flipping one singular vector without its partner. Replacing v 1 by − v 1 while leaving u 1 alone breaks A v 1 = σ 1 u 1 and the factorisation no longer reproduces A . Sign freedom is real but paired: both members of ( u i , v i ) flip together, because the outer product u i v i T must be unchanged.

Treating the decomposition as unique. With a repeated singular value, any orthonormal basis of that subspace serves, so two correct answers may share no singular vectors at all. The identity matrix has σ 1 = σ 2 = 1 and every orthonormal pair is a valid choice. Comparing an answer against a reference by matching vectors is therefore the wrong check; verifying A v i = σ i u i is the right one.

What separates these. The first three mistake the SVD for diagonalization and import its limitations. The last two mistake a construction with genuine freedom for one with a single answer. Both errors are caught by the same habit: verify the factorisation rather than the vectors.

Optional enrichment (1)

Application

Compression, and principal components

Storing less. An m × n matrix holds m n numbers. Its rank- k truncation holds k ( m + n + 1 ) , k singular values plus k vectors of each length. For a 1000 × 1000 image that is a million numbers against about 20,000 at k = 10 , a fiftyfold reduction.

Whether that is worth doing depends on the singular value spectrum. If σ 11 onward are tiny relative to σ 1 , the discarded terms carried little of the matrix and the reconstruction is close; if the spectrum is flat, every direction matters equally and truncation destroys information. The spectrum is therefore diagnostic before it is useful: plotting σ i against i says whether a low-rank structure exists at all.

The error is known in advance, which is the unusual part. By Eckart–Young, keeping k terms costs exactly σ k + 1 2 + ⋯ + σ r 2 in Frobenius norm, so k can be chosen to meet a stated tolerance without trying any reconstruction.

Principal component analysis. Centre a data matrix X , n observations as rows, p variables as columns, so each column has mean zero. Then 1 n − 1 X T X is the sample covariance matrix, and the right singular vectors of X are its eigenvectors.

Those vectors are the principal components: v 1 is the direction along which the data varies most, v 2 the most variable direction orthogonal to it, and so on. The variance along v i is σ i 2 / ( n − 1 ) , so the singular values rank the directions by how much of the spread each explains.

Projecting the data onto the first k components is the rank- k truncation, so PCA is the SVD of the centred data matrix, and the fraction of variance retained is

σ 1 2 + ⋯ + σ k 2 σ 1 2 + ⋯ + σ r 2 .

What the technique does not supply. Centring is required. The SVD of an uncentred matrix finds directions dominated by the mean rather than the variation. Scaling matters too: variables in different units make the covariance meaningless, so columns are usually standardised, and that choice changes the components. And a component is a direction in the original variables, not a cause or a named factor; interpreting v 1 as a meaningful quantity is an inferential step the algebra never licenses.

Other uses of the same decomposition. The condition number σ 1 / σ r measures how sensitive a linear system is to perturbation. The pseudoinverse A + = V Σ + U T , formed by inverting the nonzero singular values, gives the minimum-norm least-squares solution for any A , including rank-deficient ones, where the normal equations have no unique answer.

Next step

Practice The Singular Value Decomposition

Practice records what support you used, so the evidence reflects how you actually performed.

Practice this lessonSkip to Quadratic Forms and Definiteness

Results update as you type. Use the up and down arrow keys to move between results, Enter to open one, and Escape to close.

Type to search.

Settings

Appearance

Interface density

Your record

Your progress is stored in this browser and nowhere else: an identifier, the answers you have given, the mastery states and review schedule derived from them, and the lesson you last opened. Clearing it makes you a new learner on this device. It cannot be undone, and it will not affect your appearance or density settings.

Focus timer

Focus--minutes remaining

Phase

Kept in this browser only, and used to label the session in your own history.

Today

Nothing recorded yet. Finish a focus session and it will appear here.

Settings

Focus sessions between long breaks.

Sessions you are aiming for in a day.

Notifications

Your history

Sessions are stored in this browser and nowhere else. They are not evidence and never reach your mastery record.