Least-Squares Approximation & the Normal Equations
When is inconsistent — — there is no exact solution, so we settle for the next best thing: the vector that makes as close to as possible. This lesson shows that the closest point in a subspace is the orthogonal projection (Theorem 8.12), that the minimiser is found by solving the normal equation (Theorem 8.13), and how this turns messy, over-determined data into a single clean line of best fit.
Before you start — give these a try
Attempting first primes your brain for the lesson — even if you miss. Nothing is graded or saved; it's just a warm-up.
Solve the normal equation where and . Give .
Find the least-squares line through the points . Give your answer as the vector (to 3 decimals).
What you’ll be able to do
- State Definition 8.9: a least-squares solution of is a vector minimising the error , and explain why it coincides with an exact solution when the system is consistent.
- Use Theorem 8.12 to identify the point of a subspace closest to as the orthogonal projection .
- Derive and solve the normal equation (Theorem 8.13) from the orthogonality condition .
- Decide when the least-squares solution is unique () and compute it as , using Corollary 8.1 to justify that is invertible.
- Set up the design matrix for fitting a line (or a curve) to data and recover the projection formula (Theorem 8.14).
In your course
· MATH2015 · Linear Algebra & Probability- Theorem 8.12Best approximation by the orthogonal projectionFor and a subspace , is the vector of closest to : for all .
- Definition 8.9Least-squares solutionA least-squares solution of (with an matrix) is a vector with for all .
- Theorem 8.13The normal equation for least-squares solutionsThe least-squares solutions of are the exact solutions of . The solution is unique iff , and then .
- Theorem 8.14Orthogonal projection in terms of a basisIf , then , so is the matrix of the orthogonal projection onto .
- Corollary 8.1 is invertible whenIf is with , then the matrix is invertible.
- Theorem 8.11
- Theorem 8.10 (orthogonal complement of the column space, from §8.3)
Inconsistent systems and the least-squares idea
Many real problems lead to a system with more equations than unknowns (an matrix with ). Measurement noise then usually pushes outside the column space, , so no satisfies every equation exactly — the system is inconsistent. Rather than give up, we look for the best approximate solution. A least-squares solution (Definition 8.9) is a vector that minimises the Euclidean error The name comes from minimising , a sum of squares of the residual entries. If the system happens to be consistent, the minimum error is , and the least-squares solutions are exactly the ordinary solutions.
Best approximation is orthogonal projection
Minimising distance to a subspace has a clean geometric answer. Given and a subspace , Theorem 8.12 says the point of closest to is the orthogonal projection : The proof is one application of Pythagoras: write . The first piece lies in and the second in , so they are orthogonal and , which is smallest exactly when the last term is . Taking , the best is therefore , and the residual is orthogonal to the column space.
The normal equation
Orthogonality of the residual is what we can compute with. Since (Theorem 8.10), the statement 'the residual is orthogonal to every column of ' becomes This last system is the normal equation, and Theorem 8.13 says its exact solutions are precisely the least-squares solutions of — and it is always consistent, even when the original system is not. The solution is unique if and only if (that is, has linearly independent columns); then is invertible (Corollary 8.1, via from Theorem 8.11) and
Fitting a line or curve to data
The classic application is a line of best fit. To fit to data , we would like for every — the system With more than two non-identical points this is over-determined and inconsistent, so we solve the normal equation instead; the unique pair minimises the total squared vertical error . The same recipe fits any model linear in its parameters — a parabola just uses columns . Finally, when has independent columns, Theorem 8.14 packages the fitted values as a projection, a projection formula valid for any basis (the columns of ), generalising for an orthonormal basis.
Let and let be a subspace of . Then the orthogonal projection is the unique vector of closest to : for all with .
The least-squares solutions of are exactly the (exact) solutions of the normal equation This solution is unique if and only if , and in that case .
If the columns of form a basis of (equivalently ), then the orthogonal projection of onto is so the projection matrix onto is .
If is an matrix with , then the matrix is invertible.
Worked examples
The system with and is inconsistent. Find its least-squares solution , the projection of onto , and the least-squares error .
- 1
Confirm inconsistency: . Matching the last two entries forces , but then the first entry would be , so .
- 2
Form the normal-equation pieces: and .
- 3
Solve (Theorem 8.13). Since , , so .
- 4
Projection onto the column space: .
- 5
Residual and error: , which is orthogonal to both columns ( and ), confirming the fit. Hence .
Find the line of best fit (least squares) through the points .
Use least squares to find the point of the plane that is closest to , and compute the distance from to .