BetaFree coursewareRewritten from MIT OpenCourseWareCC BY-NC-SA 4.0
Open CosmologyPhysics & cosmology, from high school to a graduate year

Singular value decomposition

Every matrix A, of any shape, factors as A = UΣVᵀ: orthogonal, diagonal, orthogonal. For a symmetric positive definite matrix this is QΛQᵀ with one Q on both sides, but in general the two orthogonal matrices differ. The goal: an orthonormal basis v₁, …, v_r of the row space that A sends to multiples of an orthonormal basis u₁, …, u_r of the column space, Avᵢ = σᵢuᵢ, so AV = UΣ; orthonormal bases of the two nullspaces complete V and U and give zeros in Σ. To find them, AᵀA = VΣᵀΣVᵀ removes U: the v's are the eigenvectors of AᵀA and the σ² its eigenvalues; likewise the u's are the eigenvectors of AAᵀ, which has the same nonzero eigenvalues. Strang's example (4 4; −3 3) gives AᵀA = (25 7; 7 25) with eigenvalues 32 and 18, v's (1, 1)/√2 and (1, −1)/√2, σ's √32 and √18, and AAᵀ = diag(32, 18); his product came out with a wrong sign in the second row, a puzzle he left for later (taking u₂ = Av₂/σ₂ = (0, −1) fixes it). The rank-one example (4 3; 8 6) has AᵀA = (80 60; 60 45) with eigenvalues 125 and 0, σ₁ = √125, v₁ = (0.8, 0.6), u₁ = (1, 2)/√5. The SVD chooses the right bases for all four fundamental subspaces: orthonormal, and making A diagonal.

You need this first

Full reading path (24 pages)
  1. Vectors (8.01)
  2. Vectors and the dot product (18.02)
  3. Determinants and the cross product (18.02)
  4. Planes through three points, and matrices (18.02)
  5. Equations of planes and square systems (18.02)
  6. The geometry of linear equations (18.06)
  7. Elimination with matrices (18.06)
  8. Matrix multiplication and inverse matrices (18.06)
  9. Factorization into A = LU (18.06)
  10. Transposes, permutations and vector spaces (18.06)
  11. Properties of determinants (18.06)
  12. Determinant formulas and cofactors (18.06)
  13. Cramer's rule, the inverse matrix and volume (18.06)
  14. Column space and nullspace (18.06)
  15. Eigenvalues and eigenvectors (18.06)
  16. Diagonalisation and powers of A (18.06)
  17. Solving Ax = 0: pivot variables and special solutions (18.06)
  18. Solving Ax = b: the complete solution (18.06)
  19. Independence, basis and dimension (18.06)
  20. The four fundamental subspaces (18.06)
  21. Orthogonal vectors and subspaces (18.06)
  22. Projections onto subspaces (18.06)
  23. Projection matrices and least squares (18.06)
  24. Symmetric matrices and positive definiteness (18.06)
On this page · 6 sections
  1. The goal: orthogonal bases that stay orthogonal
  2. Finding V and U
  3. Strang's first example
  4. A singular example
  5. The right bases for the four subspaces
  6. Summary

The singular value decomposition, the SVD, is "the final and best factorization of a matrix" (transcript, p. 1). Its factors are an orthogonal matrix, a diagonal matrix and another orthogonal matrix, and any matrix whatsoever has one (p. 1):

SVD
A=UΣVTA = U\Sigma V^T
In words

capital A equals capital U capital sigma capital V ^ capital T

It brings the course together (p. 1). For a symmetric positive definite matrix it is A=QΛQTA = Q\Lambda Q^T: orthonormal eigenvectors and positive eigenvalues, one QQ for both sides (p. 1). For other matrices the eigenvector matrix is not orthogonal, so two different orthogonal matrices are needed (pp. 1–2).

The goal: orthogonal bases that stay orthogonal#

Picture AA taking the row space to the column space (p. 2). A vector v1v_1 in the row space goes to Av1Av_1 in the column space. Gram–Schmidt gives an orthogonal basis of the row space easily, but AA would generally not keep it orthogonal (p. 2). The SVD looks for the special orthonormal basis that stays orthogonal (pp. 2–3):

Row-space basis to column-space basis
Av1=σ1u1,Av2=σ2u2,…,Avr=σrurAv_1 = \sigma_1u_1, \quad Av_2 = \sigma_2u_2, \quad \dots, \quad Av_r = \sigma_ru_r
In words

capital A v one equals sigma one u one, capital A v two equals sigma two u two, and so on, capital A v sub r equals sigma sub r u r

The vv's are orthonormal in the row space, the uu's orthonormal in the column space, and the stretching numbers are called σ\sigma, no longer λ\lambda (p. 3). In matrix language (p. 4):

Matrix form
A(v1⋯vr)=(u1⋯ur)(σ1⋱σr),AV=UΣA\begin{pmatrix} v_1 & \cdots & v_r \end{pmatrix} = \begin{pmatrix} u_1 & \cdots & u_r \end{pmatrix}\begin{pmatrix} \sigma_1 & & \\ & \ddots & \\ & & \sigma_r \end{pmatrix}, \qquad AV = U\Sigma
In words

capital A v one and so on v sub r equals u one and so on u r sigma one; and so on down the diagonal; sigma sub r, capital A capital V equals capital U capital sigma

The nullspaces cause no difficulty: orthonormal bases vr+1,…,vnv_{r+1}, \dots, v_n of the nullspace and ur+1,…,umu_{r+1}, \dots, u_m of the left nullspace complete VV and UU to square orthogonal matrices, and they meet zeros in Σ\Sigma (pp. 3, 5). (Strang says "vr+1v_{r+1} down to vmv_m" and seems to name the two spaces Rm\mathbf{R}^m and Rn\mathbf{R}^n the other way round for a moment; the vv's run to vnv_n in Rn\mathbf{R}^n.) Since VV is square and orthogonal, V−1=VTV^{-1} = V^T and A=UΣVTA = U\Sigma V^T (p. 5).

Finding V and U#

Two unknown orthogonal matrices at once is too many. To make UU disappear, use the great matrix ATAA^TA, symmetric and positive (semi)definite (pp. 5–6):

AᵀA removes U
ATA=VΣTUTUΣVT=V(σ12⋱σn2)VTA^TA = V\Sigma^TU^TU\Sigma V^T = V\begin{pmatrix} \sigma_1^2 & & \\ & \ddots & \\ & & \sigma_n^2 \end{pmatrix}V^T
In words

capital A ^ capital T capital A equals capital V capital sigma ^ capital T capital U ^ capital T capital U capital sigma capital V ^ capital T equals capital V sigma one squared; and so on down the diagonal; sigma n squared capital V ^ capital T

because UTU=IU^TU = I (p. 6); here σr+1=⋯=σn=0\sigma_{r+1} = \cdots = \sigma_n = 0. This is exactly QΛQTQ\Lambda Q^T for ATAA^TA: the vv's are its eigenvectors and the σ2\sigma^2's its eigenvalues (p. 7). In the other order the VV's drop out (pp. 7, 10):

AAᵀ removes V
AAT=UΣΣTUTAA^T = U\Sigma\Sigma^TU^T
In words

capital A capital A ^ capital T equals capital U capital sigma capital sigma ^ capital T capital U ^ capital T

so the uu's are the eigenvectors of AATAA^T, and the σ\sigma's are the positive square roots (p. 7).

Strang's first example#

Example matrix
A=(44−33)A = \begin{pmatrix} 4 & 4 \\ -3 & 3 \end{pmatrix}
In words

capital A equals 4 4; minus 3 3

It is invertible, rank 2, and not symmetric, so its own eigenvectors cannot be used (pp. 4–5). (In fact its eigenvalues are complex, 3.5±i11.753.5 \pm i\sqrt{11.75}: it has no real eigenvectors at all.) First (p. 8):

AᵀA for the example
ATA=(4−343)(44−33)=(257725)A^TA = \begin{pmatrix} 4 & -3 \\ 4 & 3 \end{pmatrix}\begin{pmatrix} 4 & 4 \\ -3 & 3 \end{pmatrix} = \begin{pmatrix} 25 & 7 \\ 7 & 25 \end{pmatrix}
In words

capital A ^ capital T capital A equals 4 minus 3; 4 3 4 4; minus 3 3 equals 25 7; 7 25

Its eigenvectors are (1,1)(1, 1), with ATA(1,1)=(32,32)A^TA(1, 1) = (32, 32), and (1,−1)(1, -1), with eigenvalue 1818; normalised by 2\sqrt2, they are v1v_1 and v2v_2 (pp. 8–9). So σ1=32\sigma_1 = \sqrt{32} and σ2=18\sigma_2 = \sqrt{18} (p. 9). For UU (pp. 10–11):

AAᵀ for the example
AAT=(320018)AA^T = \begin{pmatrix} 32 & 0 \\ 0 & 18 \end{pmatrix}
In words

capital A capital A ^ capital T equals 32 0; 0 18

By luck it is diagonal, with eigenvectors (1,0)(1, 0) and (0,1)(0, 1), and again eigenvalues 32 and 18: no surprise, since ABAB and BABA always have the same eigenvalues (p. 11). Multiplying out, 32/2=4\sqrt{32}/\sqrt2 = 4 gives the first row (4,4)(4, 4) correctly, but the second row comes out (3,−3)(3, -3) instead of (−3,3)(-3, 3) (p. 12). Strang considers flipping the sign of an eigenvector but does not want a minus sign in Σ\Sigma, and leaves the puzzle for later (pp. 12–13); the later transcripts do not return to it. Earlier he had remarked that UU could also be worked out from the other pieces (p. 10). (The page's own resolution follows that route: each eigenvector is fixed only up to sign, and the choices for uu and vv must match. Taking u2=Av2/σ2=(0,−6/2)/18=(0,−1)u_2 = Av_2/\sigma_2 = (0, -6/\sqrt2)/\sqrt{18} = (0, -1) instead of (0,1)(0, 1) makes UΣVT=AU\Sigma V^T = A exactly, and Σ\Sigma keeps its positive entries: the sign sits in UU.)

A singular example#

Rank-one example
A=(4386)A = \begin{pmatrix} 4 & 3 \\ 8 & 6 \end{pmatrix}
In words

capital A equals 4 3; 8 6

Its row space is the line of multiples of (4,3)(4, 3), with the nullspace perpendicular; its column space is the line through (4,8)(4, 8), or (1,2)(1, 2), with the left nullspace perpendicular to it (pp. 13–14). With one-dimensional spaces the bases are forced: v1=(0.8,0.6)v_1 = (0.8, 0.6) and u1=(1,2)/5u_1 = (1, 2)/\sqrt5 (pp. 14–15). From (p. 15)

AᵀA, rank one
ATA=(80606045),λ=125, 0,σ1=125A^TA = \begin{pmatrix} 80 & 60 \\ 60 & 45 \end{pmatrix}, \qquad \lambda = 125,\ 0, \qquad \sigma_1 = \sqrt{125}
In words

capital A ^ capital T capital A equals 80 60; 60 45, lambda equals 125, 0, sigma one equals the square root of 125

Strang states the eigenvalues 0 and 125 at once, the rank being one (p. 16); the trace 80+4580 + 45 confirms the nonzero one. Completing the bases with the nullspace directions, v2=(0.6,−0.8)v_2 = (0.6, -0.8) and u2=(2,−1)/5u_2 = (2, -1)/\sqrt5 (p. 16):

Its SVD
(4386)=15(122−1)(125000)(0.80.60.6−0.8)\begin{pmatrix} 4 & 3 \\ 8 & 6 \end{pmatrix} = \frac{1}{\sqrt5}\begin{pmatrix} 1 & 2 \\ 2 & -1 \end{pmatrix}\begin{pmatrix} \sqrt{125} & 0 \\ 0 & 0 \end{pmatrix}\begin{pmatrix} 0.8 & 0.6 \\ 0.6 & -0.8 \end{pmatrix}
In words

4 3; 8 6 equals 1 over the square root of 5 1 2; 2 minus 1 the square root of 125 0; 0 0 0.8 0.6; 0.6 minus 0.8

125/5=5\sqrt{125}/\sqrt5 = 5, and 5 times the products of (1,2)(1, 2) and (0.8,0.6)(0.8, 0.6) gives back whole numbers: AA (p. 16). The nullspace vectors are multiplied by the zero (p. 17).

The right bases for the four subspaces#

What the SVD really does is choose the right bases for the four fundamental subspaces (pp. 17–18):

Gram–Schmidt could make orthonormal bases in chapter 4; the SVD needs eigenvalues because its bases also make the matrix diagonal: AA times each viv_i lies along the matching uiu_i, with no coupling (p. 17). The SVD returns in the last lectures of the course (p. 18).

Worked example

An SVD of your own

(a) Find the SVD of A=(55−17)A = \begin{pmatrix} 5 & 5 \\ -1 & 7 \end{pmatrix}, using ui=Avi/σiu_i = Av_i/\sigma_i. (b) Find the SVD of the rank-one matrix B=(21−4−2)B = \begin{pmatrix} 2 & 1 \\ -4 & -2 \end{pmatrix}.

(a) AᵀA

ATA=(25+125−725−725+49)=(26181874)A^TA = \begin{pmatrix} 25 + 1 & 25 - 7 \\ 25 - 7 & 25 + 49 \end{pmatrix} = \begin{pmatrix} 26 & 18 \\ 18 & 74 \end{pmatrix}: trace 100, determinant 1924−324=16001924 - 324 = 1600, so eigenvalues 8080 and 2020. ATA−80I=(−541818−6)A^TA - 80I = \begin{pmatrix} -54 & 18 \\ 18 & -6 \end{pmatrix} gives v1=(1,3)/10v_1 = (1, 3)/\sqrt{10}, and v2=(3,−1)/10v_2 = (3, -1)/\sqrt{10}. Singular values σ1=80=45\sigma_1 = \sqrt{80} = 4\sqrt5, σ2=20=25\sigma_2 = \sqrt{20} = 2\sqrt5.

(a) The u's

Av1=(20,20)/10Av_1 = (20, 20)/\sqrt{10}, so u1=(20,20)/(10⋅45)=(1,1)/2u_1 = (20, 20)/(\sqrt{10} \cdot 4\sqrt5) = (1, 1)/\sqrt2. Av2=(10,−10)/10Av_2 = (10, -10)/\sqrt{10}, so u2=(1,−1)/2u_2 = (1, -1)/\sqrt2. They are orthonormal, and σ1σ2=40=det⁡A=35+5\sigma_1\sigma_2 = 40 = \det A = 35 + 5, as it should be for a 2×22 \times 2 matrix with positive determinant.

(b) Rank one

The row space is the line through (2,1)(2, 1) and the column space the line through (1,−2)(1, -2): v1=(2,1)/5v_1 = (2, 1)/\sqrt5, u1=(1,−2)/5u_1 = (1, -2)/\sqrt5. BTB=(2010105)B^TB = \begin{pmatrix} 20 & 10 \\ 10 & 5 \end{pmatrix} has trace 25 and rank one, so σ1=5\sigma_1 = 5. Check: 5u1v1T=55(21−4−2)=B5u_1v_1^T = \frac55\begin{pmatrix} 2 & 1 \\ -4 & -2 \end{pmatrix} = B. Complete with v2=(1,−2)/5v_2 = (1, -2)/\sqrt5 (nullspace) and u2=(2,1)/5u_2 = (2, 1)/\sqrt5 (left nullspace).

Summary#

Symbols on this page

Show the 40 symbols used here
λ\lambda lambda.
An eigenvalue of A. Say it: “lambda”.
Λ\Lambda capital lambda.
The diagonal matrix of the eigenvalues. Say it: “capital lambda”.
σ\sigma sigma.
A singular value: the stretching factor in Av = σu. Say it: “sigma”.
±\pm plus or minus.
Plus or minus: both signs, or an uncertainty (67.3 ± 1.2). Say it: “plus or minus”.
×\times times.
Times (multiplication). Between two vectors: the cross product. Say it: “times”.
⋅\cdot dot.
Times (multiplication). Between two vectors: the dot product. Say it: “times”.
det⁡\det determinant.
Determinant of a matrix. Say it: “the determinant of”.
TT T.
As a superscript: the transpose. Say it: “capital T”.
Σ\Sigma capital sigma.
The diagonal matrix of singular values σ₁, …, σ_r (then zeros). Say it: “capital sigma”.
ii i.
The imaginary unit, i² = −1. Say it: “i”.
nn n.
The number of columns of A. Say it: “n”.
mm m.
The number of rows of A. Say it: “m”.
vv v.
A right singular vector (a column of V). Say it: “v”.
rr r.
The rank of A: the number of nonzero singular values. Say it: “r”.
QQ Q.
The orthogonal eigenvector matrix in A = QΛQᵀ (symmetric positive definite case). Say it: “Q”.
AA A.
Any m × n matrix to be factored; in the examples, the matrices with rows (4, 4), (−3, 3) and (4, 3), (8, 6), and the worked example's (5, 5), (−1, 7). Say it: “capital A”.
BB B.
The worked example's rank-one matrix with rows (2, 1), (−4, −2). Say it: “B”.
uu u.
A left singular vector (a column of U). Say it: “u”.
viv_{i} initial velocity.
The i-th right singular vector. Say it: “v sub i”.
UU U.
The orthogonal matrix whose columns u₁, …, u_m are the left singular vectors. Say it: “capital U”.
VV V.
The orthogonal matrix whose columns v₁, …, vₙ are the right singular vectors. Say it: “capital V”.
uru_{r} radiation energy density.
The last left singular vector in the column space. Say it: “u r”.
σr\sigma_{r} radial velocity dispersion.
The last nonzero singular value. Say it: “sigma sub r”.
v1v_{1} v one.
The first right singular vector: a unit vector in the row space. Say it: “v one”.
v2v_{2} v two.
The second right singular vector. Say it: “v two”.
II I.
The identity matrix. Say it: “capital I”.
vrv_{r} v r.
The last right singular vector in the row space. Say it: “v sub r”.
u1u_{1} u one.
The first left singular vector: a unit vector in the column space. Say it: “u one”.
u2u_{2} u two.
The second left singular vector. Say it: “u two”.
uiu_{i} u sub i.
The i-th left singular vector, uᵢ = Avᵢ/σᵢ. Say it: “u sub i”.
σ1\sigma_{1} sigma one.
The first (largest) singular value. Say it: “sigma one”.
σ2\sigma_{2} sigma two.
The second singular value. Say it: “sigma two”.
vmv_{m} v sub m.
Strang's slip for vₙ, the last right singular vector. Say it: “v sub m”.
vnv_{n} v n.
The last right singular vector (in the nullspace when r < n). Say it: “v n”.
σn\sigma_{n} sigma n.
The last diagonal entry of Σ (zero when r < n). Say it: “sigma n”.
σi\sigma_{i} sigma i.
The i-th singular value. Say it: “sigma sub i”.
vr+1v_{r+1} v r plus 1.
The first right singular vector in the nullspace. Say it: “v sub r plus 1”.
ur+1u_{r+1} u r plus 1.
The first left singular vector in the nullspace of Aᵀ. Say it: “u sub r plus 1”.
umu_{m} u m.
The last left singular vector. Say it: “u sub m”.
σr+1\sigma_{r+1} sigma r plus 1.
The first diagonal entry of Σ after the rank: zero. Say it: “sigma sub r plus 1”.

Tap or click a symbol in a formula to see the same explanation. All symbols: symbols and notation.

Words on this page

Show the 32 words used here

New here

singular value decomposition.
Writing any matrix as A = UΣVᵀ: a rotation (perhaps with a reflection), a stretching along perpendicular axes, and another rotation.

Also used

SVD.
Short for singular value decomposition, which writes any matrix as a rotation, a stretching and another rotation (reflections allowed).
factorization.
Writing something, such as a number, a matrix or an operator, as a product of simpler pieces. Explained in Factorization into A = LU.
matrix.
A rectangular table of numbers, which acts on vectors to give new ones and so describes a linear change of coordinates. Explained in Planes through three points, and matrices.
p..
Page, in a reference to a source; pp. means pages, as in pp. 3–5.
orthogonal matrix.
A square matrix whose columns are perpendicular unit vectors; it rotates or reflects without changing lengths, and its inverse is its transpose. Explained in Orthogonal matrices and Gram–Schmidt.
diagonal.
In a square matrix, the entries running from the top left corner to the bottom right; a diagonal matrix has zeros everywhere else. Explained in The four fundamental subspaces.
symmetric.
Unchanged by some swap, reflection or turn; for an expression in two quantities, unchanged when they are exchanged. Explained in Introduction to Fourier series.
positive definite.
Of a symmetric matrix or quadratic form: always giving a positive value for any nonzero input; equivalently, all its eigenvalues are positive. Explained in Symmetric matrices and positive definiteness.
orthonormal.
Of a set of vectors: each has length one and each is at right angles to all the others. Explained in Projection matrices and least squares.
eigenvector.
A non-zero vector that a matrix only stretches or shrinks without turning: multiplying it by the matrix gives a number times the same vector. Explained in Linear systems with constant coefficients: eigenvalues and eigenvectors.
eigenvalue.
A number λ for which a matrix turns some non-zero vector into λ times that vector, only stretching or shrinking it. Explained in Linear systems with constant coefficients: eigenvalues and eigenvectors.
orthogonal.
At right angles; more generally, of two vectors or functions, having a dot product, or an integral of their product, of zero. Explained in Introduction to Fourier series.
row space.
All the vectors that can be made by combining the rows of a matrix; it is the column space of its transpose. Explained in Matrix multiplication and inverse matrices.
column space.
All the vectors made by combining the columns of a matrix; Ax = b can be solved exactly when b lies in it. Explained in Matrix multiplication and inverse matrices.
vector.
A list of numbers written as a column, or more generally anything that can be added and multiplied by numbers. Explained in Orthogonal vectors and subspaces.
Gram–Schmidt.
A step-by-step method that turns independent vectors into perpendicular unit vectors that span the same space. Explained in Orthogonal matrices and Gram–Schmidt.
basis.
A set of independent vectors from which every vector in a space can be built, in exactly one way, as a combination. Explained in Independence, basis and dimension.
orthonormal basis.
A set of basis vectors that are all at right angles to each other and all of length one. Explained in Basis vectors, the metric and 4-momentum.
nullspace.
All the vectors x that a matrix sends to zero, that is, all solutions of Ax = 0. Explained in Column space and nullspace.
left nullspace.
The nullspace of the transpose of a matrix: all the combinations of its rows that give zero. Explained in The four fundamental subspaces.
invertible.
Of a square matrix or operator: having an inverse that undoes it; for a matrix this happens exactly when its determinant is not zero. Explained in The geometry of linear equations.
rank.
The number of independent columns of a matrix, which always equals the number of independent rows. Explained in Similar matrices and the Jordan form.
perpendicular.
At right angles to a line, a surface or another direction. Explained in Inclined planes.
trace.
The sum of the numbers on the main diagonal of a square matrix; it equals the sum of the eigenvalues. Explained in Linear systems with constant coefficients: eigenvalues and eigenvectors.
four fundamental subspaces.
The column space, nullspace, row space and left nullspace of a matrix, whose dimensions are all fixed by its rank. Explained in The four fundamental subspaces.
dimension.
The number of vectors in any basis of a vector space or subspace. Explained in Independence, basis and dimension.
rank one.
Of a matrix: having rank exactly one, so it is a column times a row and every column is a multiple of one column. Explained in Matrix spaces, rank one and small-world graphs.
determinant.
A single number worked out from a square array of numbers (a matrix), which measures how the matrix stretches areas or volumes. Explained in Determinants and the cross product.
singular value.
One of the stretching factors of a matrix in its singular value decomposition; the square roots of the eigenvalues of AᵀA.

Academic

transcript.
A written record of exactly what was said in a recorded lecture, word for word.
drops out.
Disappears from an equation, usually because it cancels or appears on both sides.

Tap or click a word, here or in the text, for its meaning in this lesson. All words: the glossary. How many words are marked in the text: Reading options (the “Aa” button).

Where this leads

In cosmology

Pages that build on this

Practise

Check your understanding

  1. How are the vectors viv_i in A=UΣVTA = U\Sigma V^T found?
  2. ATAA^TA has eigenvalues 4949 and 44. What are the singular values of AA?
  3. A 2×22 \times 2 matrix of rank one. How many nonzero singular values does it have?
  4. Which subspace do ur+1,…,umu_{r+1}, \dots, u_m span?
0 of 4 answered

Flashcards

1 / 3