CalcPath
ProgressProblem setsFeedback
← Question sheet

Linear Algebra · Solutions

The Singular Value Decomposition

12 questions · about 105 minutes

Work this sheet on paper, showing every step — the solutions give the full method so you can check your route, not only your final matrix. Name each result you use (“by the Spectral Theorem”, “by Eckart–Young”, “by the four-subspaces theorem”, “by the Penrose conditions”), and whenever you write down a singular vector say which formula or which null space produced it. No calculator is needed anywhere: every number on this sheet is an integer, a fraction or a surd. Full worked solutions are on a separate page, and each question has its own reveal so you can check one answer without seeing the rest.

  1. 1.Computation

    Find the singular values of each matrix exactly. In each case say which Gram matrix you diagonalised and why that one, and give one independent arithmetic check on your answer (a trace identity or a determinant identity).

    1. (a)A=(1−1​11​). What does A do to the unit circle?
    2. (b)B=(10​21​). Compare the singular values with the eigenvalues of B and comment.
    3. (c)C=​122​244​​. Explain, before computing anything, how many singular values must be zero.

    Solution

    (a) Diagonalise ATA. Both Gram matrices are 2×2, so either will do; take ATA:

    ATA=(11​−11​)(1−1​11​)=(20​02​).

    Both eigenvalues are 2, so σ1​=σ2​=2​. Every direction is stretched by the same factor: indeed 2​1​A is the rotation matrix through −45∘, so A is 2​ times a rotation and sends the unit circle to a circle of radius 2​. Check: σ1​σ2​=2=∣detA∣=∣1⋅1−1⋅(−1)∣. ✓

    (b) A shear. BTB=(12​01​)(10​21​)=(12​25​), with trace 6 and determinant 1, so the characteristic polynomial is λ2−6λ+1 and

    λ=3±22​=(2​±1)2.

    Hence σ1​=2​+1 and σ2​=2​−1. Two checks: σ1​σ2​=2−1=1=∣detB∣ ✓, and σ12​+σ22​=(3+22​)+(3−22​)=6=12+22+02+12=tr(BTB) ✓.

    Note that both eigenvalues of B are 1, while its singular values are about 2.41 and 0.41. Singular values are the absolute eigenvalues only for symmetric matrices, and a shear is the standard counterexample.

    (c) Rank one, so only one singular value is nonzero. C is 3×2, so CTC is 2×2 and is the smaller Gram matrix:

    CTC=(12​24​24​)​122​244​​=(918​1836​).

    Its determinant is 324−324=0 and its trace is 45, so the eigenvalues are 45 and 0: σ1​=45​=35​, σ2​=0. This had to happen: the second column of C is twice the first, so rankC=1 and exactly one singular value is nonzero. Check: σ12​=45=1+4+4+16+4+16, the sum of the squares of all six entries. ✓

  2. 2.Sketch

    Let A=(2−2​11​). A sketch with no singular values written beside it earns nothing here: every feature you draw must be justified by a computation.

    1. (a)Find the singular values and the right singular vectors of A. Explain why, for this particular matrix, the images of e1​ and e2​ are the semi-axes of the image ellipse, and find the unit vectors u1​,u2​ along those axes.
    2. (b)On one pair of axes sketch the unit circle and its image under A. Mark e1​ and e2​ on the circle and their images on the ellipse, draw both axes of the ellipse, and state whether A preserves or reverses orientation and how you know.
    3. (c)Verify that the image of w=2​1​(1,1) lies on your ellipse by writing Aw in the frame {u1​,u2​} and checking the ellipse equation, and check the area of the ellipse against ∣detA∣.

    Solution

    (a) Singular values and right singular vectors.

    ATA=(21​−21​)(2−2​11​)=(80​02​).

    The Gram matrix is already diagonal, so its unit eigenvectors are v1​=e1​ (eigenvalue 8) and v2​=e2​ (eigenvalue 2), and σ1​=22​, σ2​=2​. By the ellipsoid theorem the semi-axes of the image ellipse are Avi​, and here those are the images of the standard basis vectors: Ae1​=(2,−2), of length 22​=σ1​ ✓, and Ae2​=(1,1), of length 2​=σ2​ ✓. The axis directions are u1​=Av1​/σ1​=2​1​(1,−1) and u2​=Av2​/σ2​=2​1​(1,1), which are perpendicular, as they must be.

    (b) The sketch. On one set of axes draw the unit circle and, on it, the points e1​=(1,0) and e2​=(0,1). The image is an ellipse centred at the origin, tilted 45∘: its long axis runs along the line y=−x and ends at ±(2,−2), its short axis runs along y=x and ends at ±(1,1). Mark (2,−2) as the image of e1​ and (1,1) as the image of e2​, and draw both axes of the ellipse as dashed lines through the origin. The ellipse should enclose the circle without touching it: the smallest stretch is σ2​=2​>1, so every point of the circle is pushed outward. Finally, since detA=2+2=4>0, orientation is preserved: travelling counterclockwise from e1​ to e2​ on the circle corresponds to travelling counterclockwise from (2,−2) (at angle −45∘) to (1,1) (at angle 45∘) on the ellipse.

    (c) Two checks. For w=2​1​(1,1), Aw=2​1​(3,−1). Its coordinates in the frame {u1​,u2​} are

    y1​=Aw⋅u1​=21​(3⋅1+(−1)(−1))=2,y2​=Aw⋅u2​=21​(3−1)=1,

    and σ12​y12​​+σ22​y22​​=84​+21​=1, so Aw lies on the ellipse ✓ (plot it at roughly (2.1,−0.7)). Area: πσ1​σ2​=π⋅22​⋅2​=4π, and the unit disc's area π scaled by ∣detA∣=4 is also 4π ✓.

  3. 3.Computation

    Let A=​211​121​​. Compute a full SVD A=UΣVT by hand. State the size of each factor before you start.

    1. (a)Find the singular values and an orthonormal set of right singular vectors, and write down V.
    2. (b)Find u1​ and u2​ from the right singular vectors, then find the remaining column of U. Explain why that last column cannot come from the same formula as the first two, and check it is orthogonal to both.
    3. (c)Write down U, Σ and V with their correct shapes, verify two entries of UΣVT against A, and write A in outer product form.

    Solution

    Sizes. A is 3×2, so U is 3×3, Σ is 3×2 and V is 2×2.

    (a) Singular values and V. The smaller Gram matrix is ATA (2×2):

    ATA=(21​12​11​)​211​121​​=(65​56​).

    Trace 12, determinant 36−25=11, so λ2−12λ+11=(λ−11)(λ−1): λ1​=11, λ2​=1, and σ1​=11​, σ2​=1. Both are nonzero, so r=2: full column rank.

    For λ=11, ATA−11I=(−55​5−5​) forces x=y, so v1​=2​1​(1,1). For λ=1, (55​55​) forces x=−y, so v2​=2​1​(1,−1). Thus V=2​1​(11​1−1​). Check: σ12​+σ22​=12=4+1+1+4+1+1, the sum of squared entries of A. ✓

    (b) Left singular vectors from the formula, then one from the null space.

    u1​=σ1​Av1​​=11​1​⋅2​1​​332​​=22​1​​332​​,u2​=σ2​Av2​​=2​1​​1−10​​.

    (Norm check on u1​: 9+9+4=22 ✓.) The formula ui​=Avi​/σi​ produces only r=2 vectors, and there is no v3​ at all, since V is 2×2; the third column of U carries no information about A beyond being orthogonal to the first two, which is exactly the statement that it spans NullAT. Solve ATu=0:

    2x+y+z=0,x+2y+z=0.

    Subtracting gives x=y, and then 3x+z=0, so z=−3x: u3​=11​1​(1,1,−3). Orthogonality check: u1​⋅u3​∝3+3−6=0 ✓ and u2​⋅u3​∝1−1+0=0 ✓.

    (c) Assemble, check, reduce. Σ has the shape of A, a 2×2 diagonal block with a zero row beneath:

    U=​3/22​3/22​2/22​​1/2​−1/2​0​1/11​1/11​−3/11​​​,Σ=​11​00​010​​,V=2​1​(11​1−1​).

    Entry (1,1) of UΣVT is ∑i​σi​u1i​v1i​=11​⋅22​3​⋅2​1​+1⋅2​1​⋅2​1​=23​+21​=2=A11​ ✓. Entry (3,2) is 11​⋅22​2​⋅2​1​+1⋅0⋅(−2​1​)=1=A32​ ✓.

    The reduced SVD drops u3​ and the zero row of Σ; in outer product form,

    A=11​u1​v1T​+1⋅u2​v2T​=21​​332​332​​+21​​1−10​−110​​=​211​121​​=A. ✓

  4. 4.Computation

    A 3×4 matrix is given in outer product form,

    A=3u1​v1T​+u2​v2T​,u1​=31​​122​​, u2​=31​​21−2​​, v1​=21​​1111​​, v2​=21​​1−11−1​​.

    Do not multiply out the entries of A at any point; everything asked can be read off the factorisation.

    1. (a)State rankA and the dimension of each of the four fundamental subspaces, and write down orthonormal bases for ColA and RowA. Say what you checked to be sure the given expression is a legitimate SVD.
    2. (b)Find orthonormal bases for NullAT and NullA.
    3. (c)Compute Ax for x=(1,1,1,1) and for x=(1,0,−1,0). Then decide whether Ay=b is solvable for b=(0,0,3) and for b=(3,6,6), giving a solution when one exists.

    Solution

    (a) Dimensions and the two easy bases. First confirm this really is an SVD in outer product form: u1​⋅u2​=91​(2+2−4)=0, v1​⋅v2​=41​(1−1+1−1)=0, and all four vectors have unit length (91​(1+4+4)=1, 91​(4+1+4)=1, 41​⋅4=1). The weights 3>1>0 are decreasing, so σ1​=3, σ2​=1 and rankA=2.

    By the four-subspaces theorem: ColA=span{u1​,u2​}⊆R3 has dimension 2; NullAT has dimension m−r=1; RowA=span{v1​,v2​}⊆R4 has dimension 2; NullA has dimension n−r=2. The listed u's and v's are already orthonormal bases of the column and row spaces.

    (b) The two null spaces. NullAT is the orthogonal complement of ColA in R3, so it is spanned by any vector perpendicular to u1​ and u2​; the cross product (1,2,2)×(2,1,−2)=(−4−2, 4+2, 1−4)=(−6,6,−3) works, and normalising gives

    u3​=31​(2,−2,1).

    Check: u1​⋅u3​=91​(2−4+2)=0 ✓, u2​⋅u3​=91​(4−2−2)=0 ✓.

    NullA is the orthogonal complement of RowA in R4: x⊥v1​,v2​ means x1​+x2​+x3​+x4​=0 and x1​−x2​+x3​−x4​=0. Adding and subtracting, x1​+x3​=0 and x2​+x4​=0, so

    v3​=2​1​(1,0,−1,0),v4​=2​1​(0,1,0,−1),

    which are orthogonal to each other and to v1​,v2​ ✓. (Any orthonormal basis of this plane is acceptable — it is the repeated singular value 0 leaving the choice free.)

    (c) Using the factorisation directly. x=(1,1,1,1)=2v1​, and v1​⊥v2​, so

    Ax=2(3u1​(v1T​v1​)+u2​(v2T​v1​))=6u1​=(2,4,4).

    x=(1,0,−1,0)=2​v3​ lies in NullA, so Ax=0: both v1T​x and v2T​x vanish.

    Ay=b is solvable exactly when b∈ColA, i.e. when b⊥NullAT, because ColA=(NullAT)⊥. For b=(0,0,3): b⋅u3​=3⋅31​=1=0, so no solution exists. For b=(3,6,6)=9u1​: it lies in ColA, and since Av1​=3u1​, the vector y=3v1​=23​(1,1,1,1) is a solution. It is not the only one — add anything in NullA — but it is the one of smallest norm, being the one in RowA.

  5. 5.Proof

    Let A be a real m×n matrix of rank r with singular values σ1​≥⋯≥σr​>0. You may quote ∥A∥2​=σ1​, ∥A∥F2​=σ12​+⋯+σr2​, and the definition of the spectral norm as a maximum of ∥Ax∥/∥x∥.

    1. (a)Prove that ∥A∥2​≤∥A∥F​≤r​∥A∥2​, and determine exactly which matrices make each inequality an equality.
    2. (b)Prove from the definition that ∥AB∥2​≤∥A∥2​∥B∥2​ whenever the product is defined, and give a 2×2 example in which the inequality is strict.
    3. (c)Prove that an n×n matrix is orthogonal if and only if all n of its singular values equal 1. Deduce ∥Q∥2​ and ∥Q∥F​ for an orthogonal Q, and give an example showing that ∥A∥2​=1 alone does not make A orthogonal.

    Solution

    (a) The sandwich. Every σi2​ is positive, so

    ∥A∥22​=σ12​≤σ12​+σ22​+⋯+σr2​=∥A∥F2​,

    and since σi​≤σ1​ for each i,

    ∥A∥F2​=i=1∑r​σi2​≤rσ12​=r∥A∥22​.

    Taking square roots gives ∥A∥2​≤∥A∥F​≤r​∥A∥2​. The left inequality is an equality exactly when σ22​+⋯+σr2​=0, i.e. when r≤1: rank-one matrices and the zero matrix. The right inequality is an equality exactly when σi​=σ1​ for every i≤r: all nonzero singular values equal. Orthogonal matrices, and more generally scalar multiples of matrices with orthonormal columns, are the examples. ■

    (b) Submultiplicativity. The definition of ∥A∥2​ as a maximum gives ∥Ay∥≤∥A∥2​∥y∥ for every y (trivially when y=0). Apply it twice: for any x=0,

    ∥ABx∥=∥A(Bx)∥≤∥A∥2​∥Bx∥≤∥A∥2​∥B∥2​∥x∥.

    Divide by ∥x∥ and take the maximum over x: ∥AB∥2​≤∥A∥2​∥B∥2​. ■

    Strictness: A=diag(1,0) and B=diag(0,1) each have spectral norm 1, but AB=0 has norm 0<1⋅1. The direction B stretches most is the direction A kills.

    (c) Orthogonal matrices are exactly the matrices with all singular values 1. If Q is orthogonal then QTQ=In​, whose eigenvalues are all 1, so every singular value of Q is 1​=1. Conversely, if A is n×n with all n singular values equal to 1, then r=n and Σ=In​, so the SVD reads A=UIn​VT=UVT, a product of orthogonal matrices and hence orthogonal ((UVT)T(UVT)=VUTUVT=VVT=I). ■

    Consequently ∥Q∥2​=1 and ∥Q∥F​=1+⋯+1​=n​, which is the right-hand equality case of (a) with r=n. The converse of the first claim fails: A=diag(1,0) has ∥A∥2​=σ1​=1 but is singular. The spectral norm reports only the largest stretch and is silent about the others; orthogonality is a statement about all of them.

  6. 6.Computation

    Condition numbers throughout are in the 2-norm, κ(A)=σ1​/σn​. Give every value exactly.

    1. (a)Find κ(B) for the shear B=(10​21​), and use the rule of thumb to say how many decimal digits solving Bx=b can lose. Cross-check your value against ∥B∥2​∥B−1∥2​.
    2. (b)Let A be invertible. Prove that κ(ATA)=κ(A)2 and κ(A−1)=κ(A), and state the practical consequence of the first identity for solving least-squares problems through the normal equations.
    3. (c)Compute κ(E) and κ(D) for E=(10.999​0.9991​) and D=1000I2​, compare each with its determinant, and explain what the comparison shows. Then exhibit a b and a δb for which the error amplification bound for E is attained exactly, showing the ratio.

    Solution

    (a) The shear. BTB=(12​25​) has eigenvalues 3±22​=(2​±1)2, so σ1​=2​+1 and σ2​=2​−1 and

    κ(B)=2​−12​+1​=(2​−1)(2​+1)(2​+1)2​=(2​+1)2=3+22​≈5.83.

    The rule of thumb says a condition number near 10k costs about k digits; log10​5.83≈0.77, so solving Bx=b loses less than one decimal digit. Cross-check: ∥B−1∥2​=1/σ2​=2​+1, and indeed B−1=(10​−21​) is another shear with the same Gram eigenvalues, so ∥B∥2​∥B−1∥2​=(2​+1)2 ✓.

    (b) Squaring and inverting. From A=UΣVT, ATA=VΣTΣVT=VΣn2​VT, which is an orthogonal diagonalisation of a symmetric positive definite matrix; its eigenvalues σi2​ are positive, and for a symmetric positive definite matrix the eigenvalues are the singular values (the orthogonal diagonalisation is itself an SVD). Hence

    κ(ATA)=σn2​σ12​​=κ(A)2.

    Likewise A−1=VΣ−1UT is an SVD of A−1 up to reordering, with singular values 1/σn​≥⋯≥1/σ1​, so κ(A−1)=1/σ1​1/σn​​=κ(A). Practical consequence: forming the normal equations ATAx=ATb to solve a least-squares problem squares the condition number, so a matrix that loses 4 digits loses 8 once squared. This is why least-squares software works with A directly (via QR or the SVD) rather than with ATA.

    (c) Determinant versus conditioning, and attainment. E is symmetric with eigenvalues 1±0.999, namely 1.999 and 0.001, both positive, so those are its singular values and

    κ(E)=0.0011.999​=1999,detE=1−0.9992=0.001999.

    D=1000I has both singular values 1000, so κ(D)=1 while detD=106. The larger determinant belongs to the perfectly conditioned matrix and the tiny determinant to the badly conditioned one, but that is a coincidence of scale, not a rule: 10001​I has determinant 10−6 and is also perfectly conditioned. The determinant is the product of the singular values and confuses overall size with the spread between directions; the condition number is a ratio and sees only the spread. Solving Ex=b can lose about log10​1999≈3.3 digits.

    Attainment: the eigenvectors of E are 2​1​(1,1) for 1.999 and 2​1​(1,−1) for 0.001, and for a symmetric positive definite matrix these serve as both left and right singular vectors. Take b=(1,1), so x=E−1b=1.9991​(1,1), and perturb along the weak direction, δb=(t,−t), so δx=E−1δb=0.0011​(t,−t)=1000(t,−t). Then

    ∥x∥∥δx∥​=2​/1.9991000t2​​=1999t,∥b∥∥δb∥​=2​t2​​=t,

    so the ratio is exactly 1999=κ(E) ✓. With t=0.001, a 0.1% error in b becomes a 199.9% error in x: the computed solution is worse than useless.

  7. 7.Computation

    The matrix A=​211​121​​ has singular values σ1​=11​, σ2​=1, with u1​=22​1​(3,3,2), v1​=2​1​(1,1), u2​=2​1​(1,−1,0) and v2​=2​1​(1,−1). (You may take these as given, or check them.)

    1. (a)Write down the best rank-one approximation A1​, verify directly that it has rank one, compute A−A1​, and find ∥A−A1​∥2​ and ∥A−A1​∥F​ both from the singular values and directly from the entries.
    2. (b)A student proposes instead B=​200​100​​, arguing that keeping the largest row is a rank-one approximation. Compute ∥A−B∥F​ and a lower bound for ∥A−B∥2​, compare with (a), and name the theorem that guarantees the outcome.
    3. (c)A 40×30 matrix has singular values 8,6,3,2,1 and all others zero. Find the smallest k for which Ak​ retains at least 90% of ∥A∥F2​, give ∥A−Ak​∥ in both norms for that k, and compare the storage of Ak​ with that of the full matrix.

    Solution

    (a) The truncation.

    A1​=σ1​u1​v1T​=11​⋅22​1​​332​​⋅2​1​(1​1​)=44​11​​​332​332​​=21​​332​332​​,

    since 44​=211​. Its rank is one (every column is a multiple of (3,3,2)). The error is

    A−A1​=​1/2−1/20​−1/21/20​​=σ2​u2​v2T​,

    as the truncation lemma promises. Hence ∥A−A1​∥2​=σ2​=1 and ∥A−A1​∥F​=σ22​​=1. Direct check of the Frobenius value from the entries: 4⋅41​=1, so ∥A−A1​∥F​=1 ✓. The two norms agree because the error matrix has rank one.

    (b) Deleting rows is not the same as truncating. B has rank one, so it is a legitimate competitor. The error is

    A−B=​011​021​​,∥A−B∥F​=0+0+1+4+1+1​=7​≈2.65>1.

    For the spectral norm a lower bound suffices: ∥A−B∥2​≥∥(A−B)e2​∥=∥(0,2,1)∥=5​>1. So B is worse than A1​ in both norms. The Eckart–Young theorem says this was inevitable: no matrix of rank at most 1 can come closer to A than σ2​=1 in either norm. The best rank-k approximation zeroes the small singular values, which touches every entry of A; zeroing entries, rows or columns is a different and inferior operation.

    (c) Choosing k from an energy target. Squares: 64,36,9,4,1, total ∥A∥F2​=114. Cumulative fractions:

    11464​≈0.561,114100​≈0.877,114109​≈0.956.

    The first to reach 0.90 is at k=3, and k=2 falls short at 87.7%, so k=3 is the smallest. The errors are ∥A−A3​∥2​=σ4​=2 and ∥A−A3​∥F​=σ42​+σ52​​=4+1​=5​. Check: 109+5=114 ✓, the Pythagorean split of the Frobenius norm.

    Storage: the rank-3 truncation needs k(m+n+1)=3(40+30+1)=213 numbers against 40⋅30=1200 for the matrix itself, a ratio of 1200/213≈5.6, so about 18% of the original.

  8. 8.Proof

    Throughout, A is m×n of rank r and σj​(A) denotes its j-th singular value, with the convention σj​(A)=0 for j>r. Quote the Eckart–Young theorem in the form

    σk+1​(A)=min{∥A−B∥2​: rankB≤k},0≤k<min(m,n),

    together with the truncation lemma ∥A−Ak​∥2​=σk+1​. (The edge cases k=0 and k≥r are immediate and you should say why.)

    1. (a)Let E be any m×n matrix. Prove that σk+1​(A+E)≤σk+1​(A)+∥E∥2​, and deduce that ∣σj​(A+E)−σj​(A)∣≤∥E∥2​ for every j. Explain in a sentence why this inequality is what makes numerical rank a meaningful quantity.
    2. (b)Prove that ∥A∥F2​=∥Ak​∥F2​+∥A−Ak​∥F2​ for every 1≤k≤r, and describe the geometric content of the identity.
    3. (c)Let A be n×n and invertible. Prove that the spectral-norm distance from A to the nearest singular matrix is exactly σn​, exhibit a singular matrix at that distance, and deduce that κ(A)=∥A∥2​/dist(A,singular). What is the distance for the shear (10​21​)?

    Solution

    Edge cases first. For k=0 the only matrix of rank 0 is B=0 and ∥A∥2​=σ1​, so the formula holds. For k≥r the choice B=A is allowed and gives distance 0=σk+1​. For 1≤k<r it is the theorem as stated.

    (a) Singular values move by at most the size of the perturbation. Since Ak​ has rank at most k, it is an admissible B for the matrix A+E, so

    σk+1​(A+E)≤∥(A+E)−Ak​∥2​≤∥A−Ak​∥2​+∥E∥2​=σk+1​(A)+∥E∥2​,

    using the triangle inequality for the spectral norm (which holds because ∥(X+Y)x∥≤∥Xx∥+∥Yx∥ for every x) and then the truncation lemma. Now exchange roles: A=(A+E)+(−E) and ∥−E∥2​=∥E∥2​, so the same argument gives σk+1​(A)≤σk+1​(A+E)+∥E∥2​. Together, with j=k+1,

    ∣σj​(A+E)−σj​(A)∣≤∥E∥2​for every j. ■

    This is what makes numerical rank meaningful: if the data carry noise of size ∥E∥2​, every singular value of the measured matrix lies within ∥E∥2​ of the corresponding singular value of the true matrix, so a singular value far above the noise level is genuine and one below it cannot be distinguished from zero. Pivots in row reduction satisfy no such inequality, which is why they cannot be trusted to measure rank on measured data.

    (b) Pythagoras for the truncation. The expressions Ak​=∑i≤k​σi​ui​viT​ and A−Ak​=∑i>k​σi​ui​viT​ are each of SVD form (orthonormal u's, orthonormal v's, decreasing positive weights), so by the uniqueness theorem their singular values are σ1​,…,σk​ and σk+1​,…,σr​ respectively. The Frobenius formula then gives

    ∥Ak​∥F2​+∥A−Ak​∥F2​=i≤k∑​σi2​+k<i≤r∑​σi2​=i≤r∑​σi2​=∥A∥F2​. ■

    The geometric content: under the inner product ⟨X,Y⟩=tr(XTY), whose norm is the Frobenius norm, Ak​ and A−Ak​ are orthogonal — indeed AkT​(A−Ak​)=∑i≤k​∑j>k​σi​σj​vi​(uiT​uj​)vjT​=0 because uiT​uj​=0 for i=j. Truncation is an orthogonal projection of A onto the span of its first k outer products, and Pythagoras follows.

    (c) The condition number is a relative distance to singularity. An n×n matrix is singular exactly when its rank is at most n−1. Apply Eckart–Young with k=n−1 (legitimate, as r=n):

    dist(A,singular)=min{∥A−B∥2​:rankB≤n−1}=σn​,

    attained by B=An−1​=A−σn​un​vnT​, which is singular. Therefore

    κ(A)=σn​σ1​​=dist(A,singular)∥A∥2​​. ■

    A matrix is ill-conditioned precisely when it is close to a singular matrix relative to its own size, which is why scaling by a constant changes nothing. For the shear B=(10​21​), with σ2​=2​−1, there is a singular matrix within spectral distance 2​−1≈0.41, and none closer.

  9. 9.Critique

    A student is asked for A+b with A=(12​24​) and b=(5,0), and writes the following.

    Step 1. b is not a multiple of (1,2), so Ax=b has no solution and I look for a least-squares solution instead.

    Step 2. The least-squares solutions are the x with Ax=p, where p is the projection of b onto ColA=span{(1,2)}. With a=(1,2), p=a⋅ab⋅a​a=55​(1,2)=(1,2).

    Step 3. Ax=(1,2) reduces to the single equation x1​+2x2​=1, whose solutions are (1−2t,t) for any t.

    Step 4. By the Penrose conditions A+ is unique, so the least-squares solution is unique. Taking t=0 gives A+b=(1,0).

    Exactly one step contains an error, and the final answer is wrong.

    1. (a)Identify the erroneous step. State precisely which two things are being confused, and say in words which of the vectors (1−2t,t) the pseudoinverse actually returns. Find it by minimising along the line.
    2. (b)Compute A+ from an SVD of A and hence A+b. Check that your answer is a least-squares solution and compare its norm with the student's answer.
    3. (c)The student adds: “As a check, AA+ should equal I.” Explain why it will not, compute AA+, and identify the matrix you get.

    Solution

    (a) The error is in Step 4. Steps 1 to 3 are correct: (5,0) is not a multiple of (1,2); the projection formula onto a line is applied correctly, with b⋅a=5 and a⋅a=5; and the solution set of x1​+2x2​=1 is indeed the line (1−2t,t).

    Step 4 confuses two different uniqueness statements. The Penrose conditions say that the matrix A+ is unique. They say nothing about least-squares solutions being unique, and here they are not: NullA=span{(−2,1)} is a line, so every minimiser can be shifted along it without changing Ax, which is exactly what Step 3 found. The least-squares theorem for the pseudoinverse says which minimiser A+b is: the one of smallest norm, equivalently the unique minimiser lying in RowA=span{(1,2)}. Choosing t=0 picked an arbitrary point of the line, not the closest one to the origin.

    Minimising along the line: ∥(1−2t,t)∥2=1−4t+5t2, with derivative −4+10t, zero at t=52​. So the correct value is (1−54​,52​)=(51​,52​), which is indeed a multiple of (1,2) ✓.

    (b) The pseudoinverse from an SVD. ATA=(510​1020​) has trace 25 and determinant 0, so λ1​=25, λ2​=0: σ1​=5, r=1. (The full-column-rank formula (ATA)−1AT is unavailable, which is presumably why the student avoided it.) The eigenvector for 25 satisfies −20x+10y=0, i.e. y=2x, so v1​=5​1​(1,2) and

    u1​=σ1​Av1​​=51​⋅5​1​(510​)=5​1​(12​).

    Then

    A+=σ1​1​v1​u1T​=51​⋅51​(12​24​)=251​(12​24​),A+b=251​(510​)=(1/52/5​),

    agreeing with (a). Check it is a least-squares solution: Ax^=(51​+54​,52​+58​)=(1,2)=p ✓, and the residual b−p=(4,−2) is orthogonal to (1,2) since 4−4=0 ✓. Norms: ∥x^∥2=251​+254​=51​, against ∥(1,0)∥2=1 for the student's answer. Both fit the data equally well; only one is the pseudoinverse solution.

    (c) AA+ is a projection, not the identity. AA+=I would force ColA=R2, i.e. full row rank, and A has rank 1. Computing,

    AA+=(12​24​)⋅251​(12​24​)=251​(510​1020​)=51​(12​24​).

    This is symmetric and idempotent — (51​(12​24​))2=251​(510​1020​) is itself again — with column space span{(1,2)}: it is the orthogonal projection onto ColA, which is what AA+ always is (write AA+=UΣΣ+UT=∑i≤r​ui​uiT​). Applied to b it returns 51​(5,10)=(1,2)=p, the projection the student computed by hand in Step 2 ✓. The correct check for a matrix of this shape is the Penrose condition AA+A=A, not AA+=I.

  10. 10.Computation

    Four observations of two variables are recorded: (1,1), (2,4), (4,2), (5,5). Observations are rows, and m=4.

    1. (a)Centre the data, write the centred matrix X, and compute XTX and the sample covariance matrix C.
    2. (b)Find both principal components, the singular values of X, the variance explained by each component, and the fraction of total variance explained by the first.
    3. (c)Compute the scores of the four observations on the first component and verify that their sample variance equals the eigenvalue from (b). Then form the rank-one truncation X1​, add the mean back, describe geometrically where each point has gone, and check that ∥X−X1​∥F2​=σ22​.
    4. (d)Let X0​ be the raw (uncentred) matrix and xˉ the mean vector. Prove that X0T​X0​=XTX+mxˉxˉT, evaluate it for these data, and explain what an analysis that skips the centring would report and why it is misleading.

    Solution

    (a) Centre and form the covariance. Means: xˉ=41+2+4+5​=3, yˉ​=41+4+2+5​=3. Subtracting (3,3) from each row,

    X=​−2−112​−21−12​​,XTX=(4+1+1+44−1−1+4​4−1−1+44+1+1+4​)=(106​610​),C=m−11​XTX=31​(106​610​).

    The diagonal entries 310​ are the sample variances of the two variables and the off-diagonal 2 is their covariance.

    (b) Principal components. XTX has trace 20 and determinant 100−36=64, so λ2−20λ+64=(λ−16)(λ−4): eigenvalues 16 and 4, hence singular values of X are σ1​=4 and σ2​=2. For 16, −6x+6y=0 gives v1​=2​1​(1,1); for 4, 6x+6y=0 gives v2​=2​1​(1,−1). The variances explained are σi2​/(m−1): 316​ and 34​, whose sum 320​=trC ✓. The first component explains

    16+416​=0.8,

    so a single coordinate along the line y=x (through the mean) captures 80% of the spread.

    (c) Scores, and the reconstruction. The scores are Xv1​=2​1​(−4,0,0,4)=(−22​,0,0,22​). They have mean zero, so their sample variance is

    38+0+0+8​=316​=λ1​ ✓

    — the first-component-maximises-variance theorem in action. Since Xv1​=σ1​u1​, u1​=2​1​(−1,0,0,1), and the rank-one truncation is

    X1​=σ1​u1​v1T​=4⋅21​​−1001​​(1​1​)=​−2002​−2002​​.

    Adding the mean back, the reconstructed points are (1,1),(3,3),(3,3),(5,5): each original point has been dropped perpendicularly onto the line y=x. The residual is X−X1​, with rows (0,0),(−1,1),(1,−1),(0,0), so ∥X−X1​∥F2​=1+1+1+1=4=σ22​ ✓, which is the sum of the squared distances from the points to the line. That equality is Eckart–Young: no other line through the mean has a smaller total squared distance to the data.

    (d) What forgetting to centre does. Write 1 for the all-ones vector in Rm, so that X0​=X+1xˉT. Then

    X0T​X0​=XTX+XT1xˉT+xˉ1TX+xˉ(1T1)xˉT=XTX+mxˉxˉT,

    because XT1 is the vector of column sums of the centred matrix, which is 0, and 1T1=m. ■

    Here mxˉxˉT=4(99​99​), so X0T​X0​=(4642​4246​) (direct check from the raw rows: 1+4+16+25=46 and 1+8+8+25=42 ✓). Its eigenvalues are 46±42, namely 88 and 4, so the uncentred procedure reports a leading direction 2​1​(1,1) with “explained fraction” 9288​≈0.957 instead of the true 0.8. The extra term is rank one, points along the mean xˉ, and has eigenvalue m∥xˉ∥2=72 — it measures where the cloud sits, not how it varies, and it dominates whenever the mean is large compared with the spread. In this example the direction happened to survive only because xˉ=(3,3) lies along the genuine first component; move the data to have mean (3,−3) and the uncentred leading direction would swing to 2​1​(1,−1), the wrong axis entirely.

  11. 11.Computation

    Let A=(13​31​). Its polar decomposition is A=QS with Q orthogonal and S symmetric positive semidefinite.

    1. (a)Compute S=(ATA)1/2 by diagonalising ATA, then Q=AS−1. Verify that Q is orthogonal and that QS=A.
    2. (b)Compute an SVD of A, form Q=UVT and S=VΣVT, and confirm they agree with (a). Explain why the sign freedom in the singular vectors cannot change Q or S, and describe Q geometrically.
    3. (c)Prove that for an invertible A=QS, Q is a rotation (detQ=+1) if and only if detA>0, and classify the Q found above. Then show that ∥A−Q∥F​=∥Σ−I∥F​ and evaluate it, checking directly from the entries of A−Q.

    Solution

    (a) The stretch factor from a square root. A is symmetric, so ATA=A2=(1+93+3​3+39+1​)=(106​610​), with eigenvalues 10±6, namely 16 and 4, and eigenvectors 2​1​(1,1) and 2​1​(1,−1). The positive definite square root acts as 16​=4 and 4​=2 on those eigenspaces:

    S=4⋅21​(11​11​)+2⋅21​(1−1​−11​)=(31​13​).

    Check: S2=(9+13+3​3+31+9​)=(106​610​)=ATA ✓, and S is positive definite (eigenvalues 4,2). Since detS=8, S−1=81​(3−1​−13​) and

    Q=AS−1=81​(13​31​)(3−1​−13​)=81​(3−39−1​−1+9−3+3​)=(01​10​).

    QTQ=I ✓, and QS=(13​31​)=A ✓. Uniqueness of the polar factors of an invertible matrix says these are the factors.

    (b) The same factors from the SVD. Singular values are 16​=4 and 4​=2, with v1​=2​1​(1,1), v2​=2​1​(1,−1), and

    u1​=4Av1​​=42​1​(44​)=2​1​(11​),u2​=2Av2​​=22​1​(−22​)=2​1​(−11​).

    (The eigenvalue −2 of A has become the singular value 2, and the sign has moved into u2​=−v2​.) Then

    Q=UVT=u1​v1T​+u2​v2T​=21​(11​11​)+21​(−11​1−1​)=(01​10​),

    and S=VΣVT=4v1​v1T​+2v2​v2T​, which is the sum computed in (a). Both agree ✓. Sign choices cannot matter: replacing (ui​,vi​) by (−ui​,−vi​) leaves each product ui​viT​ and vi​viT​ unchanged, and if a singular value were repeated, ui​viT​ summed over its eigenspace would likewise be basis-independent.

    Geometrically Q swaps the coordinates: it is the reflection across the line y=x, not a rotation. So A is “stretch by 4 along (1,1) and by 2 along (1,−1), then reflect in the line y=x”.

    (c) Rotation or reflection, and the distance to Q. From A=QS, detA=detQdetS. The eigenvalues of S are the singular values σi​>0, so detS=σ1​⋯σn​>0, and detQ=±1 since Q is orthogonal. Hence detQ=+1 exactly when detA>0. ■ Here detA=1−9=−8<0, so detQ=−1 and Q is a reflection, in agreement with (b).

    For the distance, Q=UVT and orthogonal invariance of the Frobenius norm give

    ∥A−Q∥F​=∥UΣVT−UIVT∥F​=∥U(Σ−I)VT∥F​=∥Σ−I∥F​=(4−1)2+(2−1)2​=10​.

    Direct check: A−Q=(12​21​), whose entries square to 1+4+4+1=10 ✓. Since Q is the orthogonal matrix nearest to A, no orthogonal matrix lies within Frobenius distance 10​ of A.

  12. 12.Proof

    Let A=UΣVT be a full SVD of an m×n matrix of rank r, let b∈Rm, and write βi​=uiT​b for the coordinates of b in the basis u1​,…,um​. Write x^=A+b. This question is about truncated SVD regularisation: fixing a threshold ε>0, letting k be the number of singular values with σi​>ε, and using

    xε​=i=1∑k​σi​βi​​vi​

    in place of x^.

    1. (a)Show that x^=i=1∑r​σi​βi​​vi​. Deduce that if b is replaced by b+δb then x^ changes by at most ∥δb∥/σr​, and identify a δb for which this is an equality.
    2. (b)Prove that xε​=Ak+​b, where Ak​ is the rank-k truncation of A, and that a perturbation δb changes xε​ by less than ∥δb∥/ε, whatever the value of σr​.
    3. (c)Prove that ∥Axε​−b∥2=∥Ax^−b∥2+i=k+1∑r​βi2​. Then illustrate (a), (b) and (c) with A=(10​01/100​), b=(1,1), ε=101​ and δb=(0,1001​), computing every quantity exactly.

    Solution

    (a) The pseudoinverse solution, coordinate by coordinate. By definition A+=VΣ+UT=∑i≤r​σi−1​vi​uiT​, so

    x^=A+b=i=1∑r​σi​uiT​b​vi​=i=1∑r​σi​βi​​vi​.

    Each component of b along ui​ is divided by σi​: the smallest singular value is the largest amplifier. Replacing b by b+δb changes x^ by δx^=A+δb=∑i≤r​σi−1​(uiT​δb)vi​, and because the vi​ are orthonormal,

    ∥δx^∥2=i=1∑r​σi2​(uiT​δb)2​≤σr2​1​i=1∑r​(uiT​δb)2≤σr2​1​i=1∑m​(uiT​δb)2=σr2​∥δb∥2​,

    the last step being Parseval for the orthonormal basis u1​,…,um​ of Rm. So ∥δx^∥≤∥δb∥/σr​, with equality when δb is a multiple of ur​, since then only the i=r term survives and both inequalities are equalities. ■

    (b) The truncated solution is a pseudoinverse solution for Ak​. The truncation Ak​=∑i≤k​σi​ui​viT​ is written in SVD form with rank k, so its pseudoinverse, by the definition applied to that SVD, is Ak+​=∑i≤k​σi−1​vi​uiT​, and

    Ak+​b=i=1∑k​σi​βi​​vi​=xε​.

    (Uniqueness via the Penrose conditions guarantees this does not depend on which SVD of A we started from.) A perturbation now moves xε​ by Ak+​δb, and the computation of (a) with r replaced by k gives

    ∥Ak+​δb∥2=i=1∑k​σi2​(uiT​δb)2​≤ε21​i=1∑k​(uiT​δb)2≤ε2∥δb∥2​,

    because every retained σi​ exceeds ε. For δb=0 at least one of the two inequalities is strict: the first if some uiT​δb with i≤k is nonzero (as σi​>ε there), and otherwise the second, since then all of ∥δb∥2 sits in the omitted terms i>k. So the amplification is capped at 1/ε, a number chosen by the user, however tiny σr​ may be. ■

    (c) The price: a larger residual. Expand b=∑i≤m​βi​ui​. Since Avi​=σi​ui​,

    Ax^=i≤r∑​σi​βi​​σi​ui​=i≤r∑​βi​ui​,Axε​=i≤k∑​βi​ui​.

    The first is the projection of b onto ColA, as it should be. Subtracting from b and using orthonormality of the ui​,

    ∥Ax^−b∥2=i>r∑​βi2​,∥Axε​−b∥2=k<i≤r∑​βi2​+i>r∑​βi2​,

    and the difference is ∑k<i≤r​βi2​: exactly the part of b that lived in the discarded singular directions. ■ Regularisation trades a controlled amount of misfit (bias) for immunity to noise (variance).

    The example. A=diag(1,1001​) is its own SVD with U=V=I, σ1​=1, σ2​=1001​, r=2, and β=(1,1).

    By (a), x^=(11​,1/1001​)=(1,100), and δb=(0,1001​)=1001​u2​ gives δx^=(0,1): a perturbation of length 1001​ moved the solution by 1, which is ∥δb∥/σ2​ exactly, the equality case.

    With ε=101​ we have σ1​>ε>σ2​, so k=1 and xε​=(1,0). The same δb has u1T​δb=0, so xε​ does not move at all — comfortably within the cap ∥δb∥/ε=101​ from (b).

    Residuals: Ax^−b=(1,1)−(1,1)=0, while Axε​−b=(1,0)−(1,1)=(0,−1), of squared length 1=β22​, matching (c) with k=1, r=2. The regularised fit misses b by 1 in the direction it has chosen not to trust, and in exchange a 1% change in the data no longer produces a 100% change in the answer.

← Back to the question sheet

CalcPath·Free university mathematics

SubjectsProblem setsProgressFeedbackAbout