Skip to content

The normal equations

When Ax = b has no solution, find the x̂ that minimizes |Ax − b|² by solving AᵀA x̂ = Aᵀb, and read the error e = b − Ax̂ as orthogonal to every column of A.

It opens on

Three points do not lie on one line, so no C and D make C + Dx pass through all of them: which line is best, and what does best even mean?

Why it matters

Real measurements never fit a model exactly; the normal equations are the single recipe that gives the best line, plane or curve through noisy data.

Good to know first

  • Projection onto a subspace: p = Ax̂ with e orthogonal to the columns
  • Column space and null space: Ax = b is solvable only for b in C(A)
  • Matrix-vector multiplication: Ax is a combination of the columns

Step by step

  1. No solution: minimize the squared error

    Show that Ax = b has no solution for three non-collinear points, define E = |Ax − b|², and minimize it by calculus.

    Row 1 gives C = 6, row 2 gives C + D = 0 so D = −6, and then row 3 asks C + 2D = −6 to equal 0: no solution, because b is not in the column space.

    A common mix-up

    The best line is the one through the most points.

    In fact: No line passes through two of these points and does better; squared gaps are balanced across all three.

  2. The same equations from geometry

    Derive AᵀA x̂ = Aᵀb from the requirement that the error is orthogonal to the column space, and solve it for the thread.

    With a₁ = (1, 1, 1) and a₂ = (0, 1, 2): AᵀA = [[a₁·a₁, a₁·a₂], [a₂·a₁, a₂·a₂]] = [[3, 3], [3, 5]] and Aᵀb = (6, 0).

    A common mix-up

    The normal equations are Ax̂ = b with both sides multiplied by something unnecessary.

    In fact: AᵀA x̂ = Aᵀb is the exact condition, and multiplying Aᵀ in turns an unsolvable system into a solvable one.

  3. Reading the answer on new data

    Interpret x̂, p and e, check Aᵀe = 0 as residual properties, and see when AᵀA is invertible.

    The first normal equation, 1·e = 0, says the residuals sum to zero: 1 − 2 + 1 = 0.

    A common mix-up

    The best line must have some residual equal to zero.

    In fact: The residuals (1, −2, 1) are all nonzero; only their weighted sums vanish.

Try it

Write A and b for the points (0, 1), (1, 1), (2, 4) and test whether Ax = b is solvable.Answer

A = [[1, 0], [1, 1], [1, 2]], b = (1, 1, 4); not solvable, since C = 1 and C + D = 1 give D = 0 but then C + 2D = 1 ≠ 4

Hint: Use rows 1 and 2 first

Form AᵀA and Aᵀb for A = [[1, 0], [1, 1], [1, 2]] and b = (1, 1, 4).Answer

AᵀA = [[3, 3], [3, 5]] and Aᵀb = (6, 9)

Hint: a₂·b = 0 + 1 + 8

Explain in a sentence why the residuals of the best line with a constant term sum to zero.Answer

The first column of A is all ones and e is orthogonal to it, so the sum of the residuals is 1·e = 0

Hint: Which row of Aᵀe = 0 is that?

What is E for the line through the two end points, C = 6 and D = −3?Answer

0 + 9 + 0 = 9.

Check that e is orthogonal to both columns: what are a₁·e and a₂·e?Answer

1 − 2 + 1 = 0 and 0 − 2 + 2 = 0.

The normal equations

30 minutes every month. No card.