AᵀA x̂ = Aᵀb P = A(AᵀA)⁻¹Aᵀ QᵀQ = I
Key ideas
- Row space ⟂ nullspace, column space ⟂ left nullspace.
- Projection onto a line: p = (aᵀb / aᵀa) a, with the error perpendicular to a.
- Least squares: solve AᵀAx̂ = Aᵀb. The error is perpendicular to C(A).
- Orthonormal columns: QᵀQ = I, and Gram-Schmidt builds them: A = QR.
- §4.1 Perpendicular vectors and subspaces. Dot product zero means a right angle, like a flagpole on a floor. Ax = 0 makes x perpendicular to every row, so the nullspace is perpendicular to the row space, and the left nullspace is perpendicular to the column space. Together the two pieces fill the input space, so every x splits into a row space part and a nullspace part.
- §4.2 Projecting onto a line. The shadow of a stick with the sun straight overhead, or the spot where you reach a road by walking straight at it. p = x̂a with x̂ = aᵀb / aᵀa, and the error e = b − p is perpendicular to a.
- §4.2 The projection matrix. One matrix for every b: P = aaᵀ / aᵀa for a line, P = A(AᵀA)⁻¹Aᵀ for a column space. The shadow of a shadow is the same shadow: P² = P. I − P gives the leftover e.
- §4.3 Least squares. When Ax = b has no solution, solve AᵀAx̂ = Aᵀb. Ax̂ is the shadow of b on the column space and the error is perpendicular to every column. The average of several readings is the simplest case.
- §4.3 Fitting a line. The best line C + Dt makes the sum of squared vertical gaps smallest. C and D come from m and four sums: Σt, Σt², Σb and Σtb. Sensor calibration is a line fit.
- §4.4 Orthonormal vectors and Q. Perpendicular, length 1: a perfect street grid. QᵀQ = I, a square Q has Q⁻¹ = Qᵀ, Q keeps lengths, and coordinates are dot products.
- §4.4 Gram-Schmidt. Keep the first vector, remove from each next vector its shadows on the earlier ones, then divide by lengths. The dot products and lengths fill the triangle R in A = QR.
Next lesson: a matrix as a move of the plane, and determinants (Strang §8.1, §5.1–5.3)
First, how a matrix moves the whole plane: turning, stretching, flipping. Then the determinant, one number that says whether A has an inverse and how much it stretches areas and volumes.
Read along
Keep reading with the full course
Finish lesson 5 and you will be able to: fit the best line to noisy sensor data.
Still locked here:
- The rest of this explanation
- 2 more examples with step-by-step solutions
- Five extra members-only problems with worked solutions
$20 once, lifetime access. Lessons 1 to 3 stay free.
Examples
Example 1
Project b = 24 onto the line through a = 31, and check the right angle.
Show solutionHide solution
aᵀb = 10, aᵀa = 10, x̂ = 1. p = 31, e = −13. Check: −3 + 3 = 0 ✓

Questions and comments
Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.