Conditions for a Least Squares Minimum
The normal equation converts the first-order optimality condition for a linear least-squares problem into a linear system.
The least squares problem seeks the that keeps as close to as possible:
A minimizer satisfies the following linear system:
This is called the normal equation because the residual at a minimizer is normal, or perpendicular, to the column space of .
Least Squares and the Normal Equation
A vector minimizes if and only if it satisfies . The optimization problem and the normal equation therefore have the same solution set. That equivalence is what turns a minimization problem into a linear system you can solve with elimination or a factorization.
The Residual Is Orthogonal to the Column Space
When minimizes , the residual vector is orthogonal to every vector in the column space of .
This column space consists of all vectors that can be written as for . The orthogonality condition means
This orthogonality condition holds for every vector . The properties of the inner product give
Because this equality holds for every vector , the vector in parentheses must be zero:
Rearranging this equation gives , the normal equation.
Proof Using Pythagorean Theorem
We can also verify this result in a different way. Let be the solution of the normal equation system and be any vector in .
Using the Pythagorean theorem, we can write
Because satisfies the normal equation, the cross term is zero. This leaves:
The added squared norm is nonnegative. Therefore, the squared norm of the residual at any cannot be smaller than at :
This inequality proves that indeed gives the minimum value.
Existence and Uniqueness
The normal equation is consistent for every matrix and every vector because a least-squares minimizer always exists in finite dimensions. The minimizer is unique exactly when has full column rank:
In that case, is invertible and
If is rank deficient, the normal equation still has solutions, but they are not unique. For any particular solution , the complete set is
All these parameter vectors produce the same fitted vector .
Null Space and definiteness proof
For every ,
This equation shows that is always symmetric positive semidefinite. Moreover,
The calculation gives:
This equality of null spaces shows that is positive definite exactly when has full column rank.
Numerical warning
Positive definiteness gives uniqueness and permits a Cholesky solve, but it does not guarantee good conditioning. For a full-column-rank matrix,
Explicitly forming can therefore magnify sensitivity and rounding effects. The inverse formula proves an algebraic identity. In software, use for a well-determined full-rank least-squares solve and when rank deficiency or severe ill-conditioning matters.
An Example with Two Observations
Let and . One scalar parameter cannot match both observations: the first equation asks for , while the second asks for . The least-squares solution balances their squared residuals.
The residual is perpendicular to the line of possible predictions. Moving along that line adds a nonnegative squared distance, as the Pythagorean proof requires.