Normal equations
For a real least-squares problem Ax=b, the normal equations are AᵀAx=Aᵀb.
On this page 8 sections
- Overview
- The normal equations characterize a least-squares fit by its leftover error
- Let A have columns u=(1,1,0) and v=(0,1,1)
- For u=(1,1,0), v=(0,1,1), b=(2,3,1), each row below dots one column with u, v and b
- These equations explain regression geometry and lead to regularized variants later
- Key takeaway
- Sources & further reading
- Concept connections
01The normal equations characterize a least-squares fit by its leftover error#
The normal equations characterize a least-squares fit by its leftover error. At the best fit, moving along any model column cannot remove more error to first order. The residual is perpendicular, or normal, to those columns; that is where the name comes from.
At the closest attainable output Ax, the residual b−Ax is perpendicular to every column of A. For A=(1,1)ᵀ and b=(2,4), the closest output is (3,3). Its residual is (−1,1), whose dot product with (1,1) is zero.
Multiplying the residual by Aᵀ collects those zero dot products. Expand Aᵀ(b−Ax)=0 and rearrange. The result is called the normal equations:
For a matrix with rows and columns, is and has entries. Each left-side entry compares two feature columns by a dot product. Each right-side entry compares a feature column with the target. Build both products before trying to solve for the coefficients.
Form . .
Show answer and explanation
; .
02Let A have columns u=(1,1,0) and v=(0,1,1)#
Let A have columns u=(1,1,0) and v=(0,1,1). The entries of AᵀA are column dot products: u·u=2, u·v=1 and v·v=2. The reverse cross-product v·u also equals 1.
For columns u=(1,1,0), v=(0,1,1) and target b=(2,3,1), dot each column with b to form the right side:
Thus Aᵀb=(5,4).
A model predicts . Data : , . Form the normal equation for as .
Show answer and explanation
; .
03For u=(1,1,0), v=(0,1,1), b=(2,3,1), each row below dots one column with u, v and b#
For u=(1,1,0), v=(0,1,1), b=(2,3,1), each row below dots one column with u, v and b. It forms 2x₁+x₂=5 and x₁+2x₂=4.
The normal equations can be formed even when A has dependent columns. They then need not select a unique input. Writing an inverse of AᵀA would require independent columns; forming the two products does not require an inverse.
A learner uses on the right. Repair . .
Show answer and explanation
.
04These equations explain regression geometry and lead to regularized variants later#
These equations explain regression geometry and lead to regularized variants later. Forming them and solving them are different tasks. In numerical work, QR or SVD may be preferable to explicitly forming and inverting , especially when columns are nearly dependent.
Form AᵀAx=Aᵀb using column dot products. These equations characterize least-squares inputs; a unique input additionally requires independent columns.
- Form both sides of the normal equations.
Sources & further reading
- [1]TU Delft Linear Algebra, 7.4.3: Normal equations ↗TU Delft · Book