Index Ai Academy
Foundation · Foundation mathCalculus

The derivative: slope at a point

About 45 minLooking ahead: some prerequisites aren't done yet

Why this matters

A rate across an interval, from lesson 70, depends on the interval you choose. The derivative removes that choice: shrink the interval toward zero and, for a smooth function, the average rate settles on one number, the slope at that exact point. That number answers the most useful question in all of machine learning. If I nudge this weight up a little, does the loss go up or down, and by how much? Training a model asks it millions of times, once for every weight at every step. This lesson builds the derivative from shrinking secants, by hand and in a few lines of Python, then asks it of a real loss.

  • Find the slope at a single point by shrinking a secant until its slope settles
  • Read the derivative as a new function, f′(x) or dy/dx, and use Δy ≈ f′(x)·Δx
  • Estimate derivatives in Python with slope(f, x, h) and a small h
  • Ask a loss the question training asks: if this weight goes up a little, does the loss go up or down?
Quick check
Have a guess before you start. A car's speedometer reads 50 km/h. Is that an average over the whole trip, or the speed right now?

The math: shrink the gap

Purpose. The rate of change at one instant.

Take f(x) = x² and ask for its slope at x = 3. Pick a small step h and compute the secant's slope, (f(3 + h) − f(3)) ÷ h. As h shrinks, the slopes are 7, 6.1, 6.01, 6.001: they settle on 6. That settled value is the derivative of f at 3, the slope of the tangent, the line that just touches the curve there.

f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}

In plain words: the slope of a secant, as its two points slide together. Lesson 71's limit is what lets h head to 0 without ever being 0.