Form the normal equation A transpose A x = A transpose b
Multiply both sides of Ax=b by A transpose and state the resulting square system. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.
with a tall usually has no solution: more equations than unknowns, and the columns cannot reach.
You cannot fix that by row-reducing, because there is nothing to solve. What you can do is change the question slightly: instead of asking which makes equal, ask which makes as close to as possible.
The answer arrives from one move: multiply both sides of by.
These are the normal equations, and the only thing to be careful about is that must multiply both sides.
Why the shapes work. If is then is, so:
| object | shape | meaning | |---|---|---| | | | one row per equation | | | | square, one row per unknown | | | | one right-hand entry per unknown |
That is the whole point. The unsolvable system became a square system with the same number of equations as unknowns — and if the columns of are independent, is invertible and there is exactly one answer.
Two derivations give the same equations, and both are worth knowing because the exam asks you to justify the setup.
Geometric. The best is the projection of onto the column space of. The projection is the nearest point, so the error is perpendicular to every column of. Stack those perpendicularity conditions as rows: Expand and rearrange:
Calculus. Minimise the squared error. Differentiating with respect to each unknown and setting the gradient to zero gives, which is the same equation.
The two agree because they are the same statement. "The error is perpendicular to the column space" and "the gradient of the squared error vanishes" both say: no small change in can reduce the error. One says it with a right angle, the other with a derivative.
Why is invertible when the columns are independent. If then, which is, so, so by independence. A square matrix whose only null vector is is invertible. This is why the normal equations have exactly one solution — and why dependent columns make the answer non-unique rather than wrong.
and.
Step 1, transpose. is.
Step 2, left side. Check: is the number of rows of (the ones dot themselves),, and. Shape ✓.
Step 3, right side. Shape ✓.
Step 4, the system.
Solve it: the determinant is, so
So the best line is. Sanity: the points average around at an average time of, and ✓ — the line passes through the centroid, which a least-squares line always does.
Step 5, the check that settles it. and. Then The errors sum to zero, which is read on the first row.
- Multiply both sides of Ax=b by A transpose and state the resulting square system
- Check the shapes: A transpose A is square in the unknowns, A transpose b has one entry per unknown
- Say what the normal equations mean geometrically: the residual is perpendicular to every column
- Decide when A transpose A is invertible and what happens when it is not
.
- 1. What is?
- 2. Is it invertible?
- 3. What does your answer to (2) mean for the fit?
Answers
- 1.: the ones give, the times give twice, and the squares give.
- 2., so yes. (The columns are and, and the second is not a multiple of the first.)
- 3. The least-squares coefficients are unique. But note that the data are not: times and each appear twice, so four points sit on only two distinct times. Uniqueness of the coefficients needs independent columns, not distinct data — and here they happen to be independent even though the times repeat.