The only calculus you need

Which way is downhill, and how steep? Drag a ball on a curve and read its tilt. That tilt is the whole of the calculus you need — single variable, no fear.

Updated 25 May

The only calculus you need

In Module 2 you set a knob. In Module 3 you shrank the mistake by hand — and an algorithm did it by rolling downhill. That left one open question: at any given spot, which way is downhill? Answering it is the whole of the calculus you need here.

Which way should I move?

Picture the loss as a bowl and your knob as a ball resting on it. Drag the ball.

w (the knob)lossbottom
Drag the ball along the curve.steepness (slope): -5.0downhill is right →
  • On the left wall → downhill is right.
  • On the right wall → downhill is left.
  • At the bottom → nowhere to go; you're done.

You knew which way to move without a single equation. That instinct is the idea.

The local tilt tells you everything

Look at the short coloured line that grazes the curve under the ball — its tilt. Drag the ball and watch it rotate. That tilt carries two facts:

  • which way it leans → which way is downhill (the arrow),
  • how steep it is → how big a step to take.

And notice: the grazing line only cares about right here. Zoom in on any point and the curve looks almost straight — the tilt is local feedback, nothing more.

Sign → direction. Leans up to the right (a positive slope, red) → go left. Leans down to the right (negative, blue) → go right. Flat (≈ 0, green) → you're at the bottom.

Micro-challenges — drag the ball until:

  1. the slope is positive (red),
  2. the slope is negative (blue),
  3. the slope is ≈ 0 (green, flat).

You already do this

You read slopes all day without calling it math:

  • leaning into a steep road on a bike,
  • easing off as the hill flattens,
  • nudging a shower knob hotter — gently, as it gets close.

You constantly sense direction and steepness. That sense is the entire concept.

The same tilt, as one number

The widget shows the tilt as a picture; here it is as a single number. Edit w and run.

Predict first: at w = 0, is the slope positive or negative — and should we step left or right?

Python
First run loads the Python runtime (~10 MB) — takes ~5–10 seconds. Subsequent runs are instant.

That one number — which way + how steep — is everything you need. It has a name: the slope of the curve at that point. In calculus it's called the derivative, written dL/dw ("how the loss L changes as the knob w changes"). The symbol is just shorthand for the tilt you've been dragging — a label for an idea you already own.

Good news

Almost all of modern machine learning is built from this one move:

  1. measure the local slope,
  2. step downhill,
  3. repeat.

Deep learning does exactly this — just with millions of knobs at once instead of one. Same instinct, more dimensions. And the instinct is already yours.

Test your understanding

Prof is ready

Prof will ask you questions about the derivative as local slope: which way is downhill and how steep — not explain it. You'll be surprised what you don't know until you have to say it.

Finished this lesson?

Read through the lesson first (0/20s).