Chapter 2 Slope at a single point
The derivative
The derivative of a function is its slope at each point: how fast it is changing, right there. Drag the secant until it becomes the tangent, then watch the slopes draw a new curve.
The derivative of a function at a point is the slope of its graph at that point: how fast the output is changing per unit change of the input, right there. If s(t) is a car’s position at time t, its derivative is the speedometer reading. Geometrically, it is the slope of the tangent line, and you get it by taking the slope between two nearby points and letting them merge.
Need a number now? The derivative calculator gives f′(a) for any function you type, with an error estimate and the tangent line.
That sentence hides a puzzle. Slope is rise over run, and a single point has no rise and no run. The derivative gets around this with a limit: measure the slope between the point and a neighbour, then ask what that slope approaches as the neighbour slides in. This chapter takes the idea apart piece by piece. You will see the secant become a tangent, watch the slopes of one curve draw a second curve, prove the power and product rules with nothing but squares and rectangles, and look inside a numerical derivative calculator to see why it does not use a tiny h.
From the slope between two points to the slope at one
Pick a point P = (a, f(a)) on a curve and a second point Q a horizontal distance h away, at (a + h, f(a + h)). The straight line through them is a secant, and its slope is an ordinary rise over run:
This is the average rate of change of f between the two points. If f is position, it is the average speed over the time interval h. Now let h shrink.
On the cubic, put P at x = −2.2 and start with h = 1.6. The secant is nearly flat: slope 0.09. Halve h and the slope jumps to 0.65; keep halving and the readouts run 1.01, 1.21, 1.31, closing in on 1.42. However small you make h the slope stays near that number, so we say the limit of the secant slopes is 1.42. The line through P with that slope is the tangent line, and its slope is the derivative of f at a[1]:
Do the computation once by hand to see the limit work. For f(x) = x², the secant slope is ((a + h)² − a²)/h = (2ah + h²)/h = 2a + h, for every h other than 0. As h → 0 this approaches 2a. So the slope of the parabola at x = 3 is 6, and at x = −1 it is −2. The troublesome 0/0 never appears, because we cancelled h before letting it shrink. That cancellation is the whole trick, and it is exactly the move that resolved the hole in the previous chapter’s equation (1.1).
Notice what the derivative measures. It is a rate: units of output per unit of input. If f is the depth of water in metres and x is time in minutes, f′ is in metres per minute. The secant slope is an average over an interval; the derivative is the instantaneous rate, the average over an interval too short to have any length.
What a tangent line really is
Most people first meet tangent lines on circles, where a tangent touches the circle at exactly one point and stays on one side of it. That picture is so persuasive that it survives into calculus, where it is wrong.
Irene Biza, Constantinos Christou and Theodossios Zachariades found that many students carry the circle-geometry picture of a tangent into analysis, where it gives wrong answers for curves like x³ or for straight lines, which are their own tangents everywhere[2]. A better picture comes from magnification.
At 10× the sine curve near x = 1 visibly bends, straying from its tangent by about 5 percent of the window’s height. At 100× the gap is about half a percent; at 1000×, a twentieth of a percent, and you cannot tell the curve from a straight line. This property is called local linearity, and it is the most useful way to think about derivatives: a differentiable function, seen up close, is a straight line, and the derivative is that line’s slope. The tangent line is the best straight-line approximation to the curve near the point,
with an error that shrinks faster than h itself. Engineers use equation (2.3) daily: it is why a small error in a measurement produces a proportionally small error in anything computed from it, with the derivative as the constant of proportion.
Choose |x| in the figure and magnify the corner at 0. The V never straightens; at every magnification it is the same V. The slope is −1 just to the left and +1 just to the right, so the secant slopes approach different numbers from the two sides, and the limit in equation (2.2) does not exist. The cusp of x2/3 is worse: the slopes grow without bound in opposite directions. And x1/3 has a tangent line at 0, but it is vertical, with no finite slope[1]. The derivative exists only where the curve, magnified enough, is a single non-vertical line.
The reverse is guaranteed: a function with a derivative at a point is continuous there[1]. A jump can never be smoothed by magnifying it, so a jump has no derivative. But continuity is not enough, as the corner shows. In 1872 Karl Weierstrass went much further and described a function that is continuous everywhere and differentiable nowhere: a curve made entirely of corners, which no microscope ever straightens[3]. It shocked his contemporaries, who had assumed that continuous curves must be smooth almost everywhere.
The derivative is a new function
Equation (2.2) gives one number for each point a. Do it at every point and you get a new function, f′, whose value at x is the slope of f at x. That is what the lower panel of Figure 1 traced as you swept P, and it is the curve the home page draws. Reading f′ off the graph of f is the core skill of the subject, and it is easier than it sounds.
Three rules let you sketch any derivative. Where f rises, f′ is positive; where it falls, f′ is negative. At every smooth peak and valley the tangent is horizontal, so f′ = 0. And the steepest point of a climb, the inflection point where the curve switches from bending up to bending down, is where f′ reaches a peak of its own. On the two-tone wave in the figure, the derivative has two troughs below the axis for the long descent, because that descent has a steep start, a shoulder at x = π where it levels off for an instant, and a second steep stretch.
The derivative is a function like any other, so it has a derivative too: the second derivative f″, the rate of change of the slope. On a position graph it is acceleration. Where f″ is positive the slope is increasing and the curve bends upward, like a bowl; where it is negative the curve bends down. This is how the derivative turns graphs into equations: Newton’s second law says that force equals mass times the second derivative of position.
One idea, three notations
Calculus writes the derivative of y = f(x) in several ways, each from a different inventor and each good at something different.
| Notation | From | What it is good at |
|---|---|---|
| dy/dx, df/dx | Gottfried Leibniz, in print from 1684 | Keeps track of what changes with respect to what; makes the chain rule look like fraction arithmetic |
| f′(x), y′ | Joseph-Louis Lagrange, who also named the “derived function” (1797) | Compact; treats the derivative as a function of its own |
| ẏ, a dot over the letter | Isaac Newton’s “fluxions” | Derivatives with respect to time, still standard in physics |
Both the name and the prime notation come from Lagrange, and Cauchy adopted them in his 1823 lectures, where he also gave the first rigorous definition of the derivative as the limit in equation (2.2), written with the qualifier “when this limit exists”[4]. That small phrase opened the question this chapter asked with |x|: what happens when it does not?
documentedWhy the rules are true, in pictures
Nobody computes derivatives from the limit definition every time. A handful of rules, applied mechanically, differentiate any formula built from powers, exponentials, logarithms and trigonometric functions[1]. The danger is that the rules become the whole subject. Each one is a fact about how something grows, and two of them can be seen in a single picture.
The power rule: a growing square
Let a square have side x, so its area is x². Lengthen each side by a small amount dx. The new area is (x + dx)², and the growth is two thin strips, each x by dx, plus a tiny corner square dx by dx:
Divide by dx: the growth per unit of dx is 2x + dx. As dx → 0 the corner term disappears, and the derivative of x² is 2x. The figure makes the reason visible: with dx = 0.5 the corner is a quarter of a unit next to strips of 2, and with dx = 0.01 it is 0.0001 next to 0.04. The corner is second order: its size is proportional to (dx)², so dividing by dx still leaves something that goes to zero.
A cube of side x grows in the same way, by three square slabs of volume x² dx, three rods of volume x(dx)², and one small cube (dx)³. Only the slabs are first order, so the derivative of x³ is 3x². The general pattern is the power rule:
For whole numbers n, expanding (x + dx)n gives n first-order pieces, one for each factor you could choose to lengthen, plus higher-order debris. The rule also holds for negative and fractional powers[1]: √x = x1/2 has derivative ½x−1/2, and 1/x = x−1 has derivative −x−2.
The product rule: a growing rectangle
Now let the sides be two different functions, f and g, both changing with x. The rectangle’s area is the product fg. When x grows by dx, f grows by df and g by dg, and the area gains a strip g · df on one side, a strip f · dg on the other, and a corner df · dg. Divide by dx and let it shrink. The corner is second order again, and what remains is the product rule, which Leibniz stated in his 1684 paper[6]:
Choose f · g in Figure 5 and read the two strips. This is why the derivative of a product is not the product of the derivatives, the single most common algebraic slip in a first calculus course. If it were, a rectangle whose width is growing and whose height is fixed would not grow at all, since the height’s derivative is zero.
The quotient rule follows from the product rule. Write q = f/g, so f = qg, differentiate both sides with (2.6), and solve for q′:
Add the rules that a constant multiple and a sum differentiate term by term, and the derivatives of a few basic functions, and you can differentiate any formula you can write[1]:
| Function | Derivative | The picture |
|---|---|---|
| xn | nxn−1 | a square or cube growing by strips or slabs |
| sin x | cos x | slopes of the sine wave trace a cosine (Figure 1, “sin x”) |
| cos x | −sin x | the cosine wave falls where sine is positive |
| ex | ex | the curve whose slope everywhere equals its height |
| ln x | 1/x | the logarithm climbs ever more slowly |
| f(g(x)) | f′(g(x)) · g′(x) | the chain rule: rates multiply (next chapter) |
The exponential deserves a second look. Choose e(x/2) in Figure 1 and sweep: the derivative curve comes out exactly half the height of the curve itself, everywhere. For ex the two would coincide. A quantity whose rate of growth is proportional to its size, such as money at compound interest or an unchecked population, is described by an exponential for exactly this reason.
How a computer finds a derivative
Equation (2.2) suggests a recipe for a computer: pick a very small h, say 10−12, and compute the secant slope. It is a bad recipe, and the reason is instructive.
Computers store numbers with about 16 significant digits[7]. To compute f(a + h) − f(a) with h = 10−12, the machine subtracts two numbers that agree in their first 12 digits, so only about four meaningful digits survive the subtraction. Dividing by h then magnifies whatever error is left. Shrinking h reduces one error, the truncation error from using a secant instead of a tangent, but increases another, the round-off error from finite digits. The figure plots both.
Read the figure from the right. The forward quotient of equation (2.1) has an error proportional to h: each factor of 10 in h buys one more correct digit. The symmetric quotient (f(a + h) − f(a − h))/2h, which uses points on both sides, has an error proportional to h² and gains two digits per factor of 10[7]. Both lines eventually hit the round-off wall, where the error grows like 10−16/h. The best you can do is near h = 10−8 for the forward quotient, giving about 8 correct digits, and near 10−5 for the symmetric one, giving about 10 correct digits[7]. At h = 10−12 the forward quotient for ex is wrong in the fourth decimal place.
The way past the wall is to use several moderate steps and extrapolate. Because the error of the symmetric quotient is a tidy series in h², estimates at h, h/1.4, h/1.4², … can be combined so that the leading error terms cancel, without ever making h small enough for round-off to bite. This is Ridders’ method[8], and it typically reaches 12 to 14 correct digits along with an estimate of its own error. The calculator below uses it as a check: for a formula you type, it first applies the exact rules of this chapter (sum, product, quotient, power and chain rules) to the formula itself and evaluates the result at your point, then compares that with the extrapolated quotients.
x^(1/3) at 0: it explains why there is no derivative instead of printing a number.#Why bother with numbers when computer algebra systems give formulas? Because many derivatives that matter in practice are of functions with no formula: a simulation, a measured signal, a model fitted to data. For those, a difference quotient is the only way in, and the trade-off between truncation and round-off in Figure 6 has to be managed rather than wished away.
Where the derivative leads
The derivative answers one question about a function: how fast is it changing? Two more chapters follow from it. The chain rule handles functions fed into other functions, where rates multiply. And the fundamental theorem reveals that the derivative has an inverse, the integral, which adds up changes instead of measuring them. Classroom research has long found that students can apply the differentiation rules well before they understand the rate of change and the limit behind them[9]. If you have read this far, you have the part the rules leave out.