A slope at every point
Lesson 2.2.1 found the slope of at 3 by letting chord slopes settle on 6. Nothing about 3 was special. Do the same at other points, with a gap of on each side:
| point | from the right | from the left | slope |
|---|---|---|---|
| 0 | 0.001 | 0 | |
| 1 | 2.001 | 1.999 | 2 |
| 2 | 4.001 | 3.999 | 4 |
| 3 | 6.001 | 5.999 | 6 |
Each slope is twice the point. Algebra shows why. At a general point , expand the top and cancel :
As this tends to . So the slope of at any input is . That rule is a new function: the derivative.
Rule: Derivative
The slope of at each input where this limit exists; there is differentiable. Read as "f prime of x". Finding is called differentiating.
The derivative takes a point and returns the slope there. For , , as in lesson 2.2.1, and .
Try it
The cell repeats the table: chord slopes from both sides at six points, then .
round(…, 6) hides rounding noise in the last digits.
Reading the sign of the slope
The sign of says which way the graph is heading at .
- : the graph rises there. rises for every .
- : the graph falls there. falls for every .
- : the tangent is flat, as at the bottom of a valley. For that happens only at 0.
The sign says nothing about the height. At , is 4, above zero, yet its slope is : it is falling.
Slide the point along : the lower graph traces its slopes, the line . Then switch to . Its slope is zero at the hill () and the valley (), and negative between them. The next section works out that slope, , from the limit.
Explore
Slide the point along the curve. Its tangent shows the slope there, and the lower graph plots that slope for every x: the derivative.
The slope of y = x², which is 2x
- Point
- (−2, 4)
- Slope there
- −4
- The curve is
- falling: the slope is negative, so the slope graph is below zero
Notation and units
If , the derivative is also written , read "dee y by dee x". It recalls the chord slope of lesson 2.2.1, after the limit. It is one symbol, not a fraction of two numbers.
Rule: Two notations
Both mean the derivative of . The slope at one point is written , or at . The units are output units per input unit, as for any rate.
A square with side cm has area cm². By the first section, , in cm² per cm. At the area grows at 6 cm² per cm of side.
So adding 0.1 cm to the side adds about cm². The true gain is cm²: the tangent estimate of lesson 2.2.1.
Derivatives from the limit
Every derivative in this lesson comes from the same three steps.
- Write the chord slope .
- Simplify the top until cancels from the bottom.
- Let .
Expanding gives . Divide by to get , which tends to . At that is 12, the slope lesson 2.2.1 found from chords.
For , the extra adds to the top. The chord slope becomes , so the derivative is . It is zero at and , the hill and the valley in the slope tracer.
Put the two fractions over the common bottom :
Dividing by leaves , which tends to . This holds for every , and it is negative on both sides of 0: falls everywhere. At the slope is .
Here no factors out of the top. Multiply the top and bottom by . The top becomes , by the trick from lesson 2.1.1.
As the bottom tends to , so the derivative is , for . At it is 0.25.
A pattern
Written as powers (lesson 1.4.1), and . In all four results the power comes down in front and drops by one: , , , . Lesson 2.3.1 turns that pattern into the power rule.
Try it
SymPy follows the three steps. Each line prints the function, its simplified chord slope, and the limit as . It cannot simplify the one, but finds its limit.
The last two lines check at 2 and at 4 with .
Where a derivative does not exist
A derivative at needs a value , and chord slopes that settle on one number from both sides. Three shapes break the second condition.
At a corner the two sides settle on different slopes. At a vertical tangent and at a jump the chord slopes grow without bound. In all three, has no derivative at 0.
- A corner. For at 0, the chord slope is : 1 for every and for every . The one-sided limits differ (lesson 2.1.2), so there is no derivative at 0.
- A vertical tangent. For the cube root at 0, the chord slope is . It is 100 at and 10,000 at , from either side. The tangent is vertical, and a vertical line has no slope (lesson 1.2.1).
- A jump. Take the step , which is 0 for and 1 for . From the right every chord slope is 0. From the left it is : 10 at and 1,000 at .
Away from 0, has slope on the left and 1 on the right. That derivative is the function of lesson 2.1.2, with its jump at 0. Switch the slope tracer above to to watch it.
The ramp of lesson 1.1.2 has a corner at 0 too: slope 0 on the left, 1 on the right. At 0, has no left side, and from the right its chord slopes blow up like the cube root's.
Differentiable means continuous, not the reverse
Rule: Differentiable implies continuous
If has a derivative at , its graph has no break at (lesson 2.1.2). The reverse fails: and are continuous at 0 but have no derivative there. A Proof Gym stage proves the first part.
So a jump, a hole or a blow-up always rules out a derivative. A graph without a break can still fail, at a corner or a vertical tangent.
Try it
The cell computes chord slopes at 0 from the right and from the left, for three gaps. math.cbrt is the cube root.
The corner gives 1 and every time. The cube root and the left side of the step grow without bound.
Finite differences
Sometimes you can compute but cannot do the algebra: is a long program, or a price from a model. Then stop at a small instead of taking the limit. The result is a finite difference, an estimate of .
Rule: Finite differences
Forward uses a point to the right of , backward a point to the left. Central uses one on each side, apart; it is the average of the other two.
Take at 1, where the true slope is .
| gap | 0.1 | 0.01 | 0.001 |
|---|---|---|---|
| forward | 3.31 | 3.0301 | 3.003001 |
| backward | 2.71 | 2.9701 | 2.997001 |
| central | 3.01 | 3.0001 | 3.000001 |
Algebra explains the pattern. Expanded, the forward difference is exactly and the backward one . The central one is .
So the forward and backward errors are about , with opposite signs: a gap 10 times smaller gives an error about 10 times smaller. The central error is : 10 times smaller , 100 times smaller error. For the same , central is far more accurate.
Case study 2.2.4 uses the central difference to measure how a bond price responds to its yield.
Try it
The three estimates for at 1. Compare each line with , and .
How small should be?
Smaller is better only down to a point. The computer stores about 16 significant digits (lesson 2.1.1). With a tiny , and agree in nearly all of them, and subtracting leaves mostly rounding error.
Dividing by then magnifies that error. A rounding error of about divided by is about . Here are the errors for at 1 as shrinks:
| gap | forward error | central error |
|---|---|---|
The errors of the forward and central differences of at 1, on log scales. Each falls as shrinks until rounding takes over; the central error falls faster and bottoms out at a larger .
For inputs of about size 1, the forward difference is best near and the central one near . Below that, every step smaller makes the answer worse. At , is stored as exactly 1, and the forward difference of at 1 comes out as 0.
Lesson 2.8.1 explains the and with Taylor series (lesson 2.7.1), and picks for any function.
Try it
The errors for five gaps. f"{e:.1e}" prints a number in Python's scientific notation: 3.0e-02 means .
The last line pushes to .
Common mistakes
- is a function; is a number. The derivative of is , and its slope at 3 is 6.
- The sign of is about direction, not height. is positive at but falling there.
- Units are per input unit. for an area is in cm² per cm, not cm².
- Mind the domain. holds only for , and only for .
- Check both sides. At a corner the slopes from the two sides differ. The slope of at 0 is not 0, nor the average of and 1: it does not exist.
- Continuous is not enough. and have no break at 0 and still have no derivative there.
- A finite difference is an estimate. The forward one is off by about for at 1; prefer the central one.
- A smaller is not always better. Below about , rounding swamps the answer.
The derivative
0 of 13 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- The derivative is the slope at every . Also written ; units are output per input.
- : rising. : falling. : a flat tangent.
- From the limit: , , for , for .
- No derivative at a corner ( at 0), a vertical tangent ( at 0) or a jump. Differentiable implies continuous, not the reverse.
- Finite differences: forward and backward errors shrink like , central like . Below about rounding makes them worse.