Computing an SVD in Full, Economy and Compact Forms
Unit 10, lesson 48
Computing an SVD in Full, Economy and Compact Forms
How to compute a singular value decomposition from a symmetric eigenvalue problem, complete orthonormal bases beyond the positive singular values, tell full, economy and compact SVDs apart, and check an answer by reconstruction.
Knowing that every real matrix factors as A=UΣV⊤ is not the same as finding the factors. Given only the entries of a 2×3 matrix, where do the perpendicular directions and the stretch factors come from, and how can you tell that a proposed answer is right? This lesson computes an SVD from a symmetric eigenvalue problem, completes the bases beyond the directions with positive singular values, compares the full, economy and compact forms on a rank-one example, and checks every answer by multiplying back.
Key terms
Singular values from a symmetric eigenproblem
Definition Let A be a real m×n matrix and q=min(m,n). The n×n matrix A⊤A is symmetric with x⊤A⊤Ax=∥Ax∥2≥0, so by the spectral theorem it has an orthonormal basis of eigenvectors v1,…,vn with eigenvalues λ1≥⋯≥λn≥0. The computation runs as follows. Find these eigenvalues and orthonormal eigenvectors in decreasing order of eigenvalue, and take the singular values σi=λi for i=1,…,q. Then, for every i with σi>0, set
ui=σi1Avi.
These vectors are automatically orthonormal, since ui⋅uj=σj2(vi⋅vj)/(σiσj), which is 1 for i=j and 0 otherwise. One may start from the m×m matrix AA⊤ instead, which has the same positive eigenvalues with the same multiplicities and is smaller when m<n. Its orthonormal eigenvectors for those eigenvalues give the ui, the partners are vi=A⊤ui/σi, and the remaining right singular vectors come from an orthonormal basis of NullA. Either way, the second vector of each pair is computed from the first, never found separately.
In plain words The squared stretch ∥Ax∥2=x⊤A⊤Ax is a quadratic form. Its principal axes are the right singular vectors, and the eigenvalue on each axis is the squared stretch along it, so the singular values are square roots of eigenvalues. Pushing each axis with a positive stretch through A and rescaling gives its partner in the output space.
Example Tuples such as (1,1,2) stand for column vectors on this page. Take
A=[100111],A⊤A=101011112.
Expanding det(tI−A⊤A) along the first row gives the characteristic polynomial
For the eigenvalue 3 the system (A⊤A−3I)x=0 reads −2x+z=0, −2y+z=0 and x+y−z=0, solved by (1,1,2). For the eigenvalue 1 the equations force z=0 and x+y=0, giving (1,−1,0), and for the eigenvalue 0 they are x+z=0 and y+z=0, giving (−1,−1,1). Normalizing,
Here q=2, so the singular values are σ1=3 and σ2=1. Then u1=Av1/3=(3,3)/18=21(1,1) and u2=Av2=21(1,−1). As a cross-check, the smaller matrix AA⊤ has rows (2,1) and (1,2) and eigenvalues 3 and 1.
Completing an orthonormal basis
Definition Let A be a real m×n matrix of rank r. The formula Avi/σi produces left singular vectors only for the r positive singular values, and it cannot be used when σi=0, because division by zero is undefined and the image Avi=0 points in no direction. A full SVD needs m left singular vectors. Completing the basis means extending u1,…,ur to an orthonormal basis u1,…,um of Rm, for instance by finding a basis of the orthogonal complement and applying Gram-Schmidt. The added vectors are perpendicular to span{u1,…,ur}=ColA, so they form an orthonormal basis of the left null space NullA⊤, which has dimension m−r. Any such choice works. On the input side nothing extra is needed, because the eigenvectors of A⊤A for the eigenvalue 0 already give an orthonormal basis vr+1,…,vn of NullA⊤A=NullA.
In plain words Directions that the map never reaches still need axes in the output space. You choose them freely, as long as they are perpendicular to everything the map does reach and to each other.
Example The transpose of the matrix above,
C=A⊤=101011,
has C⊤C with rows (2,1) and (1,2), eigenvalues 3 and 1, and orthonormal eigenvectors 21(1,1) and 21(1,−1). The partner formula gives 61(1,1,2) and 21(1,−1,0) in R3, but a full SVD needs a third left singular vector. It must be a unit vector perpendicular to both, so it spans NullC⊤, and 31(−1,−1,1) works, as does its negative. The roles of the two spaces have swapped compared with A, and the singular values 3 and 1 are the same.
Full SVD
Definition A full SVD of a real m×n matrix A is a factorization A=UΣV⊤ with U an m×m orthogonal matrix, Σ an m×n rectangular diagonal matrix with diagonal entries σ1≥⋯≥σq≥0 where q=min(m,n), and V an n×n orthogonal matrix. To build one, take the vi and σi from A⊤A, form ui=Avi/σi for the positive singular values, complete the left singular vectors to an orthonormal basis of Rm, and place the columns of U and V in the same order as the singular values on the diagonal of Σ. Because it keeps complete bases of both spaces, a full SVD of a matrix of rank r displays all four fundamental subspaces. The vectors u1,…,ur span ColA, the vectors ur+1,…,um span NullA⊤, the vectors v1,…,vr span RowA, and the vectors vr+1,…,vn span NullA.
In plain words The full form keeps every axis in both spaces, including the axes the map ignores. That makes U and V square and orthogonal, and it gives explicit bases for the kernel and for the output directions perpendicular to everything the map reaches.
Example The 3×2 matrix
B=000200
sends (x,y) to (2y,0,0). Its product B⊤B=diag(0,4) has eigenvalue 4 with eigenvector e2 and eigenvalue 0 with eigenvector e1. So σ1=2 with v1=e2, and σ2=0 with v2=e1, the larger value first. The partner of v1 is u1=Be2/2=(1,0,0). Completing with (0,1,0) and (0,0,1) gives U=I3, and
Σ=200000,V=[0110].
Here V⊤ swaps the two input coordinates, Σ doubles the first and zeroes the second, and U changes nothing, so UΣV⊤=B. The kernel of B is spanned by v2=e1 in R2, and the kernel of B⊤ is spanned by u2 and u3 in R3. Their dimensions, 1 and 2, differ because B is not square, so 2−1=3−1.
Economy and compact SVD
Definition Let A be a nonzero real m×n matrix of rank r with full SVD A=UΣV⊤, and let q=min(m,n). The economy SVD keeps the first q columns of U and of V,
A=UqΣqVq⊤,
with Uq of size m×q, Σq=diag(σ1,…,σq) of size q×q including any zero singular values, and Vq of size n×q. The compact SVD keeps only the positive singular values,
A=UrΣrVr⊤,
with Ur of size m×r, Σr=diag(σ1,…,σr) of size r×r, and Vr of size n×r. Both products equal A exactly, because the dropped columns of U and V meet only zero rows or zero columns of Σ. The rectangular factors have orthonormal columns, so Uq⊤Uq=Iq and Vr⊤Vr=Ir, but UqUq⊤ is not the identity when q<m. Books and software use these names differently, and some call one of the two forms reduced or thin, so check the sizes and whether zero singular values are kept.
In plain words The economy form drops the axes that have no diagonal slot in Σ, and the compact form also drops the axes with zero stretch. Nothing of the map is lost either way, because every dropped axis is a kernel direction or an output direction perpendicular to everything the map reaches.
Example For the rank-one matrix B above, m=3, n=2, q=2 and r=1.
Form
U
Σ
V
Full
3×3
3×2
2×2
Economy
3×2
2×2
2×2
Compact
3×1
1×1
2×1
The economy Σq=diag(2,0) keeps the zero singular value, with Uq having columns (1,0,0) and (0,1,0) and Vq=V. The compact form is Ur=(1,0,0), Σr=[2] and Vr=(0,1), and
UrΣrVr⊤=2100[01]=000200=B.
For the earlier 2×3 matrix A the rank and q are both 2, so its economy and compact forms coincide. The rank here counts singular values that are exactly positive. Treating a tiny computed value as zero is a separate decision that should be stated.
Reconstruction check
Definition A proposed full SVD (U,Σ,V) of a real m×n matrix A is correct exactly when four things hold. The sizes are m×m, m×n and n×n. The equations U⊤U=Im and V⊤V=In hold. The matrix Σ is rectangular diagonal with entries σ1≥⋯≥σq≥0. Finally, the product UΣV⊤ equals A. Since V is invertible, the last condition is equivalent to AV=UΣ, that is,
Avi=σiuifor i≤q,Avi=0for q<i≤n.
Two matrices that agree on a basis agree everywhere, so checking these n products is enough. For an economy or compact form, make the same checks with the smaller sizes. The rectangular factors need orthonormal columns, and in the compact form every diagonal entry of Σ must be positive. When the kept V has fewer than n columns, those columns are not a basis of Rn, so agreement on them is not enough and the product has to be multiplied out. For the 2×3 matrix A of the first card, taking U=Σ=I2 and the columns e1 and e2 for V satisfies Avi=σiui for both columns, yet UΣV⊤ has rows (1,0,0) and (0,1,0) and is not A.
In plain words A list of plausible singular values is not an SVD. Check the shapes, check orthonormality, and multiply back. For a full SVD, testing the product on each column of V is often quicker than multiplying three matrices.
Example For A=[100111] with the factors found above, the sizes are 2×2, 2×3 and 3×3, and Σ has the decreasing diagonal 3,1. The columns of V are orthonormal, since the unnormalized vectors (1,1,2), (1,−1,0) and (−1,−1,1) have pairwise dot products 0 and were divided by their lengths, and the same holds for u1 and u2. The direct products are
so Av1=3u1, Av2=u2 and Av3=0, which are exactly the actions of UΣV⊤ on the same basis. Hence UΣV⊤=A.
Repeated singular values
Definition The singular values of a matrix are determined by the matrix, but its singular vectors are not. Replacing a pair (ui,vi) by (−ui,−vi) always gives another SVD. If a positive singular value σ occurs k>1 times, the matching right singular vectors may be any orthonormal basis of the eigenspace of A⊤A for σ2, with partners ui=Avi/σ. In a full SVD of a matrix of rank r, the vectors vr+1,…,vn may be any orthonormal basis of NullA, and ur+1,…,um any orthonormal basis of NullA⊤. What stays fixed is, for each distinct positive singular value, the subspace spanned by its right singular vectors and the subspace spanned by its left ones, together with the two kernels. When the positive singular values are distinct, each pair (ui,vi) with σi>0 is unique up to one common sign.
In plain words Two correct SVDs of the same matrix can look different. When positive stretch factors tie, any perpendicular axes inside the tied subspace will do, provided the input and output axes are chosen together.
Example For every 2×2 orthogonal matrix Q,
2I=Q(2I)Q⊤,
so U=V=Q and Σ=2I is an SVD of 2I for any choice of Q, for instance the rotation with columns (53,54) and (−54,53). With that rotation, choosing U=Q but V=I gives 2Q, which is not 2I, so the input and output axes must turn together. For the matrix B above, the completing vectors (0,1,0) and (0,0,1) could be replaced by 21(0,1,1) and 21(0,1,−1), another orthonormal basis of NullB⊤, without changing the product.
Check yourself
For the 2×3 matrix F with rows (0,0,0) and (0,0,−5), find the rank, a compact SVD, the sizes of the full, economy and compact factors, and bases of NullF and NullF⊤.
Show the answer
The product F⊤F=diag(0,0,25), so σ1=5 with v1=(0,0,1), and since q=2 the second singular value is σ2=0. The rank is 1. The partner is u1=Fv1/5=(0,−1), so the minus sign goes into u1 while the singular value stays positive. A compact SVD is Ur=(0,−1), Σr=[5] and Vr=(0,0,1), and indeed 5(0,−1)(0,0,1)⊤ has −5 in row 2, column 3 and zeros elsewhere.
The full factors are 2×2, 2×3 and 3×3, the economy factors 2×2, 2×2 and 3×2, and the compact factors 2×1, 1×1 and 3×1. The kernel of F is spanned by (1,0,0) and (0,1,0) in R3, and the kernel of F⊤ is spanned by (1,0) in R2.
Find a full SVD of the matrix below. Which step needs a choice?
G=110110Show the answer
The product G⊤G has all entries 2, with eigenvalues 4 and 0 and orthonormal eigenvectors v1=21(1,1) and v2=21(1,−1). So σ1=2 and σ2=0. The partner is u1=Gv1/2=21(1,1,0).
Apart from signs, the choice comes in completing U. The kernel of G⊤ is the plane y1+y2=0 in R3, and one orthonormal basis of it is u2=21(1,−1,0) and u3=(0,0,1). Then
The check works column by column, since Gv1=21(2,2,0)=2u1 and Gv2=0.
For A=[100111], a student keeps v1,v2,v3 and Σ from this page, but finds the left singular vectors separately as unit eigenvectors of AA⊤ and picks u1=21(1,1) and u2=21(−1,1). Both U and V are orthogonal. Is the result an SVD of A?
Show the answer
No. The vector 21(−1,1) is a legitimate unit eigenvector of AA⊤ for the eigenvalue 1, but it is the negative of Av2=21(1,−1), so the pair condition Av2=σ2u2 fails. Multiplying out gives
UΣV⊤=[011011]=A,
which swaps the first two columns of A. The shapes, the orthonormality and the singular values all pass, and only the reconstruction catches the error. The fix is to compute u2=Av2/σ2 from its partner.
May we count page visits to understand which courses and learning features are useful? Cloudflare collects visit and performance statistics, without your account details or answers. Your choice does not affect access. Details