Ran Wei/ Linear Algebra
中文
Linear Algebra · Spectra and data

Module 11Singular values and the pseudoinverse

Decompose rectangular maps into orthogonal directions, measure their sensitivity, and find minimum-norm solutions.

90 minYou need Modules 7, 8 and 10

In this module you will

  • Construct singular directions from the spectral theorem
  • Interpret singular values as stretch factors
  • Use a pseudoinverse for a minimum-norm least-squares solution
1

A rectangular map has two coordinate systems

A rectangular matrix sends inputs and outputs between different spaces. To find input directions that stretch independently, look at ATA.A^\mathsf TA\mathclose{\text{.}} It is symmetric and positive semidefinite because xTATAx=∥Ax∥2.\mathbf x^\mathsf TA^\mathsf TA\mathbf x=\|A\mathbf x\|^2\mathclose{\text{.}} Its orthonormal eigenvectors vi\mathbf v_i have nonnegative eigenvalues σi2.\sigma_i^2\mathclose{\text{.}} Arrange the square roots σi\sigma_i from largest to smallest. They are the singular values.

For each σi>0,\sigma_i>0\mathclose{\text{,}} take ui=Avi/σi.\mathbf u_i=A\mathbf v_i/\sigma_i\mathclose{\text{.}} These output directions have unit length and are mutually orthogonal, since (Avi)⋅(Avj)=σj2vi⋅vj.(A\mathbf v_i)\cdot(A\mathbf v_j)=\sigma_j^2\mathbf v_i\cdot\mathbf v_j\mathclose{\text{.}} Input directions with zero eigenvalue satisfy Avi=0.A\mathbf v_i=\mathbf0\mathclose{\text{.}} Complete the output basis orthonormally to obtain the singular value decomposition A=UΣVT,A=U\Sigma V^\mathsf T\mathclose{\text{,}} with a rectangular diagonal matrix Σ.\Sigma\mathclose{\text{.}} Keeping only the rr positive directions gives the compact form A=∑i=1rσiuiviT.A=\sum_{i=1}^r \sigma_i\mathbf u_i\mathbf v_i^\mathsf T\mathclose{\text{.}}

Example 11.1Stretch and collapse✓ Checked

Take A=(300020).A=\begin{pmatrix}3&0&0\\0&2&0\end{pmatrix}\mathclose{\text{.}} It stretches the first two coordinate directions by 33 and 22 and collapses the third. Its rank is 2.2\mathclose{\text{.}} The rectangular SVD lists two singular values, 3,2.3,2\mathclose{\text{.}} The input Gram matrix has a third eigenvalue, 0,0\mathclose{\text{,}} for the collapsed direction.

2

The effect of small singular values

For a full-column-rank matrix, σmax⁡\sigma_{\max} is the greatest output norm for a unit input and σmin⁡\sigma_{\min} the smallest. In spectral coordinates the squared output norm is a weighted sum ∑iσi2zi2\sum_i\sigma_i^2 z_i^2 with ∑izi2=1.\sum_i z_i^2=1\mathclose{\text{.}} The condition number in Euclidean norm is σmax⁡/σmin⁡.\sigma_{\max}/\sigma_{\min}\mathclose{\text{.}} The Gram matrix has condition number equal to its square. This explains why forming the normal equations can make a numerical solve more sensitive to rounding.

3

Solve in singular coordinates

The pseudoinverse A+=∑σi>0σi−1viuiTA^+=\sum_{\sigma_i>0}\sigma_i^{-1}\mathbf v_i\mathbf u_i^\mathsf T first reads the part of b\mathbf b along the reachable output directions, then undoes each nonzero stretch. This produces a least-squares fit. Other coefficient vectors producing that fit add a vector in the kernel. Since the pseudoinverse gives a coefficient vector orthogonal to the kernel, adding a nonzero kernel vector increases its length. Thus A+bA^+\mathbf b is the unique least-squares solution of minimum norm.

In a numerical fit a very small singular value amplifies noise. Truncating that direction changes the problem by discarding an unstable component. Choose a threshold according to scale and noise, and report it when interpreting the fit.

Compute itCompare exact and minimum-norm fits
Python
from sympy import Matrix

A = Matrix([[3, 0, 0], [0, 2, 0]])
b = Matrix([6, 8])
print(list(A.pinv() * b))
print((A * A.pinv() * b).tolist())
Output
[2, 4, 0]
[[6], [8]]
4

Exercises

Exercise 11.1★Singular values are nonnegative

Find the singular values of diag⁡(2,−5).\operatorname{diag}(2,-5)\mathclose{\text{.}}

Show solution✓ Checked

The Gram matrix is diag⁡(4,25),\operatorname{diag}(4,25)\mathclose{\text{,}} so the singular values are 55 and 2.2\mathclose{\text{.}}

Exercise 11.2★★Least squares with a zero row

Find the minimum-norm least-squares solution of diag⁡(2,0)x=(6,4)T.\operatorname{diag}(2,0)\mathbf x=(6,4)^\mathsf T\mathclose{\text{.}}

Show solution✓ Checked

Only the first row can affect the prediction. Fit it with x1=3.x_1=3\mathclose{\text{.}} Every x2x_2 gives the same fit, and x2=0x_2=0 gives the smallest norm. The fitted vector is (6,0)T.(6,0)^\mathsf T\mathclose{\text{.}}

Exercise 11.3★★★Compare condition numbers

Find κ2(A)\kappa_2(A) and κ2(ATA)\kappa_2(A^\mathsf TA) for A=diag⁡(4,1/2).A=\operatorname{diag}(4,1/2)\mathclose{\text{.}}

Show solution✓ Checked

The two stretch factors are 44 and 1/2,1/2\mathclose{\text{,}} so their ratio is 8.8\mathclose{\text{.}} The Gram factors are 1616 and 1/4,1/4\mathclose{\text{,}} so their ratio is 64.64\mathclose{\text{.}}

5

Check yourself

1
Which matrix gives the right singular directions?
2
Which parts of the SVD are inverted by the pseudoinverse?
3
What can a very small positive singular value do in a solve?
Finished this module?