Unit 7, lesson 32

The Pseudoinverse and Four Projectors

How the pseudoinverse built from the SVD gives every least-squares solution and the minimum-norm one, and how four orthogonal projectors split the input and output spaces of a matrix.

  • Video 32
  • The Decomposition and the Pseudoinverse

Take the matrix AA with rows (1,2)(1, 2), (2,4)(2, 4) and (0,0)(0, 0) and the target b=(7,9,2)b = (7, 9, 2). No input solves Ax=bAx = b, since the second entry of AxAx is always twice the first and the third entry is always zero, yet a whole line of inputs comes equally close. Which part of bb can be fitted and which part must remain as error, and which of the many best inputs should be chosen? The singular value decomposition answers both questions, and the answers define the pseudoinverse and four orthogonal projectors, two on the input space and two on the output space. Throughout, F\mathbb{F} is R\mathbb{R} or C\mathbb{C}, norms come from the standard inner product, and a tuple stands for a column vector.

Key terms

Pseudoinverse

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} have rank rr and a full singular value decomposition A=UΣV∗A = U\Sigma V^{*}. Let Σ+∈Rn×m\Sigma^{+} \in \mathbb{R}^{n \times m} have entries (Σ+)ii=1/σi(\Sigma^{+})_{ii} = 1/\sigma_i for i≤ri \le r and every other entry 00. So Σ+\Sigma^{+} has the transposed shape, the positive singular values are reciprocated and the zeros stay zero. The pseudoinverse of AA is

A+=VΣ+U∗∈Fn×m.A^{+} = V\Sigma^{+}U^{*} \in \mathbb{F}^{n \times m}.

In compact form,

A+=VrΣr−1Ur∗=∑i=1r1σi viui∗,A^{+} = V_r\Sigma_r^{-1}U_r^{*} = \sum_{i=1}^{r} \frac{1}{\sigma_i}\, v_i u_i^{*},

so A+ui=vi/σiA^{+}u_i = v_i/\sigma_i for i≤ri \le r and A+ui=0A^{+}u_i = 0 for i>ri > r. The result does not depend on which singular value decomposition is used, because the free choices of singular vectors cancel in each block σ−1VσUσ∗\sigma^{-1}V_\sigma U_\sigma^{*} and the zero directions do not appear at all. The next lesson characterizes A+A^{+} by four equations as well. If A=0A = 0, then A+A^{+} is the n×mn \times m zero matrix. If AA is square and invertible, then A+=A−1A^{+} = A^{-1}. If AA has full column rank, r=nr = n, then A∗AA^{*}A is invertible and A+=(A∗A)−1A∗A^{+} = (A^{*}A)^{-1}A^{*}. If AA has full row rank, r=mr = m, then A+=A∗(AA∗)−1A^{+} = A^{*}(AA^{*})^{-1}. Both formulas follow by writing each side in singular coordinates.

In plain words The pseudoinverse undoes AA on the directions that AA keeps and sends every output direction perpendicular to all outputs of AA to zero. There is no division by zero, because a lost direction is never inverted at all.

Example For the opening matrix, A=5 u1v1TA = 5\,u_1v_1^{\mathsf{T}} with u1=(1,2,0)/5u_1 = (1, 2, 0)/\sqrt{5} and v1=(1,2)/5v_1 = (1, 2)/\sqrt{5}, so r=1r = 1 and

A+=15 v1u1T=125[120240].A^{+} = \frac{1}{5}\, v_1u_1^{\mathsf{T}} = \frac{1}{25}\begin{bmatrix} 1 & 2 & 0 \\ 2 & 4 & 0 \end{bmatrix}.

The matrix AA is 3×23 \times 2 and its pseudoinverse is 2×32 \times 3. Neither formula for full rank applies, since the rank r=1r = 1 is smaller than both m=3m = 3 and n=2n = 2. For instance ATAA^{\mathsf{T}}A, with rows (5,10)(5, 10) and (10,20)(10, 20), is singular.

Least-squares solution set

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} and b∈Fmb \in \mathbb{F}^m. A vector x^∈Fn\hat{x} \in \mathbb{F}^n is a least-squares solution of Ax=bAx = b if ∥Ax^−b∥≤∥Ax−b∥\lVert A\hat{x} - b \rVert \le \lVert Ax - b \rVert for every x∈Fnx \in \mathbb{F}^n. Take a full singular value decomposition and put c=U∗bc = U^{*}b and y=V∗xy = V^{*}x. Unitary matrices preserve norms, so

∥Ax−b∥2=∥Σy−c∥2=∑i=1r∣σiyi−ci∣2+∑i=r+1m∣ci∣2.\begin{aligned} \lVert Ax - b \rVert^2 &= \lVert \Sigma y - c \rVert^2 \\[0.4em] &= \sum_{i=1}^{r} \lvert \sigma_i y_i - c_i \rvert^2 \\[0.4em] &\quad + \sum_{i=r+1}^{m} \lvert c_i \rvert^2. \end{aligned}

The last sum does not depend on xx. Each term of the first sum vanishes exactly when yi=ci/σiy_i = c_i/\sigma_i, and the coordinates yr+1,…,yny_{r+1}, \dots, y_n do not appear. So least-squares solutions always exist, and the least-squares solution set is

A+b+ker⁡A,A^{+}b + \ker A,

the set of all vectors A+b+zA^{+}b + z with z∈ker⁡Az \in \ker A. The vector A+bA^{+}b is the solution with yr+1=⋯=yn=0y_{r+1} = \cdots = y_n = 0. The minimum squared residual is ∑i>r∣ci∣2\sum_{i > r} \lvert c_i \rvert^2. Equivalently, xx is a least-squares solution exactly when Ax=AA+bAx = AA^{+}b, and exactly when it solves the normal equations A∗Ax=A∗bA^{*}Ax = A^{*}b, which in singular coordinates read σi2yi=σici\sigma_i^2 y_i = \sigma_i c_i for i≤ri \le r. The set is a single point exactly when ker⁡A={0}\ker A = \{0\}, that is r=nr = n, and the minimum residual is zero exactly when b∈im⁡Ab \in \operatorname{im} A.

In plain words Only the part of bb along directions that AA can reach is adjustable, and the rest is a fixed error that no input can remove. Inputs that differ by a kernel vector give the same output, so they fit equally well.

Example For the opening AA and b=(7,9,2)b = (7, 9, 2), the pseudoinverse gives A+b=125(25,50)=(1,2)A^{+}b = \tfrac{1}{25}(25, 50) = (1, 2), and ker⁡A\ker A is spanned by (2,−1)(2, -1). The least-squares solution set is the line

x=(1+2s, 2−s),s∈R.x = (1 + 2s,\ 2 - s), \qquad s \in \mathbb{R}.

Every such xx gives Ax=(5,10,0)Ax = (5, 10, 0), so the residual b−Ax=(2,−1,2)b - Ax = (2, -1, 2) has squared norm 99. In singular coordinates, with u1=(1,2,0)/5u_1 = (1, 2, 0)/\sqrt{5}, u2=e3u_2 = e_3 and u3=(2,−1,0)/5u_3 = (2, -1, 0)/\sqrt{5}, the target becomes c=(55,2,5)c = (5\sqrt{5}, 2, \sqrt{5}), and the fixed error is 22+(5)2=92^2 + (\sqrt{5})^2 = 9. The normal equations reduce to the single equation x1+2x2=5x_1 + 2x_2 = 5, the same line.

Minimum-norm least-squares solution

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} and b∈Fmb \in \mathbb{F}^m. The theorem says that among all least-squares solutions of Ax=bAx = b, the vector A+bA^{+}b has the smallest norm and is the only one with that norm. It is called the minimum-norm least-squares solution. The proof uses the compact form. The vector

A+b=∑i=1r⟨ui,b⟩σi viA^{+}b = \sum_{i=1}^{r} \frac{\langle u_i, b \rangle}{\sigma_i}\, v_i

lies in the span of v1,…,vrv_1, \dots, v_r, which is (ker⁡A)⊥(\ker A)^{\perp}. Every least-squares solution is A+b+zA^{+}b + z with z∈ker⁡Az \in \ker A, and by the Pythagorean identity

∥A+b+z∥2=∥A+b∥2+∥z∥2,\lVert A^{+}b + z \rVert^2 = \lVert A^{+}b \rVert^2 + \lVert z \rVert^2,

which is larger than ∥A+b∥2\lVert A^{+}b \rVert^2 unless z=0z = 0. Equivalently, A+bA^{+}b is the unique least-squares solution in (ker⁡A)⊥=im⁡A∗(\ker A)^{\perp} = \operatorname{im} A^{*}. When b∈im⁡Ab \in \operatorname{im} A it is the exact solution of smallest norm. When A=0A = 0, every input is a least-squares solution and the minimum-norm one is A+b=0A^{+}b = 0.

In plain words Two separate choices are made. First fit the output as well as possible, then among all inputs with that best fit take the shortest. The shortest one has no kernel component, because a kernel component adds length without changing the output.

Example On the line x=(1+2s,2−s)x = (1 + 2s, 2 - s) from above,

∥x∥2=(1+2s)2+(2−s)2=5+5s2,\begin{aligned} \lVert x \rVert^2 &= (1 + 2s)^2 + (2 - s)^2 \\[0.4em] &= 5 + 5s^2, \end{aligned}

which is smallest at s=0s = 0. That gives A+b=(1,2)A^{+}b = (1, 2), of norm 5\sqrt{5}, and (1,2)(1, 2) is orthogonal to the kernel direction (2,−1)(2, -1). The choice s=1s = 1 gives (3,1)(3, 1), with the same residual but squared norm 1010.

Projector onto the column space

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} have rank rr and compact singular value decomposition A=UrΣrVr∗A = U_r\Sigma_rV_r^{*}. Then

AA+=UrUr∗=∑i=1ruiui∗∈Fm×m.AA^{+} = U_rU_r^{*} = \sum_{i=1}^{r} u_iu_i^{*} \in \mathbb{F}^{m \times m}.

This matrix is Hermitian and idempotent, and its image is the span of u1,…,uru_1, \dots, u_r, which is im⁡A\operatorname{im} A, the column space of AA. So AA+AA^{+} is the orthogonal projector of Fm\mathbb{F}^m onto the column space. For every b∈Fmb \in \mathbb{F}^m, the vector AA+bAA^{+}b is the point of im⁡A\operatorname{im} A closest to bb, and it is the fitted output Ax^A\hat{x} of every least-squares solution x^\hat{x}. In the full decomposition it is UU times the diagonal matrix with rr ones followed by m−rm - r zeros times U∗U^{*}. It equals ImI_m exactly when r=mr = m.

In plain words The matrix AA+AA^{+} acts on the output space. It keeps the part of a target that AA can produce and removes the rest.

Example For the opening matrix, u1=(1,2,0)/5u_1 = (1, 2, 0)/\sqrt{5}, so

AA+=u1u1T=15[120240000].AA^{+} = u_1u_1^{\mathsf{T}} = \frac{1}{5}\begin{bmatrix} 1 & 2 & 0 \\ 2 & 4 & 0 \\ 0 & 0 & 0 \end{bmatrix}.

It sends b=(7,9,2)b = (7, 9, 2) to 15(25,50,0)=(5,10,0)\tfrac{1}{5}(25, 50, 0) = (5, 10, 0), the fitted output found above.

Projector onto the row space

Definition With the same notation,

A+A=VrVr∗=∑i=1rvivi∗∈Fn×n.A^{+}A = V_rV_r^{*} = \sum_{i=1}^{r} v_iv_i^{*} \in \mathbb{F}^{n \times n}.

It is the orthogonal projector of Fn\mathbb{F}^n onto the span of v1,…,vrv_1, \dots, v_r. Since A∗ui=σiviA^{*}u_i = \sigma_iv_i, that span is im⁡A∗\operatorname{im} A^{*}, which equals (ker⁡A)⊥(\ker A)^{\perp}. This subspace is the row space of AA. Over R\mathbb{R} it is spanned by the rows of AA, and over C\mathbb{C} by the complex conjugates of the rows, written as columns. For every x∈Fnx \in \mathbb{F}^n, applying AA and then A+A^{+} gives A+(Ax)=(A+A)xA^{+}(Ax) = (A^{+}A)x, the row space component of xx, and A(A+Ax)=AxA(A^{+}Ax) = Ax. The projector equals InI_n exactly when r=nr = n.

In plain words The matrix A+AA^{+}A acts on the input space. It keeps the part of an input that AA remembers and removes the part that AA forgets.

Example For the opening matrix,

A+A=v1v1T=15[1224].A^{+}A = v_1v_1^{\mathsf{T}} = \frac{1}{5}\begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}.

For x=(3,1)x = (3, 1), the output is Ax=(5,10,0)Ax = (5, 10, 0) and A+Ax=(1,2)A^{+}Ax = (1, 2). The pseudoinverse returns (1,2)(1, 2) rather than (3,1)(3, 1) because the two inputs have the same output and only (1,2)(1, 2) lies in the row space. Although A+AA^{+}A is square, it is not I2I_2.

Complementary projectors

Definition If P∈Fk×kP \in \mathbb{F}^{k \times k} is the orthogonal projector onto a subspace SS, then Ik−PI_k - P is Hermitian and idempotent, since (Ik−P)2=Ik−2P+P2=Ik−P(I_k - P)^2 = I_k - 2P + P^2 = I_k - P, and its image is ker⁡P=S⊥\ker P = S^{\perp}. So Ik−PI_k - P is the orthogonal projector onto S⊥S^{\perp}. Applied to the two projectors above, the m×mm \times m matrix Im−AA+I_m - AA^{+} projects Fm\mathbb{F}^m onto (im⁡A)⊥=ker⁡A∗(\operatorname{im} A)^{\perp} = \ker A^{*}, and the n×nn \times n matrix In−A+AI_n - A^{+}A projects Fn\mathbb{F}^n onto (im⁡A∗)⊥=ker⁡A(\operatorname{im} A^{*})^{\perp} = \ker A. They give two orthogonal splittings,

b=AA+b+(Im−AA+) b,x=A+Ax+(In−A+A) x,\begin{aligned} b &= AA^{+}b + (I_m - AA^{+})\,b, \\[0.4em] x &= A^{+}Ax + (I_n - A^{+}A)\,x, \end{aligned}

for every b∈Fmb \in \mathbb{F}^m and x∈Fnx \in \mathbb{F}^n. The least-squares residual is (Im−AA+)b(I_m - AA^{+})b, and the least-squares solution set can be written as A+b+(In−A+A)wA^{+}b + (I_n - A^{+}A)w with w∈Fnw \in \mathbb{F}^n. The four projectors live in two different spaces, two of size m×mm \times m and two of size n×nn \times n, and even when m=nm = n the output projector AA+AA^{+} and the input projector A+AA^{+}A are in general different matrices.

In plain words Each space splits in two perpendicular pieces. The output space splits into what AA can produce and the directions perpendicular to all of it, and the input space splits into what AA remembers and the kernel directions that it forgets.

Example For the opening matrix,

I3−AA+=15[4−20−210005],I2−A+A=15[4−2−21].\begin{gathered} I_3 - AA^{+} = \frac{1}{5}\begin{bmatrix} 4 & -2 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 5 \end{bmatrix}, \\[0.4em] I_2 - A^{+}A = \frac{1}{5}\begin{bmatrix} 4 & -2 \\ -2 & 1 \end{bmatrix}. \end{gathered}

The first sends b=(7,9,2)b = (7, 9, 2) to the residual (2,−1,2)(2, -1, 2). The second sends x=(3,1)x = (3, 1) to its kernel part (2,−1)(2, -1), so (3,1)=(1,2)+(2,−1)(3, 1) = (1, 2) + (2, -1), with perpendicular parts.

Check yourself

  1. Find the pseudoinverse of the matrix AA with rows (2,0,0)(2, 0, 0) and (0,0,0)(0, 0, 0), and the minimum-norm least-squares solution of Ax=bAx = b for b=(4,5)b = (4, 5).
Show the answer

The matrix is already in singular value form, with U=I2U = I_2, V=I3V = I_3, σ1=2\sigma_1 = 2 and σ2=0\sigma_2 = 0. Reciprocate the positive value, keep the zeros and transpose the shape, so

A+=[1/200000],A^{+} = \begin{bmatrix} 1/2 & 0 \\ 0 & 0 \\ 0 & 0 \end{bmatrix},

a 3×23 \times 2 matrix. The minimum-norm least-squares solution is A+b=(2,0,0)A^{+}b = (2, 0, 0). The first equation 2x1=42x_1 = 4 can be met and the second, 0=50 = 5, cannot, so the least-squares solutions are (2,s,t)(2, s, t) for all ss and tt, with residual (0,5)(0, 5). Watch for two common slips, writing A+A^{+} with the shape of AA and trying to reciprocate a zero.

  1. Let AA have rows (1,1)(1, 1), (1,1)(1, 1) and (1,1)(1, 1), and let b=(1,2,9)b = (1, 2, 9). Find A+A^{+}, all least-squares solutions, the minimum-norm one and the residual.
Show the answer

The matrix is the outer product of (1,1,1)(1, 1, 1) and (1,1)(1, 1), so σ1=3 2=6\sigma_1 = \sqrt{3}\,\sqrt{2} = \sqrt{6} with u1=(1,1,1)/3u_1 = (1, 1, 1)/\sqrt{3} and v1=(1,1)/2v_1 = (1, 1)/\sqrt{2}. Then

A+=16 v1u1T=16[111111],A^{+} = \frac{1}{\sqrt{6}}\,v_1u_1^{\mathsf{T}} = \frac{1}{6}\begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix},

and A+b=16(12,12)=(2,2)A^{+}b = \tfrac{1}{6}(12, 12) = (2, 2). The kernel is spanned by (1,−1)(1, -1), so the least-squares solutions are (2+s,2−s)(2 + s, 2 - s), and the minimum-norm one is (2,2)(2, 2). Each of them gives Ax=(4,4,4)Ax = (4, 4, 4), so the residual is (−3,−2,5)(-3, -2, 5), with squared norm 3838. Every equation says x1+x2=bix_1 + x_2 = b_i, and the best common value 44 is the mean of the targets. The formula (ATA)−1ATb(A^{\mathsf{T}}A)^{-1}A^{\mathsf{T}}b fails here, because ATAA^{\mathsf{T}}A, with every entry 33, is singular.

  1. (a) For which A∈Fm×nA \in \mathbb{F}^{m \times n} is A+A=InA^{+}A = I_n, and for which is AA+=ImAA^{+} = I_m? (b) For the matrix of question 2 and the input x=(3,1)x = (3, 1), which of the four projectors extracts the part of xx that cannot be recovered from AxAx, and what is that part?
Show the answer

For (a), A+A=VrVr∗A^{+}A = V_rV_r^{*} is the identity exactly when r=nr = n, that is, when AA has full column rank and ker⁡A={0}\ker A = \{0\}. Likewise AA+=ImAA^{+} = I_m exactly when r=mr = m, full row rank. Both hold only for a square invertible matrix, and then A+=A−1A^{+} = A^{-1}.

For (b), the unrecoverable part lies in ker⁡A\ker A, so the projector is the 2×22 \times 2 matrix

I2−A+A=12[1−1−11].I_2 - A^{+}A = \frac{1}{2}\begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}.

It sends (3,1)(3, 1) to (1,−1)(1, -1). Indeed Ax=(4,4,4)Ax = (4, 4, 4) and A+Ax=(2,2)A^{+}Ax = (2, 2), so (3,1)=(2,2)+(1,−1)(3, 1) = (2, 2) + (1, -1). The output complement I3−AA+I_3 - AA^{+} is a 3×33 \times 3 matrix that acts on targets, not on inputs.

How this lesson connects