Least-Squares Problems
When Ax = b has no solution, the least-squares solution makes Ax as close to b as possible. The closest Ax is the projection of b onto the column space, and the vector that produces it solves the normal equations A-transpose A x = A-transpose b.
╌╌╌╌
Over-determined systems — more equations than unknowns, built from noisy measurements — usually have no exact solution. The coefficient matrix maps onto the subspace , and the target typically lies outside it, so no exact solution exists. The practical question is which makes closest to , and the best-approximation theorem answers it: project onto .
The least-squares problem
The name records that is the square root of a sum of squares, so minimizing it minimizes the total squared error. No matter what is chosen, lands somewhere in . The task is to make that point the one in nearest to .
The normal equations
Let . It is in , so is consistent and has a solution . Because is the closest point of to , this minimizes and so is a least-squares solution.
The residual is orthogonal to , hence orthogonal to every column of . If is a column, then , i.e. . Stacking these over all columns is the single matrix equation , which rearranges to
The forward direction is the derivation above. Conversely, if satisfies the normal equations, then is orthogonal to the rows of , hence to the columns of , hence to all of . So is an orthogonal decomposition, and by uniqueness must equal the projection — making a least-squares solution. The normal equations convert a minimization into a square linear system.
Non-unique least-squares solutions
When the columns of are dependent, has free variables and the least-squares solutions form a whole family.
Such matrices appear in the analysis-of-variance problems of statistics, where the columns encode overlapping group memberships.
Uniqueness of the least-squares solution
The projection is unique, but the producing it need not be. Uniqueness is governed by the columns of .
The equivalence rests on the fact that : if , then , so , and the reverse is obvious. Independent columns thus make have trivial null space, hence invertible. The closed form is convenient for a system but is not the recommended route for larger or ill-conditioned problems.
When the columns are orthogonal, no inverse is needed at all: the projection is the sum of one-dimensional projections, and the weights are the least-squares solution directly. For with orthogonal columns,
Matrices with orthogonal columns arise routinely in the regression models where centering the data makes the design matrix's columns orthogonal by construction.
The least-squares error
Once is found, the quality of the fit is the distance from to its approximation.
For the worked example, , so and the error is . No can bring within of ; the residual is the leg of the right triangle from down to . An error of zero means was already in and the original system was consistent.
The QR route
The formula can amplify rounding error: forming squares the sensitivity of the problem. When the columns of are independent, the QR factorization gives a more reliable path.
With , the projection of onto is (projection onto an orthonormal basis). Then , so is the least-squares solution. In practice one does not invert ; since is upper triangular, the system
is solved by back-substitution, which is faster and more accurate than computing .
Summary
| Quantity | Formula | Notes |
|---|---|---|
| Normal equations | always consistent | |
| Unique solution | needs independent columns | |
| Orthogonal columns | weights | no inverse needed |
| QR route | back-substitution, more stable | |
| Error | minimum residual length |
The least-squares solution is a projection: is the foot of the perpendicular from to , and the normal equations are the algebraic statement that the residual is orthogonal to every column. Fitting lines, polynomials, and surfaces to data applies the same machinery with a design matrix.1
Footnotes
- Lay, §6.5 — Least-Squares Problems: the definition of a least-squares solution, Theorem 13 (normal equations), Theorem 14 (uniqueness via independent columns and invertibility of ), the least-squares error, and Theorem 15 (the QR solution ). ↩
╌╌ END ╌╌