A car's speedometer shows one number, now. Yet speed is a
distance divided by a time, and at one instant no time passes and no distance
is covered. The goal of this lesson is to resolve that puzzle with the previous lesson's limits: an
average over a shrinking interval settles on a number, and that number is the
derivative, the rate of change at an instant. You
will compute derivatives by hand, see them as the
slope of a curve, and watch a computer approach them with
differences. You need the
limit of a function.
Average speed over a shrinking interval
Drop a stone. After t seconds it has fallen about s(t) = 4.9t² metres (the 4.9
is half of 9.8, the acceleration of a falling body,
which Physics measures). How
fast is it going at the instant t = 1?
Over any interval of time there is an average speed, the distance fallen
divided by the time taken. Over the second from t = 1 to t = 2 the stone falls
s(2) − s(1) = 19.6 − 4.9 = 14.7 metres, an average of 14.7 m/s. Shrink the
interval to run from 1 to 1 + h, for smaller and smaller h:
h (seconds)
1
0.1
0.01
0.001
average speed (m/s)
14.7
10.29
9.849
9.8049
The averages close in on 9.8, and algebra says why. The distance fallen between
1 and 1 + h is 4.9(1 + h)² − 4.9 = 4.9(2h + h²), so the average speed is
4.9(2h + h²) ÷ h = 9.8 + 4.9h
for every h other than 0. As h tends to 0 this tends to 9.8: the stone's
speed at the instant t = 1 is 9.8 m/s. No instant was divided by zero; the
answer is the limit of averages, each of which is an honest distance over an
honest time.
The rate of change of any function
The same recipe works for any function f. The change in f from a to a + h,
divided by the change in the input, is the
average rate of change of f over
that interval:
(f(a + h) − f(a)) ÷ h
Books often write a change with the Greek capital Δ ("delta"): Δx for a change
in x, Δf for the change it causes in f, so the average rate is Δf ÷ Δx. Now let
the interval shrink:
f′(a) = lim (f(a + h) − f(a)) ÷ h, as h → 0
When this limit exists it is the derivative of f at a,
written f′(a) and read "f prime of a", and f is a
differentiable function at a. The
derivative is the instantaneous rate of change: how fast f is changing at
the input a, in units of f per unit of input. For the stone, s′(1) = 9.8 m/s.
As in the previous lesson's definition of a limit, h tends to 0 but is never
0, so the quotient always makes sense.
Another notation, Leibniz's, writes the derivative of y = f(x) as dy/dx, a
reminder that it began as Δy ÷ Δx. Physics writes the velocity of a
body at position x as v = dx/dt, the derivative of
position with respect to time: that is the velocity of the physics lessons, and
this lesson is where it comes from.
The slope of a curve
There is a picture behind the formula. The
slope of a straight line is its rise divided by its run:
a line that climbs 3 for every 2 across has slope 3/2, a flat line has slope 0,
and a falling one a negative slope.
On the graph of f, the straight line through the two points (a, f(a)) and
(a + h, f(a + h)) is a chord of the curve. Its rise is
f(a + h) − f(a) and its run is h, so the slope of the chord is the average
rate of change. As h shrinks, the second point slides along the curve towards
the first and the chord swings round. The line it settles on, through (a, f(a))
with slope f′(a), is the tangent line: the line
that touches the curve at that point and runs in the curve's direction there.
So the derivative has two readings, one per audience: a rate (metres per
second, euros per year) and a slope (how steep the graph is). They are the
same number.
The lesson on e found one already: the chord of y = eˣ from (0, 1) to
(h, eʰ) has slope (eʰ − 1) ÷ h, squeezed towards 1. In this lesson's words, the
derivative of eˣ at 0 is 1.
Derivatives by hand: x², x³ and the pattern
Take f(x) = x² at any point x. Multiplying out, (x + h)² − x² = 2xh + h², so
(f(x + h) − f(x)) ÷ h = 2x + h, which tends to 2x.
The derivative is a new function: f′(x) = 2x. At x = 3 the curve y = x²
climbs with slope 6; at x = 0 it is flat; at x = −1 it falls with slope −2. The
stone is the same calculation with 4.9 in front: s′(t) = 9.8t, which is 9.8 at
t = 1.
For f(x) = x³, (x + h)³ = x³ + 3x²h + 3xh² + h³, so the quotient is
3x² + 3xh + h², which tends to 3x². The pattern continues for every whole
number n, and it is called the power rule:
the derivative of xⁿ is n xⁿ⁻¹
with two plain cases at the start of it: a constant function c has derivative
0 (it never changes), and the line x has derivative 1.
Why the power rule holds for every whole number n
Write (x + h)ⁿ as the product of n brackets (x + h)(x + h)⋯(x + h) and multiply
out by taking either x or h from each bracket. Taking x from every bracket gives
xⁿ. Taking h from exactly one bracket and x from the other n − 1 gives xⁿ⁻¹h,
and there are n ways to choose which bracket, so n xⁿ⁻¹h in all. Every other
choice takes h from two brackets or more, so it contains h² at least. Hence
(x + h)ⁿ − xⁿ = n xⁿ⁻¹h + (terms with h² or a higher power)
Divide by h: n xⁿ⁻¹ plus terms that each still contain h, and those tend to 0.
The quotient tends to n xⁿ⁻¹.
Where there is no derivative
The function |x|, the distance of x from 0, is x for x ≥ 0 and −x below. At 0
its graph has a corner. Chords to the right of 0 have slope (|h| − 0) ÷ h = 1;
chords to the left have slope −1. Two sequences of h tending to 0 give two
different limits, so the limit does not exist: |x| is continuous at 0 but not
differentiable there.
The other way round always works: a function differentiable at a is continuous
at a. Write f(a + h) − f(a) as h × (f(a + h) − f(a)) ÷ h; as h → 0 that is a
quantity tending to 0 times one tending to f′(a), so the difference tends to 0.
Compute to see: differences
A computer cannot take a limit, but it can take a small h. The quotient
(f(x + h) − f(x)) ÷ h with a fixed small h is a
finite difference, here a
forward difference, which looks only ahead.
A better one looks both ways, the
central difference
(f(x + h) − f(x − h)) ÷ 2h. For f(x) = x³ at x = 2, where the derivative is
3 × 2² = 12:
h
forward
central
0.1
12.61
12.01
0.01
12.0601
12.0001
0.001
12.006001
12.000001
The forward difference here is exactly 12 + 6h + h², so its error shrinks like
h: ten times smaller h, about ten times smaller error. The central difference is
exactly 12 + h², so its error shrinks like h²: ten times smaller h, a hundred
times smaller error.
Then the computer bites back. It stores about sixteen significant digits, so
subtracting two nearly equal numbers throws most of them away:
def f(x):
return x ** 3
h = 1e-15
print((f(2 + h) - f(2)) / h) # 10.658141036401503
The machine cannot even store 2 + 10⁻¹⁵ exactly, and the answer is wrong in the
second digit. This is rounding error, the error a computer makes by keeping
only about sixteen digits of every number. Below some h it grows faster than the
limit closes in, so the smallest h is not the best one. The derivative itself, the limit, has
no such problem: it is exact, and the computer only approximates it. Compute to
see, prove to know.
Check yourself
Loading the exercise...
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Images, PDF or text. Kept on this device only.
Keeping your files on this device
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Ctrl/Cmd + Enter to send
🎓 Practice ladder
2 graded rungs · ~25 min
Two coding rungs in your browser, in a little Python
(Beginner Python teaches it): differences that close in on a
derivative, then how small a step should be.
Rung 1 — average rates over shrinking intervals
Loading exercise…
Rung 2 — forward or central, and how small a step
Loading exercise…
My notes on this module
Loading your notes...
The derivative as a rate of change — TransformerLab