Derivatives
Read a derivative as the rate of change: how much the output moves per small nudge of the input.
What the animation says
Nudge the input
Here's a formula: x squared. Put in three, and out comes nine. Now nudge the input a little. Which way does the output move, and how far? How far it moves per unit of nudge is a single number: the derivative. A model is a huge program full of adjustable numbers. For each one, the derivative says which way to turn it, and how strongly the result reacts. So try it: nudge three up to three point one. Does the output move by point one too?
Rise over run
Three point one squared is nine point six one. The output rose point six one, for a nudge of point one. Divide them: rise over run. Point six one over point one gives six point one per unit of nudge. On a straight line, that rate is the same everywhere. On a curve, it depends on where you stand. So we take a tiny step. Think of a speedometer: it shows your speed right now, not your average over the trip.
Shrink the step
The size of the step, called h, still matters. With h of one, three goes to four and nine goes to sixteen: rate seven. With h of point one: rate six point one. With h of point zero one, the output is nine point zero six zero one: rate six point zero one. The rate is settling. The number it settles on as h shrinks toward zero is the derivative. One more: h of point zero zero one. What rate comes out?
It settles on 6
Six point zero zero one. Here's the same loop in Python. This line computes rise over run. As h shrinks, the rate goes seven, six point one, six point zero one, six point zero zero one. The odd trailing digits are just floating-point rounding. It settles on six: the derivative of x squared at three. In general it's two x. That's the power rule: x to the n gives n times x to the n minus one. The sign says which way the output moves. The size says how strongly.
Use it: predict a change
Now put the derivative to work. Move x from three to three point zero five. The nudge is point zero five. The derivative at three is six. So the output changes by about six times point zero five: point three. Where does the output land? Tap it.
What to remember
To predict a small change, take the output you know, and add the derivative times the nudge. Nine, plus six times point zero five, gives nine point three. The true value is nine point three zero two five, very close. The derivative is how much the output moves per tiny nudge. Its sign says which way; its size says how strongly.
Rise over run, for a tiny run
The definition, symbol by symbol
Derivative of x² at x = 3
Watch the fraction settle
def f(x):
return x ** 2
def rate(f, x, h):
return (f(x + h) - f(x)) / h
for h in [1, 0.1, 0.01, 0.001]:
print(h, rate(f, 3, h))
# 1 7.0
# 0.1 6.1000...
# 0.01 6.0099... (6.01 up to rounding)
# 0.001 6.0009... (6.001 up to rounding) -> approaches 6
What to remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses