4.5.42 · D4Linear Algebra (Full)

Exercises — Pseudoinverse

2,542 words12 min readBack to topic

Before we start, three reminders you will lean on constantly:


Level 1 — Recognition

L1.1 — Which formula?

For each matrix, state its shape, whether it has full column rank, full row rank, or neither, and which of the three formulas you would reach for.

Recall Solution

is (tall). Its two columns and are not multiples of each other, so they are independent → full column rank (). Use .

is (fat). Its two rows and are independent → full row rank (). Use .

is (square) but row 2 row 1, so rank , not full. Neither nor is invertible → must use the SVD formula .

L1.2 — True or false

  1. If is square and invertible then .
  2. always equals the identity.
  3. The matrix is symmetric.
Recall Solution
  1. True — the pseudoinverse generalises the inverse; for invertible square they coincide.
  2. False only for full column rank. In general is an orthogonal projection onto the row space, and a projection can have eigenvalue .
  3. True — this is Penrose Condition 3: .

Level 2 — Application

L2.1 — Compute a tall pseudoinverse

Find for , then use it to solve the least-squares problem with .

Recall Solution

Shape check. , columns independent → Case 1, .

Step 1 — . ( has 's columns as its rows.) Step 2 — invert it. Determinant . For a matrix the inverse is : Step 3 — multiply by . Step 4 — solve. So the best-fit line through is . No line hits all three points, so this is the least-squares answer — the one making smallest.

L2.2 — Compute a fat pseudoinverse

Find for and the minimum-norm solution of .

Recall Solution

Shape check. (fat), one nonzero row → full row rank → Case 2, .

Step 1 — (a number): . Step 2 — invert: . Step 3 — assemble: Step 4 — solve: Why this is the minimum-norm one. Every solution of can be written as plus a vector in the nullspace of — the directions crushes to zero, i.e. all with (for example ). Adding such a leaves unchanged but only lengthens , because is perpendicular to every nullspace vector: . So is the shortest — the one with no wasted nullspace component.


Level 3 — Analysis

L3.1 — Rank-deficient by SVD

Compute for using the SVD formula, and verify .

Recall Solution

Read off the SVD. is already diagonal, so (the identity), . The singular values are , (so rank ).

Build . Flip nonzero, leave zero: . Verify Condition 1 (). (projection onto the first axis), so ✓. The zero direction stays dead: no information there to invert.

L3.2 — Projection viewpoint

For the tall of L2.1, compute and confirm it is (a) symmetric and (b) idempotent (). What does do geometrically?

Recall Solution

. Then (a) Symmetric: the matrix equals its transpose (check the off-diagonals: , ) ✓ — this is Penrose Condition 3. (b) Idempotent — proved, not just checked. "Idempotent" means applying twice does the same as once: . Here is why it must hold for any built from a genuine pseudoinverse, using only the Penrose conditions: The middle grouping used Condition 2 (). So every orthogonal projection of this form satisfies — projecting an already-projected vector changes nothing. (A direct numeric check for this specific is also in VERIFY.) Geometry. is the orthogonal projection onto the column space of — a 2D plane inside 3D. The figure below shows exactly this: the blue plane is the column space (all vectors ), the yellow arrow is , and drops straight down onto the plane to the green arrow . The red segment is the leftover residual , and it meets the plane at a right angle. That right angle is the least-squares condition : the error is smallest exactly when it is perpendicular to the plane.

Figure — Pseudoinverse
Figure L3.2 — Least-squares as projection. Blue plane: the column space of (every possible ). Yellow arrow : the target we cannot reach. Green arrow : the closest point in the plane, produced by . Red segment: the residual , perpendicular to the plane — this perpendicularity is what "least squares" means.


Level 4 — Synthesis

L4.1 — Build two ways and compare

For , compute by (i) the tall formula and (ii) the SVD formula. Show they agree.

Recall Solution

(i) Tall formula. , inverse . (ii) SVD. 's nonzero entries are already the singular values along the diagonal: , with . So , and Both routes give the same matrix ✓. When full column rank and an easy SVD both apply, they must agree — the pseudoinverse is unique.

L4.2 — A full non-diagonal SVD pseudoinverse

Compute for the rank-1 matrix .

Recall Solution

Step 1 — form and find its eigenvalues. . Its eigenvalues solve , giving or . Singular values are square roots: , (so rank ).

Step 2 — right singular vectors (eigenvectors of , unit length). For : solve direction . Normalise (divide by its length ): . For : direction , normalise: . Check orthonormal: , , and ✓ — so is orthogonal.

Step 3 — left singular vector (only the nonzero has one). Rule: . Check unit length: ✓.

Step 4 — assemble . The SVD sum runs only over nonzero singular values, so with : Sanity via Condition 1: (projection onto the line ), and ✓.


Level 5 — Mastery

L5.1 — Prove the Penrose conditions from the tall formula

Let have full column rank and . Prove all four Penrose conditions hold.

Recall Solution

Write . First note is symmetric: is symmetric (since ), and the inverse of a symmetric matrix is symmetric because when . Hence .

Condition 4 first: . The identity is symmetric ✓ — and this also shows is a genuine left inverse.

Condition 1: ✓.

Condition 2: ✓.

Condition 3: . Transpose it: (using ), so is symmetric ✓.

All four hold, and since the Penrose conditions define a unique matrix, this really is the pseudoinverse.

L5.2 — Least squares from scratch, then read off

Derive by minimising , explaining why the gradient is set to zero, and hence identify . Then verify numerically for the L2.1 data that has smaller error than the nearby .

Recall Solution

Set up the error. means "squared length of the residual vector ". Expand using : Why set the gradient to zero? Recall from the definitions box: the gradient is the vector of slopes of in each coordinate direction. Here is a smooth, bowl-shaped (convex) function of — like a parabola in many dimensions. Its lowest point is exactly where the slope in every direction is flat, i.e. where the gradient is the zero vector. This is the least-squares condition. These are the normal equations. With full column rank is invertible: Geometrically: the residual is orthogonal to every column of , i.e. — the same equation. That is why is the orthogonal projection onto the column space.

Numeric check (L2.1 data, , ).

  • At the pseudoinverse answer : , so residual , and .
  • At the nearby : , residual , and . Since , the pseudoinverse solution genuinely has the smaller squared error — no other choice can beat it, because it is the unique minimum of the convex bowl ✓.

Recall One-line self-test

Given any matrix, my first move is to check ::: its rank and shape, then pick tall / fat / SVD. geometrically is ::: orthogonal projection onto the column space of . The SVD sum for has how many terms? ::: exactly , the rank of (one term per nonzero singular value). The nullspace of is ::: the set of all with — the directions crushes to zero.

Connections