When b is not in the column space Col(A) (the range of A), the system has no solution, typically because there are more equations than unknowns. Least squares replaces b by the closest attainable vector, the orthogonal projectionp of b onto Col(A), and solves Ax^=p.
The normal equations say that the residual is orthogonal to every column, since the rows of the transpose are the columns of A:A⊤(b−Ax^)=0, that is, the residual lies in Null(A⊤)=Col(A)⊥ given by the Fundamental Theorem of Linear Algebra. The same equations follow from setting the gradient of ∥b−Ax∥2, namely 2A⊤Ax−2A⊤b, to zero.
Misunderstandings to avoid: the fitted vector Ax^ is always unique, but x^ need not be; and the formula (A⊤A)−1A⊤b is valid only when the columns of A are linearly independent.
The normal equations are always consistent, and their solution set equals the set of least-squares solutions.
Since Null(A⊤A)=Null(A), the least-squares solutions form the affine subspace{x^}+Null(A).
The solution is unique if and only if A has full column rankn; then x^=(A⊤A)−1A⊤b and p=Hb with the symmetric idempotent matrix H=A(A⊤A)−1A⊤.
In general, x^+=A+b, with A+ the Moore-Penrose inverse, is the unique least-squares solution of minimum norm; it is the one lying in the row spaceRow(A).
Fitting a line. Fit y=c0+c1t to the points (0,1),(1,2),(2,2). Then
A=111012,b=122,A⊤A=(3335),A⊤b=(56).
Solving 3c0+3c1=5,3c0+5c1=6 gives c1=21,c0=67. The fitted values are (67,35,613)⊤, the residual is (−61,31,−61)⊤, whose entries sum to 0 and are orthogonal to (0,1,2)⊤, and the minimal sum of squares is 61.
In the figure, the residuals are the vertical gaps between the data and the fitted line, −61,31 and −61. Their squares add up to 61, and no other line does better. Seen in R3, the fitted values (67,35,613)⊤ are the orthogonal projection of b onto Col(A), and the residual vector is orthogonal to both columns of A.
Switch on your own line and move c0 and c1: its sum of squared residuals never drops below that of the least-squares line y=67+21t. Add a fourth point to see the fit move.
Rank-deficient case. For A=(1111),b=(1,3)⊤: the normal equations reduce to x1+x2=2, so every (2−t,t)⊤ is a least-squares solution, with fitted vector (2,2)⊤, the projection of b onto span{(1,1)⊤}. The minimum-norm solution is (1,1)⊤=A+b, using A+=41A.
Aliases: method of least squares, linear least squares, least-squares solution, least-squares method, least-squares problem, least-squares approximation
Keywords: normal equations, A^T A x = A^T b, (A^T A)^{-1} A^T b, residual, minimum-norm least-squares solution, A^+ b, line fitting
Symbols: element of, real numbers
Last updated: 22 October 2026 19:04
Least SquaresEuclidean NormRange of a Linear MapTransposeOrthogonal ProjectionFundamental Theorem of Linear AlgebraMoore-Penrose InverseSingular Value DecompositionGram-Schmidt AlgorithmIdempotent Matrix