Linear Algebra, Live
Recap · Reading

What you can now do.

Lesson 5 in one page. You can now test right angles with a dot product, drop any vector onto a line or a plane, find the best answer to equations that have no exact answer, draw the best line through data, and build bases where every calculation is a dot product.

Lesson 5 · slide 8Recap
AᵀA x̂ = Aᵀb    P = A(AᵀA)⁻¹Aᵀ    QᵀQ = I
Key ideas
  1. Row space ⟂ nullspace, column space ⟂ left nullspace.
  2. Projection onto a line: p = (aᵀb / aᵀa) a, with the error perpendicular to a.
  3. Least squares: solve AᵀAx̂ = Aᵀb. The error is perpendicular to C(A).
  4. 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 ✓

Exercise Free play: proj(a, b) draws a projection for you (proj(a, b, p) checks your own p), fit(t, b, C, D) draws a line fit, vectors(...) draws arrows. Edit the code and press Run.
slide_8.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Questions and comments

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

The full course

From Ax = b to PCA, by running it

Lessons 1 to 3 are free. Finish all eight and you will be able to:

You get: all 8 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · answers to your questions · every future update.

$20 once · lifetime access
Continue to checkout →

Already a member? Log in to the course