The slope of the slope
The derivative is a function, so it has a derivative of its own. That is the second derivative, written and read "f double prime of x". It says how fast the slope is changing.
For the slope is . At it is : each step of 1 in adds 2 to the slope. So everywhere.
Rule: Second derivative
Differentiate twice. Its units are output units per input unit, per input unit: the change in the slope per unit of input.
For , the power rule (lesson 2.3.1) gives and then . For , every derivative is again (lesson 2.3.4).
A stone dropped from rest falls metres in seconds. Its speed is metres per second. Its second derivative, metres per second per second (m/s²), is its acceleration.
Concave up and concave down
The sign of says which way the graph bends.
- : the slope rises from left to right, and the graph bends up like a cup. It is concave up, also called convex.
- : the slope falls, and the graph bends down like a cap. It is concave down, or simply concave.
Take . Its slope is 2 at , 1 at 1, 0.5 at 2 and 0.25 at 4. The slope keeps falling, so bends down.
The algebra agrees: has slope , negative for every .
Rule: Concavity
A concave-up curve lies above its tangent lines; a concave-down curve lies below them. Near the point of contact, the gap grows like the square of the distance, as in lesson 2.2.1.
The tangent to at 0 is . The curve is above it everywhere except at 0: by 0.3679 at , 0.1487 at 0.5 and 0.7183 at 1. The tangent to at 1 is , and the curve is below it: by 0.1931 at 0.5, 0.3069 at 2 and 0.9014 at 3.
A concave-up curve, , sits above its tangent at 0; a concave-down curve, , sits below its tangent at 1. The vertical gaps are the distances between curve and tangent.
Direction and bend are separate
The sign of says whether the graph rises or falls; the sign of says how it bends. All four pairs happen.
| concave up, | concave down, | |
|---|---|---|
| rising, | ||
| falling, | for |
falls, yet bends up: its slope is negative but rising towards 0, and .
Try it
sp.diff(f, x, 2) differentiates twice. Each line prints a function, its slope and its second derivative.
SymPy writes as log and as sqrt(x). The second derivative of is negative, so is concave down, like .
Try it
The gaps between each curve and its tangent, at the inputs used above.
The first three lines are , all positive. The last three are , all positive too: the tangent is on top.
Estimating from three values
When is only a program, estimate as lesson 2.2.2 estimated . The slope of the chord just right of , minus the slope just left of it, divided by , gives the second central difference.
Rule: Second central difference
Three values of , a gap apart. Divide by , not . Its error shrinks like .
| gap | 0.1 | 0.01 | 0.001 |
|---|---|---|---|
| at 0 (true 1) | 1.000834 | 1.000008 | 1.0 |
| at 2 (true ) |
Rounding bites sooner than for a first difference, because the error is divided by . At , the estimate for at 0 is 0.999978, worse than at . Case study 2.4.5 uses this estimate to measure a bond's convexity.
Try it
second is the formula above. The loop prints it for at 0 and at 2, then tries a gap that is too small.
Inflection points
Where changes sign, the graph switches from bending one way to bending the other. That point is an inflection point.
Rule: Inflection point
The curve is concave down on one side of and concave up on the other. There the tangent crosses the curve.
For , is negative for and positive for . So 0 is an inflection point. The tangent there is , and the curve crosses it.
The cubic bends down left of 0 and up right of 0. The maximum sits in the cap, the minimum in the cup, and the tangent at the inflection point crosses the curve.
For , the second derivative is . It is at 1 and 6 at 3, so the sign changes at , an inflection point with value .
is not enough
has , which is 0 at 0. But it is 0.12 at both and : no sign change. is concave up on both sides, so 0 is not an inflection point.
The second-derivative test
At a critical point where , the bend tells you which kind it is. A cup has its lowest point at the bottom; a cap has its highest point at the top.
Rule: Second-derivative test
If , the test says nothing: go back to the first-derivative test of lesson 2.4.1.
For : , a maximum, and , a minimum. For from lesson 2.4.1, , so : the critical point at 1 is a maximum. Both agree with the sign test of lesson 2.4.1, with one evaluation each.
When the test is silent
, and all have and . They give three different answers, so alone decides nothing.
| function | slope just left of 0 | slope just right of 0 | at 0 |
|---|---|---|---|
| 0.004 | minimum | ||
| 0.004 | maximum | ||
| 0.03 | 0.03 | neither |
The slopes are at . The test also needs : at a corner such as at 0 there is no or , and only the sign test works.
Try it
The first loop finds each critical point and prints there. -exp(-1) is .
Then SymPy solves for .
Try it
Central differences at and for the three silent cases, as in the table.
Lesson 2.4.3 uses to find a minimum with Newton's method, and module 2.7 builds the best quadratic copy of a curve from it. Case study 2.4.5 uses convexity for bonds and for attitudes to risk.
Common mistakes
- "Concave up" and "convex" mean the same thing, and so do "concave down" and "concave". Finance usually says convex and concave.
- The bend is not the direction. falls but is concave up; rises but is concave down.
- is not a verdict. , and all have and give a minimum, a maximum and neither.
- An inflection point needs a sign change, not just . has none.
- The second-derivative test needs . At a corner, use the sign test.
- The second central difference divides by , and a tiny drowns it in rounding.
Concavity and the second derivative
0 of 12 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
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
- is the derivative of : how fast the slope changes, in output units per input unit per input unit.
- : concave up (convex), above its tangents. : concave down (concave), below them. The bend is separate from the direction.
- , with an error shrinking like .
- An inflection point is where changes sign; alone is not enough.
- At a critical point with : is a minimum, a maximum, and decides nothing.