Lesson 3.3 · 15 of 25 lessons

Least squares

Carry the right angle created by a dot product into projection and least-squares error.

Open the interactive animation

01 · Story

What to verify in this scene

Follow the explanations and operations, then identify the mathematical evidence that remains in the final scene.

  1. 01

    When target b is not on direction a, choose its closest shadow p

  2. 02

    Add residual e to p to reconstruct the original target b

  3. 03

    dot(a, e) = 0
    A least-squares residual is orthogonal to the chosen subspace

02 · Notebook

The runnable notebook

This source creates the mathematical objects and controls the order of operations and animation. Read it here, then play the same scene yourself.

2d
zoom 4/5
coordinates on
2, 1  #a@
point(2, 3)  #b@
14/5, 7/5  #p@
// When target {{b}} is not on direction {{a}}, choose its closest shadow {{p}}
focus a p b
checkpoint Least squares

focus -
-4/5, 8/5  #e@
// Add residual {{e}} to {{p}} to reconstruct the original target {{b}}
sum(p, e)  #rebuild@
dot(a, e)  #ortho@
// `dot({{a}}, {{e}}) = 0`\nA least-squares residual is **orthogonal** to the chosen subspace
focus a e
Open the interactive animation

03 · Unit 3

Lessons in this unit

Orthogonality, projection & least squares — Carry the right angle created by a dot product into projection and least-squares error.

  1. 3.1Dot products & orthogonality
  2. 3.2Projection
  3. 3.3Least squares