Mathematics RU

Part IV · Calculus Chapter 26 of 60

The derivative

What does a speedometer really show? Let’s get into a car with a dashcam, turn average speed into instantaneous speed, and learn to find the slope of any smooth graph at any of its points.

Ages 16–18 50 minutes

Builds on: 25 · Limits

You will learn

  • understand the derivative as instantaneous speed and as the slope of a tangent
  • find derivatives with the sum, product, quotient and chain rules
  • know where the derivatives of the sine, the exponential and the logarithm come from, and draw a tangent to a graph

The last chapter ended with a promise. A stone dropped from a tower is falling at $10$ m/s one second after release: that’s the number the average speeds $10 + 5h$ tend to as the stretch of time $h$ shrinks to zero. Such a limit has a name, the derivative, and, as we said, a speedometer needle shows it. Let’s test the promise on the road. The needle is at sixty, and everyone understands what that means. But what exactly? In a single instant the car doesn’t move anywhere. Zeno of Elea already argued about the flying arrow: at each moment it occupies a space equal to itself, that is, it’s at rest. So where does motion come from?

Take a car, a speedometer and a dashcam that stamps the exact time on every frame. From the frames you can compute the average speed between any two moments. Let’s bring the frames closer together and watch where the average speeds go. The limit we find is the speedometer reading. It’ll also turn out to be the slope of a graph, the rate of growth of anything at all, and the main tool of the whole of calculus. And along the way we’ll derive rules that let us find such limits almost without thinking about limits.

What the needle shows

The light turns green, and the car moves off with a constant acceleration of $2$ m/s². The distance it covers in $t$ seconds is $s(t) = t^2$ metres: one metre in the first second, four in two, twenty-five in five. What will the speedometer show exactly five seconds after the start?

The dashcam knows time and position, so it can compute average speed, just as we did for the stone: distance covered divided by the time it took. Take the frames at $5$ s and $6$ s. The car was at the $25$ m and $36$ m marks, covered $11$ metres in a second, and its average speed is $11$ m/s. But during that second the car was speeding up, so at $t = 5$ it was going slower. Bring the frames closer: between $5$ and $5.1$ seconds the car covered $5.1^2 - 25 = 1.01$ metres, an average speed of $1.01 : 0.1 = 10.1$ m/s. Between $5$ and $5.01$ we get $10.01$ m/s, between $5$ and $5.001$, $10.001$ m/s.

The pattern can be seen in general too. If the frames are $h$ seconds apart, the average speed is

$$\frac{s(5 + h) - s(5)}{h} = \frac{(5 + h)^2 - 25}{h} = \frac{10h + h^2}{h} = 10 + h.$$

For any $h \ne 0$ the average speed differs from $10$ by exactly $h$. There’s no need to divide by zero: we divide by a non-zero $h$ and only then look at what the result tends to as $h$ tends to zero. That’s a limit, and it equals $10$ m/s, that is, $36$ km/h. That’s exactly the number the speedometer shows.

Instantaneous speed at the moment $t$ is the limit of the average speed over the stretch from $t$ to $t + h$ as $h$ tends to zero: $v(t) = \lim\limits_{h \to 0} \frac{s(t + h) - s(t)}{h}$.

Zeno is right about one thing: you can’t tell speed from a single frame. But speed doesn’t live in a single frame. It lives in how the average speeds behave over shorter and shorter stretches around that frame. The second frame can be taken before the first too, with negative $h$: the average speeds $10 - 0.1$, $10 - 0.01$, $10 - 0.001$ close in on the same number from below.

Shrink the interval $h$ between frames and watch the two speedometer needles: orange is the average speed between the frames, purple the instantaneous speed. Drag the point $P$ along the graph or press “Drive”. On the second trip the car speeds up and then brakes before the next traffic light.

The table under the speedometer shows how fast the average speeds close in on the instantaneous one. When accelerating, $s = t^2$, the difference is exactly $h$. On the trip from light to light it also shrinks roughly tenfold with each row, although the formula for the distance is more complicated there.

The secant becomes a tangent

Draw the distance as a graph: time horizontally, metres covered vertically. Two frames are two points of the graph, $P(5, 25)$ and $Q(6, 36)$. The average speed $\frac{36 - 25}{6 - 5}$ equals the slope of the line $PQ$, the ratio of rise to run. That’s the very slope from the chapter on functions. A line through two points of a graph is called a secant. As $Q$ slides along the graph towards $P$, the secant turns about $P$ and in the limit settles into a position that we’ll call the tangent. The instantaneous speed is its slope.

The word “tangent” is familiar from the circle: there it’s a line that has exactly one point in common with the circle. For graphs this definition won’t do. The line $x = 1$ meets the parabola $y = x^2$ at exactly one point, but it can’t be called a tangent. And the line $y = 0$ touches the cubic $y = x^3$ at the origin and yet passes right through it.

Which statement about the tangent to a graph is true?

The tangent to a graph is defined through a limit, just like instantaneous speed. Everything we knew about the tangent to a circle stays true for the circle, but needn’t be true for graphs.

All that’s left of the car is a function and its graph, so let’s say the same thing for any function. Instead of time, let it be $x$; instead of distance, $f(x)$.

The derivative of a function $f$ at a point $x$ is the limit $f'(x) = \lim\limits_{h \to 0} \frac{f(x + h) - f(x)}{h}$, if it exists and is finite. A function that has a derivative at a point is called differentiable at that point, and finding the derivative is called differentiation.

The step shrinks towards zero but never becomes zero: at $h = 0$ the fraction makes no sense, and the limit describes what happens near zero. The increment of the function, the rise of the secant. It’s often written $\Delta f$ or $\Delta y$. The increment of the argument, the run, $\Delta x$. It can be negative: then the secant’s second point lies to the left of the first. Example: for $f(x) = x^2$ at $x = 3$ we get $\frac{(3 + h)^2 - 9}{h} = \frac{6h + h^2}{h} = 6 + h \to 6$. So $f'(3) = 6$: at this point the parabola rises by about $6$ units for every unit to the right.

The tangent to the graph of a function $f$ at the point $(a, f(a))$, where $f$ is differentiable, is the line through this point with slope $f'(a)$.

The height of the point of contact: at $x = a$ the bracket vanishes, and the line passes through $(a, f(a))$. The slope of the tangent: the derivative at the point of contact. The $x$-coordinate of the point of contact. Example: the tangent to $y = x^2$ at $a = 3$: $y = 9 + 6(x - 3) = 6x - 9$. Check: the equation $x^2 = 6x - 9$, that is, $(x - 3)^2 = 0$, has the single root $3$, and for all other $x$ the parabola lies above the line.

Find from the definition the derivative of $f(x) = x^2 - 4x$ at $x = 1$.

$f(1 + h) - f(1) = (1 + h)^2 - 4(1 + h) - (1 - 4) = 1 + 2h + h^2 - 4 - 4h + 3 = h^2 - 2h$. Divide by $h$: we get $h - 2$, and as $h \to 0$ this tends to $-2$. So $f'(1) = -2$: at $x = 1$ the parabola is going down.

The magnifying glass

There’s another way to see the tangent, and it’s perhaps the most honest. In the last chapter the microscope showed that near zero the sine wave hardly differs from the line $y = x$ (the fundamental trigonometric limit). Every smooth graph behaves like that. Take a magnifying glass and look at a small piece of a smooth graph around a point $P$. The stronger the magnification, the straighter the piece looks, and at a millionfold magnification it can’t be told from a segment. This segment lies on the tangent, and its slope equals the derivative.

Choose a function and press “Zoom in”. The sine wave straightens out. The kink in $|x^2 - 1|$ stays a kink, the cube root turns into a vertical line, and the blancmange stays spiky at any magnification. At ×1 you can move the point $P$.

This property is called local linearity: near a point a differentiable function is almost linear. “Almost” here means something precise. By the definition of the derivative $\frac{f(a + h) - f(a)}{h} = f'(a) + \varepsilon$, where the correction $\varepsilon$ tends to zero along with $h$. Multiply by $h$:

$$f(a + h) = f(a) + f'(a)\,h + \varepsilon h.$$

The first two terms are the tangent, the last is the error. It’s small even compared with the small $h$: at $h = 0.001$ the error is a tiny fraction of a thousandth. That’s why under the glass the graph and the tangent merge. Mental estimates rely on this. To find $\sqrt{4.1}$, take $f(x) = \sqrt x$ near the point $a = 4$. The derivative of the square root, as we’ll soon find, is $\frac{1}{2\sqrt x}$, which at $4$ is $\frac14$. So $\sqrt{4.1} \approx 2 + \frac14 \cdot 0.1 = 2.025$, and the exact value $2.02485\ldots$ differs by less than two ten-thousandths.

Estimate $\sqrt[3]{8.1}$ with the tangent, given that the derivative of $\sqrt[3]{x}$ at $x = 8$ is $\frac{1}{12}$. Round the answer to four decimal places.

$\sqrt[3]{8.1} \approx \sqrt[3]{8} + \frac{1}{12} \cdot 0.1 = 2 + 0.00833\ldots \approx 2.0083$. A calculator gives $2.00830$, so the tangent was off by less than a ten-thousandth.

The magnifying glass also shows how a derivative can fail to exist. The first way is a kink. The function $|x|$ is continuous at zero, but the secants on the right have slope $1$ and on the left $-1$: the one-sided limits differ. Under the glass the kink doesn’t straighten, because $|x|$ doesn’t change when stretched: magnify the picture around zero a thousand times and you get the same letter V. The second way is a vertical tangent, as with $\sqrt[3]{x}$ at zero: the secants get steeper and steeper, and their slope runs off to infinity, and infinity isn’t a number.

The third way astonished nineteenth-century mathematicians. In 1872 Karl Weierstrass presented to the Berlin Academy a function that is continuous everywhere and has no derivative at any point: its graph consists of nothing but kinks. The example in the widget is the “blancmange”, constructed in 1903 by the Japanese mathematician Teiji Takagi. It’s the sum of infinitely many saw-tooth “saws”, each half as tall and twice as frequent as the one before: $\sum_{n = 0}^{\infty} \frac{d(2^n x)}{2^n}$, where $d(y)$ is the distance from $y$ to the nearest integer. However much you magnify, new kinks appear from under each kink.

So a continuous function needn’t be differentiable. But a differentiable one is always continuous.

If a function $f$ has a derivative at a point $x$, then $f$ is continuous at that point: $f(x + h) \to f(x)$ as $h \to 0$.

The idea: the increment of the function is the average slope times the step, and the step tends to zero. For $h \ne 0$ the identity $f(x + h) - f(x) = \frac{f(x + h) - f(x)}{h} \cdot h$ holds. The first factor tends, by hypothesis, to the number $f'(x)$, and the second to zero. The limit of a product is the product of the limits (the arithmetic of limits), so the right side tends to $f'(x) \cdot 0 = 0$. So $f(x + h) - f(x) \to 0$, that is, $f(x + h) \to f(x)$, which is the definition of continuity at the point $x$.

A speedometer for the whole trip

A speedometer works not at one point but all the way. If at each point $x$ you record the value $f'(x)$, you get a new function: the derivative of $f$. For $s(t) = t^2$ it’s $v(t) = 2t$: we did the calculation for $t = 5$, but it didn’t depend on the time being five. In general $\frac{(t + h)^2 - t^2}{h} = 2t + h \to 2t$.

The graphs of $f$ and $f'$ are related like a record of the distance and a record of the speedometer. Where $f$ grows, the tangents go up and $f'$ is positive. Where $f$ decreases, $f'$ is negative. At the top of a hill and the bottom of a dip the tangent is horizontal and $f' = 0$. Where the graph is steeper, $|f'|$ is larger. Why the sign of the derivative controls the growth of the function (it’s less obvious than it seems) will be proved in the next chapter. For now let’s learn to read one graph from the other.

For each of the seven points guess the slope of the graph and set it on the lower graph. The selected point is accompanied by an orange ruler on the upper graph: line it up with the tangent. “Check” shows the true derivative.

On the “step” the derivative looks like a hill: it’s largest in the middle, where the graph is steepest, and almost zero at the edges, where it’s almost horizontal, although the graph itself is nowhere near zero there. Confusing the value of a function with its rate of change is the most common mistake in reading graphs, from school problems to stock-market reports.

The temperature outside rose all day, but towards evening it was rising more and more slowly. What can be said about the derivative of the temperature with respect to time in the evening?

The temperature is rising: the derivative is positive. It’s rising ever more slowly: the derivative is decreasing. Just like a car easing off the accelerator but still moving forward: its speed is positive and falling.

The first rules

Computing every derivative from the definition is like computing every area by counting squares. Let’s derive a few rules, and almost any formula can be differentiated without a thought for limits. The two simplest: the derivative of a constant is zero (for $f(x) = c$ the increment is always $c - c = 0$), and the derivative of the function $x$ is one (the increment is $h$, the ratio $1$).

If $u$ and $v$ are differentiable at $x$ and $c$ is a number, then $(u + v)' = u' + v'$ and $(cu)' = c\,u'$.

The difference quotient of a sum splits into two: $\frac{u(x + h) + v(x + h) - u(x) - v(x)}{h} = \frac{u(x + h) - u(x)}{h} + \frac{v(x + h) - v(x)}{h}$. The first term tends to $u'(x)$, the second to $v'(x)$, and the limit of a sum is the sum of the limits. Likewise $\frac{c\,u(x + h) - c\,u(x)}{h} = c \cdot \frac{u(x + h) - u(x)}{h} \to c\,u'(x)$: a constant factor comes out of the limit. A difference reduces to a sum: $u - v = u + (-1) \cdot v$.

Now powers. We already know the derivative of $x^2$: $2x$. This answer has a vivid meaning. Let $x$ be the side of a square and $x^2$ its area. How fast does the area grow when the side grows?

For any natural $n$, $(x^n)' = n\,x^{n - 1}$.

Two strips of size $x \times h$ along two sides of the square. The corner $h \times h$. For small $h$ it’s tiny even compared with the strips. Example: a side of $3$ cm grew by $1$ mm. The strips added $2 \cdot 30 \cdot 1 = 60$ mm², the corner only $1$ mm².

The trick is to cut the added area into pieces and see which of them survive division by $h$.

A square of side $x$ has area $x^2$. The side has grown by $h$. The new area is $(x + h)^2$, and we need the increment $(x + h)^2 - x^2$: the area of the border around the old square. The border consists of two strips $x \times h$ along two sides, with total area $2xh$… …and a small corner $h \times h$ of area $h^2$. We get $(x + h)^2 - x^2 = 2xh + h^2$; the square of a sum gives the same. Divide by $h$: $\frac{2xh + h^2}{h} = 2x + h$. The strips give $2x$ for any $h$, and the corner contributes $h$, which vanishes as $h \to 0$. So $(x^2)' = 2x$. The rate of growth of the area is half the perimeter: the area builds up along two sides of length $x$.

A cube is the same, only in space. A cube of side $x$ grows by three slabs $x \times x \times h$ on three faces, three bars $x \times h \times h$ along the edges, and a little cube $h \times h \times h$ in the corner: $(x + h)^3 - x^3 = 3x^2h + 3xh^2 + h^3$. After dividing by $h$ the slabs give $3x^2$, while the bars and the little cube leave terms with a factor $h$ that vanish. So $(x^3)' = 3x^2$. For $n > 3$ the picture can’t be drawn, but the argument is the same.

Let’s prove it for any natural $n$. Write $(x + h)^n$ as a product of $n$ identical brackets $(x + h)(x + h) \cdots (x + h)$ and expand them: by the distributive law we get the sum of all products in which one term, $x$ or $h$, is taken from each bracket. Taking $x$ from every bracket gives $x^n$. Taking $h$ from one bracket and $x$ from the rest gives $x^{n - 1}h$; the bracket for $h$ can be chosen in $n$ ways, so there are $n$ such terms, together $n x^{n - 1}h$. In all the other products $h$ is taken from at least two brackets, so their sum can be written as $h^2 R$, where $R$ is a polynomial in $x$ and $h$. So $(x + h)^n - x^n = n x^{n - 1}h + h^2 R$ and $\frac{(x + h)^n - x^n}{h} = n x^{n - 1} + hR$. As $h \to 0$ the polynomial $R$ tends to its value at $h = 0$, that is, it stays bounded, and the term $hR$ tends to zero. What’s left is $n x^{n - 1}$. Exactly how many terms of each kind there are is counted by the binomial theorem, but only the first two matter for the derivative.

The exponent comes down as a factor: that many “faces” along which the power builds up. The exponent drops by one. Example: $(x^5)' = 5x^4$, so $(2x^5 - 3x^2 + 7)' = 10x^4 - 6x$. Later we’ll see that the formula holds for any exponent: $\left(\frac1x\right)' = (x^{-1})' = -x^{-2} = -\frac{1}{x^2}$ and $(\sqrt x)' = \left(x^{1/2}\right)' = \frac{1}{2\sqrt x}$.

A growing rectangle

The derivative of a sum is the sum of the derivatives. It’s tempting to deal just as easily with a product, but the derivative of a product isn’t the product of the derivatives. Check on $x \cdot x = x^2$: the product of the derivatives gives $1 \cdot 1 = 1$, while the right answer is $2x$. Leibniz himself stumbled on this: in a manuscript of November 1675 he checks whether $d(uv)$ equals the product $du\,dv$, and finds from an example that it doesn’t. Area again suggests the right rule.

If $u$ and $v$ are differentiable at $x$, then $(uv)' = u'v + uv'$.

The first factor grows while the second stays put: the strip $\Delta u \times v$. The second factor grows while the first stays put: the strip $u \times \Delta v$. Example: $(x^2 \sin x)' = 2x \sin x + x^2 \cos x$ (we’ll derive the derivative of the sine a little later). Or a shop’s revenue is the price times the number of sales. The price is $100$ and rises by $2$ a month; sales are $500$ and rise by $10$ a month. Revenue grows at $2 \cdot 500 + 100 \cdot 10 = 2000$ a month.

The trick is the same as with the square: the added area is made up of two strips and a corner, and the corner won’t survive the limit.

The product $u(x) \cdot v(x)$ is the area of a rectangle with sides $u$ and $v$. When $x$ gets the increment $h$, the sides change by $\Delta u = u(x + h) - u(x)$ and $\Delta v = v(x + h) - v(x)$. The new area is $(u + \Delta u)(v + \Delta v)$. The added area consists of the strip $\Delta u \cdot v$ on the right… …the strip $u \cdot \Delta v$ on top… …and the corner $\Delta u \cdot \Delta v$. Expanding the brackets gives the same for any signs of the increments: $(u + \Delta u)(v + \Delta v) - uv = \Delta u \cdot v + u \cdot \Delta v + \Delta u \cdot \Delta v$. Divide by $h$: $\frac{\Delta u}{h}\,v + u\,\frac{\Delta v}{h} + \frac{\Delta u}{h}\,\Delta v$. As $h \to 0$ the ratios $\frac{\Delta u}{h}$ and $\frac{\Delta v}{h}$ tend to $u'$ and $v'$, and $\Delta v$ tends to zero, because the differentiable function $v$ is continuous (the theorem in the “magnifying glass” section). The first two terms give $u'v + uv'$, and the third tends to $u' \cdot 0 = 0$.

We’ll deal with a quotient in two moves: first find the derivative of the fraction $\frac1v$, then write $\frac uv$ as the product $u \cdot \frac1v$.

If $u$ and $v$ are differentiable at $x$ and $v(x) \ne 0$, then $\left(\frac1v\right)' = -\frac{v'}{v^2}$ and $\left(\frac uv\right)' = \frac{u'v - uv'}{v^2}$.

The function $v$ is continuous at $x$ (it’s differentiable) and $v(x) \ne 0$, so for small enough $h$ the value $v(x + h)$ isn’t zero either: numbers close to $v(x)$ have the same sign. For such $h$, bring the difference to a common denominator:

$$\frac{1}{v(x + h)} - \frac{1}{v(x)} = \frac{v(x) - v(x + h)}{v(x + h)\,v(x)} = -\frac{\Delta v}{v(x + h)\,v(x)}.$$

Divide by $h$ to get $-\frac{\Delta v}{h} \cdot \frac{1}{v(x + h)\,v(x)}$. As $h \to 0$ the first factor tends to $-v'(x)$, and $v(x + h) \to v(x)$ by continuity, so the second factor tends to $\frac{1}{v(x)^2}$. That’s the first formula. For the second apply the product rule: $\left(u \cdot \frac1v\right)' = u' \cdot \frac1v + u \cdot \left(-\frac{v'}{v^2}\right) = \frac{u'v - uv'}{v^2}$.

As in the product rule: the numerator grows. The denominator grows, which makes the fraction smaller, hence the minus. The square of the denominator. It’s positive, so the numerator decides the sign of the derivative. Example: $\left(\frac{x^2 + 1}{x - 1}\right)' = \frac{2x(x - 1) - (x^2 + 1) \cdot 1}{(x - 1)^2} = \frac{x^2 - 2x - 1}{(x - 1)^2}$. And from the first formula: $\left(\frac{1}{x^n}\right)' = -\frac{n x^{n - 1}}{x^{2n}} = -n x^{-n - 1}$, that is, the power rule holds for negative whole exponents too.

The gearbox

The engine turns the crankshaft, the crankshaft turns the wheels through the gearbox, and the wheels roll the car along. If in third gear the wheel makes one turn for every three turns of the shaft, and one turn of the wheel carries the car two metres, then each turn of the shaft is worth $\frac13 \cdot 2 = \frac23$ of a metre. Rates of change in a chain multiply. That’s the basis of the rule for a composite function, that is, for a composition $f(g(x))$, the “conveyor belt” from the chapter on functions.

Choose the gear ratios of the two pairs and turn the gear $x$. How many turns does $y$ make for one turn of $x$? The signs multiply too: each mesh reverses the direction of rotation, and two meshes restore it.

Gears have constant ratios: they’re linear functions. The derivative measures the “local gear ratio” of any smooth function: by what factor it stretches a small segment near the chosen point. Under the magnifying glass every smooth function works like a gear, only each one’s ratio changes from point to point.

If a function $g$ is differentiable at the point $x$ and a function $f$ is differentiable at the point $u = g(x)$, then $f(g(x))$ is differentiable at $x$ and $\bigl(f(g(x))\bigr)' = f'(g(x)) \cdot g'(x)$.

The derivative of the inner function: by what factor the first machine stretches a small segment near $x$. The derivative of the outer function, taken at the point $g(x)$, not at $x$: the second machine receives $u = g(x)$ as its input. Example: $\bigl((3x + 1)^5\bigr)' = 5(3x + 1)^4 \cdot 3 = 15(3x + 1)^4$. The outer function is $u^5$, the inner $u = 3x + 1$. In Leibniz’s notation the rule looks like cancelling fractions: $\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$.

The idea: picture each function as a machine that carries the points of one number line to another, and follow what becomes of a small segment.

On the top line mark the segment from $x$ to $x + h$. The machine $g$ carries it to the middle line, the machine $f$ to the bottom line. In the picture $g(x) = \frac{x^2}{3}$ and $f(u) = 10\left(1 - e^{-u/5}\right)$, but any differentiable functions will do. The image of the segment on the middle line has length $\Delta u = g(x + h) - g(x)$. By the definition of the derivative $\frac{\Delta u}{h} \to g'(x)$: for small $h$ the machine $g$ stretches segments by a factor of about $g'(x)$. The image on the bottom line has length $\Delta y = f(u + \Delta u) - f(u)$. If $\Delta u \ne 0$, the ratio $\frac{\Delta y}{\Delta u}$ is the slope of a secant of the graph of $f$, and as $\Delta u \to 0$ it tends to $f'(u)$. If $\Delta u \ne 0$, the stretches multiply: $\frac{\Delta y}{h} = \frac{\Delta y}{\Delta u} \cdot \frac{\Delta u}{h}$. Shrink the segment in the picture and watch the three numbers on the right. That leaves the case $\Delta u = 0$ (for example, if $g$ is constant near $x$, or oscillates, returning to the same value): then we can’t divide by $\Delta u$. To avoid dividing, introduce the slope function $\varphi(w) = \frac{f(w) - f(u)}{w - u}$ for $w \ne u$ and $\varphi(u) = f'(u)$. The equation $f(w) - f(u) = \varphi(w)\,(w - u)$ holds for all $w$, including $w = u$, where both sides are zero. Substitute $w = g(x + h)$: we get $\Delta y = \varphi(g(x + h)) \cdot \Delta u$ with no division at all, and so $\frac{\Delta y}{h} = \varphi(g(x + h)) \cdot \frac{\Delta u}{h}$. As $h \to 0$ we have $g(x + h) \to g(x) = u$ ($g$ is continuous), and $\varphi(w) \to f'(u)$ as $w \to u$ by the definition of the derivative, so the first factor tends to $f'(u)$ and the second to $g'(x)$. The upshot: $\bigl(f(g(x))\bigr)' = f'(g(x)) \cdot g'(x)$.

What is the derivative of $\sin 2x$?

The outer function is the sine, and its derivative $\cos u$ is taken at $u = 2x$. The inner function $2x$ grows twice as fast as $x$, which gives the factor $2$. The sine wave $\sin 2x$ is squeezed horizontally by half, so its slopes are twice as steep.

Find the derivative of $(x^2 + 1)^{10}$.

The outer function is $u^{10}$, with derivative $10u^9$; the inner is $u = x^2 + 1$, with derivative $2x$. By the chain rule we get $10(x^2 + 1)^9 \cdot 2x = 20x(x^2 + 1)^9$. Luckily, there was no need to expand a tenth power.

The roundabout

A car enters a roundabout of radius one unit and drives at unit speed. In time $x$ it covers an arc of length $x$, that is, it turns through an angle of $x$ radians, and ends up at the point $(\cos x, \sin x)$: that’s how sine and cosine are defined on the unit circle (chapter on trigonometry). How fast is its “northward” coordinate, $\sin x$, changing? The car’s velocity points along the tangent to the circle, perpendicular to the radius, and at the point with angle $x$ its northward component is $\cos x$. Physics suggests the answer: $(\sin x)' = \cos x$. Let’s prove it honestly, replacing the arc with a chord.

If the angle is measured in radians, $(\sin x)' = \cos x$ for every $x$.

The length of the chord spanning an arc $h$ of the unit circle. The rise of the chord: how much higher the second point is than the first. The cosine of the angle between the chord and the vertical. The chord is perpendicular to the bisector of the angle, which runs at the angle $x + \frac h2$ to the horizontal. Example: at $x = 0.45$ and $h = 0.6$ the left side is $\sin 1.05 - \sin 0.45 \approx 0.8674 - 0.4350 = 0.4324$, and the right $2\sin 0.3 \cdot \cos 0.75 \approx 0.5910 \cdot 0.7317 \approx 0.4324$.

The trick is to measure the rise not along the arc but along the chord: for the chord both the length and the direction are known.

The points $P(\cos x, \sin x)$ and $Q(\cos(x + h), \sin(x + h))$ lie on the unit circle, and the angle $POQ$ is $h$. The difference we need, $\sin(x + h) - \sin x$, is how much higher $Q$ is than $P$, that is, the vertical component of the vector $\overrightarrow{PQ}$. Triangle $OPQ$ is isosceles: $OP = OQ = 1$. Its altitude $OM$ is also the median and the bisector (chapter on the triangle), so in the right triangle $OMQ$ the angle at $O$ is $\frac h2$ and the leg $MQ = \sin\frac h2$. The chord is $PQ = 2\sin\frac h2$. The bisector $OM$ runs at the angle $x + \frac h2$ to the horizontal, and the chord is perpendicular to it. So the chord makes the same angle $x + \frac h2$ with the vertical: the arms of these two angles are pairwise perpendicular. In the language of directions: the vector $\overrightarrow{PQ}$ is turned by $x + \frac h2 + 90°$ from the $x$-axis, and the vertical component of a vector of length $L$ in that direction is $L\sin\left(x + \frac h2 + 90°\right) = L\cos\left(x + \frac h2\right)$. In this form the argument works for any position of the points. So $\sin(x + h) - \sin x = 2\sin\frac h2 \cdot \cos\left(x + \frac h2\right)$. For negative $h$ the point $Q$ lies on the other side of $P$, the chord is turned by $x + \frac h2 - 90°$, and its length is $2\sin\frac{|h|}{2}$; multiplying out gives the same formula. Divide by $h$: $\frac{\sin(x + h) - \sin x}{h} = \frac{\sin(h/2)}{h/2} \cdot \cos\left(x + \frac h2\right)$. As $h \to 0$ the first factor tends to $1$ (the fundamental trigonometric limit), and the second to $\cos x$, because the cosine is continuous. The upshot: $(\sin x)' = \cos x$.

The rest of trigonometry follows by the rules. The cosine is the sine of the complementary angle: $\cos x = \sin\left(\frac\pi2 - x\right)$. By the chain rule $(\cos x)' = \cos\left(\frac\pi2 - x\right) \cdot (-1) = -\sin x$. The minus is clear on the roundabout too: while the car goes round the upper half of the ring, its “eastward” coordinate $\cos x$ decreases. The tangent is a quotient: $(\tan x)' = \frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x} = \frac{1}{\cos^2 x}$, because $\sin^2 x + \cos^2 x = 1$.

The exponential and the logarithm

The exponential function $a^x$ has a property polynomials don’t: its rate of growth is proportional to the function itself. A bank deposit grows the faster the larger it is; a colony of bacteria, the faster the more bacteria it has. Let’s see what the definition of the derivative says:

$$\frac{a^{x + h} - a^x}{h} = a^x \cdot \frac{a^h - 1}{h}.$$

The factor $a^x$ has come out, and the second factor doesn’t depend on $x$ at all: it’s the difference quotient of the graph of $a^x$ at zero. So if there’s a derivative at zero, then $(a^x)' = a^x \cdot m(a)$, where $m(a) = \lim\limits_{h \to 0} \frac{a^h - 1}{h}$. Everything is decided by one number, the slope at zero. Let’s compute it for a few bases:

$h$$a = 2$$a = 2.71828$$a = 3$$a = 10$
$0.1$$0.7177$$1.0517$$1.1612$$2.5893$
$0.01$$0.6956$$1.0050$$1.1047$$2.3293$
$0.001$$0.6934$$1.0005$$1.0992$$2.3052$
$0.0001$$0.6932$$1.0001$$1.0987$$2.3029$

For two the slope at zero is about $0.693$, for three about $1.099$. Somewhere between them there’s a base with slope exactly $1$, and it’s the number $e = 2.71828\ldots$, the very base of the natural logarithm in the chapter on logarithms. Let’s take this property as the definition: $e$ is the base for which the tangent to the graph of $y = e^x$ at the point $(0, 1)$ has slope $1$. That such a base exists, is unique and coincides with the limit $\left(1 + \frac1n\right)^n$ from the last chapter will be proved in the chapter on the number $e$. The link with the limit can be guessed already. Slope $1$ at zero means that for small $h$, $e^h \approx 1 + h$ almost holds. Take $h = \frac1n$ and raise to the power $n$: $e = \left(e^{1/n}\right)^n \approx \left(1 + \frac1n\right)^n$. That’s an estimate, not a proof: the small errors are multiplied together $n$ times, and one still has to check they don’t pile up. The numbers are encouraging: at $n = 1000$ we get $2.71692$, at $n = 10^6$, $2.71828$.

$(e^x)' = e^x$ for every $x$.

By the calculation above $\frac{e^{x + h} - e^x}{h} = e^x \cdot \frac{e^h - 1}{h}$: we used only the property of powers $e^{x + h} = e^x e^h$. The number $e^x$ doesn’t depend on $h$, and $\frac{e^h - 1}{h} \to 1$ by the definition of the number $e$. So the limit is $e^x \cdot 1 = e^x$.

The exponential is a function equal to its own derivative: the height of the graph at each point equals its slope. The natural logarithm is its inverse function, and its derivative can be found by reflection.

$(\ln x)' = \frac1x$ for every $x > 0$.

The idea: the graph of the logarithm is the mirror image of the graph of the exponential, and under reflection in the line $y = x$ rise and run swap roles, so the slope turns upside down.

The function $\ln x$ is the inverse of $e^x$, so their graphs are symmetric about the line $y = x$ (chapter on functions): the point $A(a, e^a)$ of the exponential’s graph reflects to the point $B(e^a, a)$ of the logarithm’s graph. Draw the secant through $A$ and a nearby point $A'$ of the graph of $e^x$. Its slope is $k = \frac{\Delta y}{\Delta x}$: rise divided by run. The reflection takes the secant $AA'$ to the secant $BB'$ of the logarithm’s graph. The horizontal leg of the slope triangle becomes vertical and vice versa, so the slope of the reflected secant is $\frac{\Delta x}{\Delta y} = \frac1k$. The number $k$ isn’t zero: the exponential is strictly increasing. Now let $B'(x', \ln x')$ approach $B$, that is, $x' \to e^a$. The $x$-coordinate of the point $A'$ equals the $y$-coordinate of the point $B'$, the number $\ln x'$. The logarithm is continuous, so $\ln x' \to \ln e^a = a$, and $A'$ approaches $A$. Then $k$ tends to the derivative of the exponential at $a$, that is, to $e^a \ne 0$, and the slope of the secant $BB'$, which is $\frac1k$, tends to $\frac{1}{e^a}$. The limit of the secants’ slopes exists, so the logarithm has a derivative at the point $B$, and it equals $\frac{1}{e^a}$. The point $B$ has $x$-coordinate $x = e^a$. So $(\ln x)' = \frac{1}{e^a} = \frac1x$. Since $a$ is arbitrary, this holds for all $x > 0$.

Now that we have the exponential, the logarithm and the chain rule, two debts can be paid. The first is the derivative of $a^x$ for any base. Since $a = e^{\ln a}$, we have $a^x = e^{x\ln a}$, and by the chain rule $(a^x)' = e^{x \ln a} \cdot \ln a = a^x \ln a$. So the mysterious slope at zero $m(a)$ is $\ln a$: for two, $\ln 2 = 0.6931\ldots$, as in the table.

The second debt is a power with any exponent. For $x > 0$ we have $x^r = e^{r\ln x}$, and $(x^r)' = e^{r\ln x} \cdot \frac rx = x^r \cdot \frac rx = r x^{r - 1}$. The formula for natural $n$ has turned out to hold for any real exponent: $(\sqrt x)' = \left(x^{1/2}\right)' = \frac12 x^{-1/2} = \frac{1}{2\sqrt x}$, as we promised in the “magnifying glass” section.

A circle without a formula

A roundabout of radius $5$ is given by the equation $x^2 + y^2 = 25$, but $y$ isn’t expressed in terms of $x$ in it: a circle isn’t the graph of a function, since above each $x$ in $(-5, 5)$ it has two points. How do we find the slope of the tangent at the point $(3, 4)$? Near this point the circle coincides with the graph of a function $y(x)$, its upper half, and for it the identity $x^2 + y(x)^2 = 25$ holds for all $x$ near $3$. Differentiate both sides, remembering that $y$ is a function of $x$ and applying the chain rule to $y^2$:

$$2x + 2y \cdot y' = 0, \qquad y' = -\frac{x}{y} = -\frac34.$$

Let’s check: the radius from the centre to the point $(3, 4)$ has slope $\frac43$, and $\frac43 \cdot \left(-\frac34\right) = -1$. Lines whose slopes multiply to $-1$ are perpendicular, so the tangent is perpendicular to the radius, as a tangent to a circle should be. Expressing $y = \sqrt{25 - x^2}$ explicitly would give the same: $y' = \frac{-2x}{2\sqrt{25 - x^2}} = -\frac34$. This technique is called implicit differentiation: the derivative is found without expressing the function by a formula. The derivative of the logarithm can be obtained the same way: from $e^{y} = x$ it follows that $e^{y}\,y' = 1$, that is, $y' = \frac{1}{e^y} = \frac1x$. But this argument assumes in advance that the logarithm has a derivative, and the reflection in the mirror is what proved it.

Find the slope of the tangent to the circle $x^2 + y^2 = 25$ at the point $(4, -3)$.

From $2x + 2yy' = 0$ we get $y' = -\frac{x}{y} = -\frac{4}{-3} = \frac43$. Check: the slope of the radius to this point is $-\frac34$, and $\frac43 \cdot \left(-\frac34\right) = -1$: the tangent is perpendicular to the radius.

Who invented the speedometer

Everything in this chapter was invented within a couple of decades by two people, and more than one generation of historians has tried to work out who came first. Isaac Newton built his “method of fluxions” in 1665–1666, when plague closed the University of Cambridge and he was living at his family home in Woolsthorpe. He wrote treatises and showed them to friends but didn’t print them: the main one, The Method of Fluxions and Infinite Series, written around 1671, came out only in 1736, after its author’s death. Gottfried Wilhelm Leibniz arrived at his calculus in 1675 in Paris, independently, and in 1684 published in the Leipzig journal Acta Eruditorum the paper “A New Method for Maxima and Minima, and also Tangents”, the first publication of the differential calculus.

In 1676 Newton, replying to a letter from Leibniz, hid the essence of his method in an anagram: “6accdae13eff7i3l9n4o4qrr4s8t12ux”. It’s the letter counts of a Latin sentence meaning roughly “given an equation involving any number of flowing quantities, to find the fluxions, and vice versa”. It’s impossible to read, but it can later be used to prove who knew first.

The dispute flared up at the start of the eighteenth century. In 1712 the Royal Society of London, whose president was Newton, set up a committee, and its report recognised Newton’s priority. It later emerged that Newton himself had written the text of the report. Today historians agree that both discovered calculus independently: Newton first, but Leibniz published first and devised the more convenient notation. Convenience proved more important than priority. Out of loyalty to Newton the English clung to his dots for almost a hundred years, while on the Continent the Bernoullis, Euler and Lagrange built calculus further in Leibniz’s language. Only in 1812 did the Cambridge students Charles Babbage, John Herschel and George Peacock found the Analytical Society to switch to Leibniz’s $d$. Babbage joked that they stood for “the principles of pure D-ism in opposition to the Dot-age of the University”, playing on “dotage”.

A table and a trainer

Let’s gather everything we’ve derived. These formulas, together with the sum, product, quotient and chain rules, are enough to differentiate any function built from powers, roots, sines, exponentials and logarithms.

FunctionDerivativeWhere from
$c$ (a number)$0$the increment is zero
$x^r$$r x^{r - 1}$brackets, then $x^r = e^{r \ln x}$
$\sqrt x$$\frac{1}{2\sqrt x}$$r = \frac12$
$\frac1x$$-\frac{1}{x^2}$$r = -1$
$e^x$$e^x$the definition of $e$
$a^x$$a^x \ln a$$a^x = e^{x \ln a}$
$\ln x$$\frac1x$reflection
$\log_a x$$\frac{1}{x \ln a}$$\log_a x = \frac{\ln x}{\ln a}$
$\sin x$$\cos x$the chord
$\cos x$$-\sin x$$\cos x = \sin\left(\frac\pi2 - x\right)$
$\tan x$$\frac{1}{\cos^2 x}$quotient

The derivatives of the inverse trigonometric functions, for example $(\arctan x)' = \frac{1}{1 + x^2}$, are derived by the same reflection as the logarithm; try getting this formula yourself by implicitly differentiating $\tan y = x$. The trainer has three levels: powers and polynomials, then products and quotients, then composite functions. Any derivative of your own can be checked in the solver, and the trainers of the whole course are collected on the practice page.

Where next

A speedometer answers the question “how fast”. But more often we’re interested in something else: where is best. From a square sheet of cardboard $30 \times 30$ cm, equal little squares are cut from the corners and the edges folded up, making an open box. A small cut gives a flat box, a large one a tall but narrow box. At what cut is the volume largest? There are infinitely many options, and they can’t all be tried. But the derivative spots the top of a hill from afar: there the tangent is horizontal. How to turn this observation into a method, why it works and where it can mislead, is told in the chapter on extrema and optimization.

In this chapter

  1. What the needle shows
  2. The secant becomes a tangent
  3. The magnifying glass
  4. A speedometer for the whole trip
  5. The first rules
  6. A growing rectangle
  7. The gearbox
  8. The roundabout
  9. The exponential and the logarithm
  10. A circle without a formula
  11. Who invented the speedometer
  12. A table and a trainer
  13. Where next

Chapters