The closed form: normal equations

Find the bottom of the least-squares bowl in one step — derive the normal equations twice, by calculus and by a right angle, and learn when the famous formula breaks and what libraries do instead.

40 min

After this lesson you can

  • Derive by setting the gradient of the squared error to zero
  • Derive the same equations geometrically, as an orthogonal projection onto the column space of
  • Read every symbol of and check its shapes
  • Recognise when is singular or ill-conditioned, and what the pseudoinverse and minimum-norm solution do then
  • Explain the cost and why numerical code uses QR or the SVD instead of an inverse

In this lesson

  1. Setting up
  2. Derivation 1: set the gradient to zero
  3. Derivation 2: a right angle
  4. Decoding (X⊤X)−1X⊤y
  5. When the formula breaks
  6. Cost, and what libraries actually do
  7. In code

This lesson is part of Descent Pro

Descent Pro unlocks every lesson on the route, from base camp to the summit. Every plan starts with a free trial.

Descent Pro

Start your free trial to keep reading

This lesson, and every other lesson on the route, is part of Descent Pro. Every plan starts with a free trial, and students with a .edu email get longer. Cancel before the trial ends and you pay nothing.