SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 2.4.1 Maxima and minimaConcept · 25 min
      2. 2.4.2 Concavity and the second derivativeConcept · 25 min
      3. 2.4.3 Newton's method with derivativesConcept · 30 min
      4. 2.4.4 Practice set: using derivativesPractice set · 25 min
      5. 2.4.5 Case study: convexity and risk aversionCase study · 30 min
      6. 2.4.6 Case study: implied volatility by Newton's methodCase study · 30 min

Level 2, Single-variable calculus 2.4 Using derivatives Lesson 2 of 6

ConceptLesson 2.4.2 in Level 2, Single-variable calculus. About 25 minutes.

Concavity and the second derivative

The slope of the slope

The derivative f′f' is a function, so it has a derivative of its own. That is the second derivative, written f′′(x)f''(x) and read "f double prime of x". It says how fast the slope is changing.

For f(x)=x2f(x) = x^2 the slope is 2x2x. At x=−1,0,1,2x = -1, 0, 1, 2 it is −2,0,2,4-2, 0, 2, 4: each step of 1 in xx adds 2 to the slope. So f′′(x)=2f''(x) = 2 everywhere.

Rule: Second derivative

f′′(x)=ddx f′(x)also written d2ydx2\begin{gathered} f''(x) = \frac{d}{dx}\, f'(x) \\[4pt] \text{also written } \frac{d^2y}{dx^2} \end{gathered}

Differentiate twice. Its units are output units per input unit, per input unit: the change in the slope per unit of input.

For x3−3xx^3 - 3x, the power rule (lesson 2.3.1) gives f′(x)=3x2−3f'(x) = 3x^2 - 3 and then f′′(x)=6xf''(x) = 6x. For exe^x, every derivative is exe^x again (lesson 2.3.4).

A stone dropped from rest falls s(t)=4.9t2s(t) = 4.9t^2 metres in tt seconds. Its speed is s′(t)=9.8ts'(t) = 9.8t metres per second. Its second derivative, s′′(t)=9.8s''(t) = 9.8 metres per second per second (m/s²), is its acceleration.

Concave up and concave down

The sign of f′′f'' says which way the graph bends.

  • f′′>0f'' > 0: the slope rises from left to right, and the graph bends up like a cup. It is concave up, also called convex.
  • f′′<0f'' < 0: the slope falls, and the graph bends down like a cap. It is concave down, or simply concave.

Take ln⁡x\ln x. Its slope 1x\frac{1}{x} is 2 at x=0.5x = 0.5, 1 at 1, 0.5 at 2 and 0.25 at 4. The slope keeps falling, so ln⁡x\ln x bends down.

The algebra agrees: 1x=x−1\frac{1}{x} = x^{-1} has slope −x−2=−1x2-x^{-2} = -\frac{1}{x^2}, negative for every x>0x > 0.

Rule: Concavity

f′′>0: concave up (convex)f′′<0: concave down (concave)\begin{gathered} f'' > 0: \ \text{concave up (convex)} \\ f'' < 0: \ \text{concave down (concave)} \end{gathered}

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 exe^x at 0 is y=1+xy = 1 + x. The curve is above it everywhere except at 0: by 0.3679 at x=−1x = -1, 0.1487 at 0.5 and 0.7183 at 1. The tangent to ln⁡x\ln x at 1 is y=x−1y = x - 1, 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, exe^x, sits above its tangent at 0; a concave-down curve, ln⁡x\ln x, sits below its tangent at 1. The vertical gaps are the distances between curve and tangent.

Direction and bend are separate

The sign of f′f' says whether the graph rises or falls; the sign of f′′f'' says how it bends. All four pairs happen.

concave up, f′′>0f'' > 0concave down, f′′<0f'' < 0
rising, f′>0f' > 0exe^xln⁡x\ln x
falling, f′<0f' < 0e−xe^{-x}−x2-x^2 for x>0x > 0

e−xe^{-x} falls, yet bends up: its slope −e−x-e^{-x} is negative but rising towards 0, and f′′(x)=e−x>0f''(x) = e^{-x} > 0.

Try it

sp.diff(f, x, 2) differentiates twice. Each line prints a function, its slope and its second derivative.

SymPy writes ln⁡\ln as log and x\sqrt{x} as sqrt(x). The second derivative of x\sqrt{x} is negative, so x\sqrt{x} is concave down, like ln⁡x\ln x.

⌘/Ctrl + Enter runs the cell

Try it

The gaps between each curve and its tangent, at the inputs used above.

The first three lines are ex−(1+x)e^x - (1 + x), all positive. The last three are (x−1)−ln⁡x(x - 1) - \ln x, all positive too: the tangent is on top.

⌘/Ctrl + Enter runs the cell

Estimating f′′f'' from three values

When ff is only a program, estimate f′′f'' as lesson 2.2.2 estimated f′f'. The slope of the chord just right of xx, minus the slope just left of it, divided by hh, gives the second central difference.

Rule: Second central difference

f′′(x)≈f(x+h)−2f(x)+f(x−h)h2f''(x) \approx \frac{f(x + h) - 2f(x) + f(x - h)}{h^2}

Three values of ff, a gap hh apart. Divide by h2h^2, not hh. Its error shrinks like h2h^2.

gap hh0.10.010.001
exe^x at 0 (true 1)1.0008341.0000081.0
ln⁡x\ln x at 2 (true −0.25-0.25)−0.250313-0.250313−0.250003-0.250003−0.25-0.25

Rounding bites sooner than for a first difference, because the error is divided by h2h^2. At h=10−6h = 10^{-6}, the estimate for exe^x at 0 is 0.999978, worse than at h=0.001h = 0.001. 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 exe^x at 0 and ln⁡x\ln x at 2, then tries a gap that is too small.

⌘/Ctrl + Enter runs the cell

Inflection points

Where f′′f'' changes sign, the graph switches from bending one way to bending the other. That point is an inflection point.

Rule: Inflection point

f′′ changes sign at cf'' \text{ changes sign at } c

The curve is concave down on one side of cc and concave up on the other. There the tangent crosses the curve.

For x3−3xx^3 - 3x, f′′(x)=6xf''(x) = 6x is negative for x<0x < 0 and positive for x>0x > 0. So 0 is an inflection point. The tangent there is y=−3xy = -3x, and the curve crosses it.

The cubic x3−3xx^3 - 3x 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 x3−6x2+4x^3 - 6x^2 + 4, the second derivative is 6x−12=6(x−2)6x - 12 = 6(x - 2). It is −6-6 at 1 and 6 at 3, so the sign changes at x=2x = 2, an inflection point with value −12-12.

f′′=0f'' = 0 is not enough

x4x^4 has f′′(x)=12x2f''(x) = 12x^2, which is 0 at 0. But it is 0.12 at both −0.1-0.1 and 0.10.1: no sign change. x4x^4 is concave up on both sides, so 0 is not an inflection point.

The second-derivative test

At a critical point where f′(c)=0f'(c) = 0, 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

f′(c)=0, f′′(c)>0  ⇒  minimumf′(c)=0, f′′(c)<0  ⇒  maximum\begin{gathered} f'(c) = 0,\ f''(c) > 0 \;\Rightarrow\; \text{minimum} \\ f'(c) = 0,\ f''(c) < 0 \;\Rightarrow\; \text{maximum} \end{gathered}

If f′′(c)=0f''(c) = 0, the test says nothing: go back to the first-derivative test of lesson 2.4.1.

For x3−3xx^3 - 3x: f′′(−1)=−6<0f''(-1) = -6 < 0, a maximum, and f′′(1)=6>0f''(1) = 6 > 0, a minimum. For xe−xxe^{-x} from lesson 2.4.1, f′′(x)=(x−2)e−xf''(x) = (x - 2)e^{-x}, so f′′(1)=−e−1≈−0.3679<0f''(1) = -e^{-1} \approx -0.3679 < 0: 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

x4x^4, −x4-x^4 and x3x^3 all have f′(0)=0f'(0) = 0 and f′′(0)=0f''(0) = 0. They give three different answers, so f′′(0)=0f''(0) = 0 alone decides nothing.

functionslope just left of 0slope just right of 0at 0
x4x^4−0.004-0.0040.004minimum
−x4-x^40.004−0.004-0.004maximum
x3x^30.030.03neither

The slopes are at ±0.1\pm 0.1. The test also needs f′(c)=0f'(c) = 0: at a corner such as ∣x∣|x| at 0 there is no f′f' or f′′f'', and only the sign test works.

Try it

The first loop finds each critical point and prints f′′f'' there. -exp(-1) is −e−1-e^{-1}.

Then SymPy solves f′′(x)=0f''(x) = 0 for x3−6x2+4x^3 - 6x^2 + 4.

⌘/Ctrl + Enter runs the cell

Try it

Central differences at −0.1-0.1 and 0.10.1 for the three silent cases, as in the table.

⌘/Ctrl + Enter runs the cell

Lesson 2.4.3 uses f′′f'' 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

  1. "Concave up" and "convex" mean the same thing, and so do "concave down" and "concave". Finance usually says convex and concave.
  2. The bend is not the direction. e−xe^{-x} falls but is concave up; ln⁡x\ln x rises but is concave down.
  3. f′′(c)=0f''(c) = 0 is not a verdict. x4x^4, −x4-x^4 and x3x^3 all have f′′(0)=0f''(0) = 0 and give a minimum, a maximum and neither.
  4. An inflection point needs a sign change, not just f′′=0f'' = 0. x4x^4 has none.
  5. The second-derivative test needs f′(c)=0f'(c) = 0. At a corner, use the sign test.
  6. The second central difference divides by h2h^2, and a tiny hh drowns it in rounding.

Concavity and the second derivative

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 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, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for 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

  • f′′(x)f''(x) is the derivative of f′(x)f'(x): how fast the slope changes, in output units per input unit per input unit.
  • f′′>0f'' > 0: concave up (convex), above its tangents. f′′<0f'' < 0: concave down (concave), below them. The bend is separate from the direction.
  • f′′(x)≈f(x+h)−2f(x)+f(x−h)h2f''(x) \approx \frac{f(x + h) - 2f(x) + f(x - h)}{h^2}, with an error shrinking like h2h^2.
  • An inflection point is where f′′f'' changes sign; f′′=0f'' = 0 alone is not enough.
  • At a critical point with f′(c)=0f'(c) = 0: f′′(c)>0f''(c) > 0 is a minimum, f′′(c)<0f''(c) < 0 a maximum, and f′′(c)=0f''(c) = 0 decides nothing.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.