Least Squares and Pseudoinverses
Replace an unreachable target with its closest column-space projection, interpret the orthogonal residual, and use the pseudoinverse to select the minimum-norm least-squares solution.
When a target lies outside a matrix's column space, the system has no exact solution. Least squares replaces the unreachable target with its closest reachable approximation. The pseudoinverse then provides one consistent rule for choosing the parameters.
An Inconsistent System Still Has a Best Approximation
Suppose one number is expected to satisfy both
No value satisfies both equations. In matrix form,
The reachable predictions are all points on a line. The target lies outside that line. Least squares chooses the reachable point closest to the target.
This situation is common when several noisy measurements constrain fewer unknown quantities. The equations may disagree slightly even though a useful approximation exists.
The Residual Measures the Remaining Error
For a proposed parameter vector , define
Here is the fitted or predicted output, and is the residual. Least squares chooses
Read this as: “among all parameter vectors , choose the one that makes the squared distance between the target and prediction as small as possible.”
The notation asks for the input at which the expression is smallest, rather than the smallest value itself.
For the scalar example, the objective is
Expanding and completing the square gives
so the minimum occurs at . The fitted output is and the residual is . Least squares does not make an impossible system exact; it makes the squared residual as small as possible.
Exercise: Find a one-parameter least-squares fit
Minimize . What value of gives the least-squares fit?
Compute it first, then check your number.
HintBalance the two residuals
At the midpoint, the two residuals have equal magnitude and opposite signs.
SolutionComplete the square
Expanding gives
The nonnegative squared term is smallest at . At this point the two residuals are and , so neither direction of movement can reduce their total squared magnitude.
Least Squares Is an Orthogonal Projection
Every prediction lies in . The closest prediction is the orthogonal projection of onto that column space.
At the closest point, the residual
is orthogonal to every column of . Writing all those dot products together gives
Substituting the residual definition produces the normal equations:
The normal equations say that, at the least-squares solution, every column of has zero dot product with the residual. They describe perpendicularity, not a new kind of average.
The word “normal” refers to perpendicularity: the residual is normal to the column space.
Exercise: Identify the optimal residual direction
At a least-squares solution, how is the residual related to ?
Select one choice, then check.
HintUse the projection geometry
Draw the shortest segment from the target to the column space.
SolutionThe residual is perpendicular
The fitted output is the orthogonal projection of onto the column space. Therefore the displacement from the fit to the target is perpendicular to every column-space direction:
The Best Prediction May Have Several Parameter Vectors
The fitted output is unique because an orthogonal projection onto a subspace is unique. The parameter vector need not be unique.
If has a nontrivial null space and , then
All these parameter vectors produce the same fit and the same residual. A least-squares parameter solution is unique exactly when has full column rank. In that case is invertible and
This formula explains the solution but is not usually the preferred numerical procedure. Forming can worsen conditioning; QR or singular value decomposition is generally more reliable.
Exercise: Recognize nonunique parameters
Suppose minimizes the squared residual and is a nonzero null vector of . What can be said about ?
Select one choice, then check.
HintApply the matrix to the sum
Use linearity and the definition of the null space.
SolutionNull-space movement preserves the fit
Since ,
The fitted output and residual are unchanged, so the shifted vector is another least-squares solution.
The Pseudoinverse Chooses One Canonical Solution
The Moore–Penrose pseudoinverse, written , is defined for every matrix—square or rectangular, full rank or rank deficient. The vector
has two linked properties:
- it minimizes ;
- among all vectors with that minimum residual, it has the smallest Euclidean norm .
Thus the pseudoinverse handles both difficulties:
- if the target is unreachable, it chooses a closest reachable prediction;
- if several parameter vectors give that prediction, it chooses the minimum-norm one.
When a square matrix is invertible, . The pseudoinverse is not an ordinary inverse for every matrix; in general, neither nor must be the identity. Instead, these products act as projections onto the appropriate retained subspaces.
Exercise: Choose among equally good fits
Several parameter vectors produce the same minimum least-squares residual. Which one does select?
Select one choice, then check.
HintRecall the second optimization criterion
First minimize the residual; then minimize the parameter norm among ties.
SolutionUse the minimum-norm solution
The pseudoinverse first attains the smallest possible residual and then selects, among all equally good fits, the vector with minimum .
Singular Values Explain the Pseudoinverse
The later singular value decomposition lesson will factor a matrix as
In that coordinate system, the pseudoinverse reciprocates nonzero singular values and leaves zero singular values at zero:
A zero singular value represents a direction erased by the matrix. Replacing it with would be undefined and would pretend to recover information that the output does not contain.
Exercise: Interpret a zero singular value
Why does the pseudoinverse leave the reciprocal of a zero singular value at zero rather than attempting to compute ?
Select one choice, then check.
HintTrack the lost direction
Every magnitude along that input direction produces the same zero output component.
SolutionDo not invent erased information
A zero singular value collapses an input direction to zero. Because the output contains no evidence of the original magnitude, no inverse-like operation can reconstruct it uniquely.
Compare least squares and the pseudoinverse
Edit the matrix or target. Both methods produce a least-squares fit; the pseudoinverse also remains defined for rank-deficient matrices.
Ready to run.
The repeated columns make the parameter vector nonunique. The pseudoinverse splits the shared contribution evenly, giving the minimum-norm solution. The final output confirms that the residual is orthogonal to both columns.
Before Using Least Squares
Separate three objects: the parameter vector , the fitted output , and the residual . Check whether the target is exactly reachable, whether the parameters are unique, and whether a minimum-norm selection is appropriate. In numerical work, use a least-squares solver rather than explicitly forming .
The next lesson studies eigenvectors: special directions that a square matrix keeps on the same line. That viewpoint begins a different route into matrix structure and repeated transformations.