Skip to content

5.2 — The Derivative

A car travels 120 km in 2 hours. Average speed: 60 km/h. Easy.

Now ask what its speed was at exactly 11:37 and 22 seconds. Not over an interval — at an instant. This is genuinely hard, and the difficulty is not practical but logical: speed is distance divided by time, and in an instant zero distance is covered in zero time. \frac{0}{0}, which Chapter 1.2 showed means nothing.

Yet the speedometer reads something. It is not lying, and the number it shows is real. Working out what that number is took from Zeno to Newton.

The answer: do not use an instant. Use a shrinking interval, and take the limit.

1. From average rate to instantaneous rate

Measure the average speed over the two seconds around 11:37:22. Then over one second. Then a tenth. Then a hundredth. The averages settle towards a particular number, and that number is the instantaneous speed.

Written generally, for a function f and a starting point x, the average rate of change over an interval of width h is

\frac{f(x+h) - f(x)}{h}

This is called the difference quotient. Now shrink h to nothing:

f'(x) = \lim_{h\to0}\frac{f(x+h)-f(x)}{h}

That is the derivative. It is the instantaneous rate of change of f at x, and it is a limit of exactly the \frac{0}{0} shape that Chapter 5.1 taught us to handle.

2. The geometric picture

On a graph, \frac{f(x+h)-f(x)}{h} is the gradient of the straight line through two points on the curve — a secant line, from the Latin for "cutting".

As h shrinks, the second point slides towards the first, and the secant pivots. In the limit the two points merge and the secant becomes the tangent — the line that touches the curve at that point and matches its direction.

\textbf{The derivative is the gradient of the tangent line.}

A curve with a secant line through two points and the tangent line at one point
The secant through two points, and the tangent at one. As the second point slides towards the first, the secant's gradient approaches the tangent's — and that limiting gradient is the derivative. Image: Wikimedia Commons.

So the derivative answers "how steep is the curve here", and the three cases are worth naming:

  • f'(x) \gt 0: the function is rising.
  • f'(x) \lt 0: falling.
  • f'(x) = 0: momentarily flat — a peak, a trough, or a level pause. Chapter 5.4 makes this the basis of optimisation.

3. Computing derivatives from the definition

Do this a few times by hand. After that, the rules of Chapter 5.3 take over — but the rules come from here, and having ground through the definition once makes them make sense.

Example 1: f(x) = x^2.

f'(x) = \lim_{h\to0}\frac{(x+h)^2 - x^2}{h} = \lim_{h\to0}\frac{x^2 + 2xh + h^2 - x^2}{h}

The x^2 terms cancel:

= \lim_{h\to0}\frac{2xh + h^2}{h} = \lim_{h\to0}\frac{h(2x+h)}{h} = \lim_{h\to0}(2x+h) = 2x

The cancellation of h is the whole trick, and it is legal because in the limit process h is never actually zero — only approaching it (Chapter 5.1, Section 1).

\frac{d}{dx}x^2 = 2x

At x=3 the gradient is 6. At x=0 it is 0, which matches the parabola's flat bottom.

Example 2: f(x) = \frac{1}{x}.

\lim_{h\to0}\frac{\frac{1}{x+h}-\frac{1}{x}}{h} = \lim_{h\to0}\frac{\frac{x - (x+h)}{x(x+h)}}{h} = \lim_{h\to0}\frac{-h}{h\,x(x+h)} = \lim_{h\to0}\frac{-1}{x(x+h)} = -\frac{1}{x^2}

Negative everywhere, which matches the fact that \frac{1}{x} always falls as x increases.

Example 3: f(x) = c, a constant.

\lim_{h\to0}\frac{c - c}{h} = \lim_{h\to0}\frac{0}{h} = 0

A flat line has zero gradient. Nothing changes, so the rate of change is zero.

4. Notation, and why there are three kinds

Three notations are in use, and each is better for something. You need to read all three.

Lagrange: f'(x), read "f prime of x". Compact. Higher derivatives are f'', f''', then f^{(4)}.

Leibniz: \frac{dy}{dx}, read "dee y by dee x". Verbose but it names the variables, and it looks like a fraction in a way that makes the chain rule of Chapter 5.3 almost self-evident. It is not literally a fraction, but Leibniz designed the notation so that treating it as one gives correct answers, and that design has held up for three hundred years.

Newton: \dot{y}, a dot above. Used in physics for derivatives with respect to time only, so \dot{x} is velocity and \ddot{x} is acceleration.

Newton called his version "fluxions" and got there first, around 1665. Leibniz published first, in 1684, with better notation. The priority dispute poisoned relations between British and Continental mathematicians for a century, and British mathematics fell behind precisely because it stuck with Newton's clumsier notation out of loyalty.

Portrait of Gottfried Wilhelm Leibniz
Gottfried Wilhelm Leibniz (1646–1716), who invented the notation we still use — the dy/dx and the elongated S of the integral sign. He and Newton discovered calculus independently, and the ugly priority fight that followed damaged both mathematics and their reputations. Image: Wikimedia Commons.

5. When a derivative does not exist

Not every function has a derivative everywhere, and the failures are instructive.

A corner. f(x) = |x| at x=0. Approaching from the right the gradient is +1; from the left it is -1. The one-sided limits disagree, so the derivative does not exist. There is no single tangent line at a sharp corner — you cannot say which way the curve is pointing.

A vertical tangent. f(x) = \sqrt[3]{x} at x=0 has a tangent that is vertical, and a vertical line has undefined gradient (Chapter 3.4).

A jump. Where the function is not continuous, it cannot be differentiable. Differentiable implies continuous, though not the reverse — the corner case above is continuous and not differentiable.

A curve that is a corner everywhere

Weierstrass constructed a function in 1872 that is continuous everywhere and differentiable nowhere — infinitely wrinkled at every scale, so no point has a tangent.

It caused genuine dismay. Hermite called such functions "a lamentable plague". The prevailing assumption had been that a continuous curve must be smooth except at a few bad points, and that intuition turned out to be simply false.

Then it turned out to describe reality. The path of a pollen grain in water, a share price over time, and a coastline (Chapter 3.6) are all continuous and nowhere smooth. The mathematics of Brownian motion — which Einstein used in 1905 to prove atoms exist, and which underlies the Black–Scholes model of option pricing — is built on exactly these functions.

6. The second derivative

Differentiate the derivative and you get the second derivative, f''(x) or \frac{d^2y}{dx^2}. It is the rate of change of the rate of change.

For motion: position, then velocity, then acceleration. And acceleration is what you physically feel — you cannot sense speed (a smooth aircraft at 900 km/h feels like standing still) but you certainly sense acceleration. Newton's second law, F = ma, says force is proportional to the second derivative of position, which is why all of physics is written in second-order differential equations (Chapter 6.2).

Geometrically, the second derivative measures concavity:

  • f'' \gt 0: the curve bends upward, holding water, like a valley.
  • f'' \lt 0: it bends downward, like a hill.
  • f'' = 0 with a sign change: an inflection point, where the bending switches direction.

A concrete reading. If a country's infection numbers are rising (f' \gt 0) but the rise is slowing (f'' \lt 0), the peak has not arrived but the turn has begun. "Flattening the curve" was a statement about the second derivative, and it is why the distinction mattered so much in 2020.

Beyond the second, the derivatives of position have names that are half-joking and genuinely used: the third is jerk, and lift designers and roller-coaster engineers limit it, because a sudden change in acceleration is what makes a ride unpleasant. The fourth, fifth and sixth are called snap, crackle and pop.

Every formula above, built from scratch

None of the results in this chapter are worth memorising, because each one can be rebuilt in under a minute from something simpler. What follows is that rebuilding, one result at a time, so the formula and the reason for it sit on the same page as the explanation that needed them.

The derivative

f'(x) = \lim_{h\to0}\frac{f(x+h)-f(x)}{h}

Read it aloud. "f prime of x is the limit, as h goes to zero, of f of x plus h minus f of x, all over h."

What it says. The fraction is the gradient of the line joining two nearby points on the curve — rise over run. Let the second point slide towards the first, and the chord becomes the tangent. The derivative is that limiting gradient: the instantaneous rate of change.

The notations f'(x), \frac{dy}{dx}, \dot y and Df all mean this. Leibniz's \frac{dy}{dx} is the most useful because it remembers what is changing with respect to what, and because it behaves correctly under the chain rule.

Every basic derivative, from the definition

Powers: \dfrac{d}{dx}x^n = nx^{n-1}.

Take n=3 and watch the mechanism, which is identical for any n:

\frac{(x+h)^3 - x^3}{h} = \frac{x^3 + 3x^2h+3xh^2+h^3 - x^3}{h}

The x^3 terms cancel. Every surviving term has a factor of h, so divide it out:

= 3x^2 + 3xh + h^2

Now let h\to0. The last two terms vanish, leaving 3x^2.

For general n, the binomial theorem of 2.2 — polynomials gives (x+h)^n = x^n + nx^{n-1}h + (\text{terms with } h^2 \text{ or higher}). The x^n cancels, dividing by h leaves nx^{n-1} + (\text{terms still carrying } h), and those vanish. The whole power rule is the second term of the binomial expansion.

Sine: \dfrac{d}{dx}\sin x = \cos x.

\frac{\sin(x+h)-\sin x}{h}

Expand with the addition formula \sin(x+h) = \sin x\cos h + \cos x\sin h:

= \frac{\sin x\cos h + \cos x\sin h - \sin x}{h} = \sin x\cdot\frac{\cos h - 1}{h} + \cos x\cdot\frac{\sin h}{h}

Two known limits finish it. The second bracket goes to 1, as proved above. The first goes to 0 — because \cos h \approx 1 - \frac{h^2}{2}, so \frac{\cos h - 1}{h}\approx -\frac h2 \to 0. Therefore:

\frac{d}{dx}\sin x = \sin x\cdot 0 + \cos x\cdot 1 = \cos x

The same argument on cosine gives \frac{d}{dx}\cos x = -\sin x, the minus arriving because \cos(x+h) = \cos x\cos h - \sin x\sin h.

The exponential: \dfrac{d}{dx}e^x = e^x.

\frac{e^{x+h}-e^x}{h} = \frac{e^x e^h - e^x}{h} = e^x\cdot\frac{e^h-1}{h}

The factor e^x comes straight out because e^{x+h} = e^xe^h. The remaining limit is 1 by definition of e. So the derivative is e^x itself.

This is the only function that is its own derivative, up to a constant multiple, and it is why e appears in every growth and decay law: those laws all say "the rate of change is proportional to the amount present", which is the equation y' = ky.

The logarithm: \dfrac{d}{dx}\ln x = \dfrac1x.

Rather than the definition, use the inverse relationship. Let y = \ln x, so x = e^y. Differentiate both sides with respect to x, using the chain rule on the right:

1 = e^y\frac{dy}{dx} \quad \Rightarrow \quad \frac{dy}{dx} = \frac{1}{e^y} = \frac1x

Why this is a small miracle. The family x^n has derivatives nx^{n-1}, so differentiating produces the powers \ldots, x^{-3}, x^{-2} but never x^{-1}, because that would need n = 0 and then the n out front kills it. The gap at x^{-1} is filled by a function from a completely different family. That is why \int\frac1x dx = \ln|x| and not a power.

7. Where this shows up in your life

Every speedometer, tachometer and rate display. All derivatives.

Every "rate of change" in the news. Inflation is the derivative of the price level. A slowing rise in cases is a second derivative. Growth rates, acceleration, momentum — all this chapter.

Every optimisation. Finding a maximum or minimum means finding where the derivative is zero, and Chapter 5.4 does this properly.

Every machine learning model that trains. Backpropagation computes the derivative of the error with respect to every weight, then steps downhill. Volume I, 12.4 covers it, and the chain rule of Chapter 5.3 is what makes it possible.

Every physical simulation. Games, weather, crash tests and orbital mechanics all step forward by computing rates of change.

Every smooth animation curve. Easing functions are chosen so that the velocity and often the acceleration are continuous, because a discontinuous derivative looks jerky to the eye.


Computing every derivative from the definition would be unbearable. Fortunately a handful of rules covers everything, and they compose so cleanly that any function you can write down can be differentiated mechanically.