SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 4.3.1 The Hessian and second-order Taylor expansionConcept · 35 min
      2. 4.3.2 Minima, maxima and saddle pointsConcept · 30 min
      3. 4.3.3 Practice set: second-order methodsPractice set · 20 min
      4. 4.3.4 Case study: delta–gamma–vega P&LCase study · 35 min

Level 4, Multivariable calculus and optimisation 4.3 Second order Lesson 2 of 4

ConceptLesson 4.3.2 in Level 4, Multivariable calculus and optimisation. About 30 minutes.

Minima, maxima and saddle points

Critical points

In one variable, lesson 2.4.1 looked for the highest and lowest points where f′=0f' = 0. In several variables, a smooth function can only have a top or a bottom where every partial derivative is 0. There the tangent plane is flat: the slope ∇f⋅u\nabla f \cdot \mathbf{u} is 0 in every direction (lesson 4.2.1).

Rule: Critical point

∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}

A point where every partial derivative is 0 is a critical point. To find them, solve the equations fx=0f_x = 0, fy=0f_y = 0 together. A point with no gradient, such as the tip of a cone, needs a separate look.

Three kinds of critical point matter:

  • a local minimum: f(a)f(\mathbf{a}) is the lowest value of ff near a\mathbf{a};
  • a local maximum: the highest value near a\mathbf{a};
  • a saddle point: neither, because ff rises in some directions and falls in others.

Example 1: f(x,y)=x3−3x+y2f(x, y) = x^3 - 3x + y^2. Here ∇f=(3x2−3, 2y)\nabla f = (3x^2 - 3,\ 2y). The first equation gives x=1x = 1 or x=−1x = -1, the second y=0y = 0. So there are two critical points: (1,0)(1, 0), where f=−2f = -2, and (−1,0)(-1, 0), where f=2f = 2.

Example 2: f(x,y)=6xy−2x3−3y2f(x, y) = 6xy - 2x^3 - 3y^2. Here ∇f=(6y−6x2, 6x−6y)\nabla f = (6y - 6x^2,\ 6x - 6y). The second equation gives y=xy = x; then the first is 6x−6x2=06x - 6x^2 = 0, so x=0x = 0 or x=1x = 1. The critical points are (0,0)(0, 0), where f=0f = 0, and (1,1)(1, 1), where f=1f = 1.

The equations are not linear here, so there can be several solutions. For a quadratic function they are linear, and lesson 4.4.1 solves them as a system (lesson 3.3.1).

Try it

sp.solve solves the two equations fx=0f_x = 0, fy=0f_y = 0 together and lists every solution. The second number on each line is ff there.

⌘/Ctrl + Enter runs the cell

What the Hessian says

At a critical point the gradient term of the quadratic copy (lesson 4.3.1) is 0. What is left is the quadratic form of lesson 3.7.1:

f(a+h)−f(a)≈12 h⊤H hf(\mathbf{a} + \mathbf{h}) - f(\mathbf{a}) \approx \tfrac{1}{2}\,\mathbf{h}^\top H\,\mathbf{h}

So near a\mathbf{a}, the sign of the change in ff is the sign of h⊤Hh\mathbf{h}^\top H\mathbf{h}.

For the cubic, fxx=6xf_{xx} = 6x, fxy=0f_{xy} = 0 and fyy=2f_{yy} = 2, so H=(6x002)H = \begin{pmatrix} 6x & 0 \\ 0 & 2 \end{pmatrix}.

  • At (1,0)(1, 0), H=(6002)H = \begin{pmatrix} 6 & 0 \\ 0 & 2 \end{pmatrix} and the change is about 3h12+h223h_1^2 + h_2^2: positive for every step. A minimum.
  • At (−1,0)(-1, 0), H=(−6002)H = \begin{pmatrix} -6 & 0 \\ 0 & 2 \end{pmatrix} and the change is about −3h12+h22-3h_1^2 + h_2^2: negative along xx, positive along yy. A saddle.

Near the saddle, here is the true change f(−1+h1,h2)−2f(-1 + h_1, h_2) - 2 against −3h12+h22-3h_1^2 + h_2^2:

step h\mathbf{h}(0.1,0)(0.1, 0)(−0.1,0)(-0.1, 0)(0,0.1)(0, 0.1)(0.1,0.1)(0.1, 0.1)(0.1,0.2)(0.1, 0.2)
change in ff−0.029-0.029−0.031-0.0310.01−0.019-0.0190.011
12h⊤Hh\frac{1}{2}\mathbf{h}^\top H\mathbf{h}−0.03-0.03−0.03-0.030.01−0.02-0.020.01

The quadratic form is 0 on the lines h2=±3 h1h_2 = \pm\sqrt{3}\,h_1, which separate the steps that go up from those that go down, like the hyperbolas of lesson 3.7.1.

Slices of x3−3x+y2x^3 - 3x + y^2 through its two critical points. At (1,0)(1, 0) both slices have a bottom: a minimum. At (−1,0)(-1, 0) the slice along xx has a top and the slice along yy a bottom: a saddle.

Lesson 3.7.1's tests now apply to the matrix of second derivatives.

Rule: The second-derivative test

∇f(a)=0 and H at a:positive definite  ⟹  local minimumnegative definite  ⟹  local maximumindefinite  ⟹  saddle point\begin{gathered} \nabla f(\mathbf{a}) = \mathbf{0} \text{ and } H \text{ at } \mathbf{a}: \\[4pt] \text{positive definite} \implies \text{local minimum} \\ \text{negative definite} \implies \text{local maximum} \\ \text{indefinite} \implies \text{saddle point} \end{gathered}

If HH is only semidefinite, with an eigenvalue 0, the test cannot decide: the quadratic copy is flat in some direction, and the terms it leaves out take over.

Try it below. Jump to each critical point of the cubic and read the Hessian and the verdict. Then move the point off (1,0)(1, 0) with the sliders: HH still curves up every way while x>0x > 0, but the gradient is no longer 0, so the point is not a minimum. Switch to the saddle x2−y2x^2 - y^2 to compare.

Explore

Move the point and read the Hessian, the table of second derivatives. Jump to a point where the gradient is zero and the Hessian says what kind of point it is.

−2−1012−2−1012
Point
(0, 1), f = 1
Gradient ∇f (dark arrow)
(−3, 2), length 3.606
Hessian
fxx = 0, fxy = 0, fyy = 2; det H = 0
So
The gradient is not 0, so this is not a critical point. det H = 0: the test cannot decide

Try it

The first loop prints the change in ff near the saddle (−1,0)(-1, 0) and the quadratic form −3h12+h22-3h_1^2 + h_2^2, as in the table.

The second does the same near the minimum (1,0)(1, 0), with 3h12+h223h_1^2 + h_2^2: every change is positive.

⌘/Ctrl + Enter runs the cell

The 2×22 \times 2 test: det⁡H\det H and fxxf_{xx}

For two variables, lesson 3.7.1's leading minors are fxxf_{xx} and det⁡H=fxxfyy−fxy2\det H = f_{xx}f_{yy} - f_{xy}^2. A positive determinant means the two eigenvalues of HH have the same sign, and fxxf_{xx} says which.

Rule: Second-derivative test for two variables

det⁡H=fxxfyy−fxy2det⁡H>0, fxx>0: minimumdet⁡H>0, fxx<0: maximumdet⁡H<0: saddledet⁡H=0: no verdict\begin{gathered} \det H = f_{xx}f_{yy} - f_{xy}^2 \\[6pt] \det H > 0,\ f_{xx} > 0:\ \text{minimum} \\ \det H > 0,\ f_{xx} < 0:\ \text{maximum} \\ \det H < 0:\ \text{saddle} \\ \det H = 0:\ \text{no verdict} \end{gathered}

All evaluated at a critical point. With det⁡H>0\det H > 0, fxxf_{xx} and fyyf_{yy} have the same sign, so either one can be used.

Example 2 again. For 6xy−2x3−3y26xy - 2x^3 - 3y^2, fxx=−12xf_{xx} = -12x, fxy=6f_{xy} = 6 and fyy=−6f_{yy} = -6:

(1,1): H=(−1266−6), det⁡H=36(0,0): H=(066−6), det⁡H=−36\begin{gathered} (1, 1):\ H = \begin{pmatrix} -12 & 6 \\ 6 & -6 \end{pmatrix},\ \det H = 36 \\[6pt] (0, 0):\ H = \begin{pmatrix} 0 & 6 \\ 6 & -6 \end{pmatrix},\ \det H = -36 \end{gathered}

At (1,1)(1, 1), det⁡H>0\det H > 0 and fxx=−12<0f_{xx} = -12 < 0: a local maximum. At (0,0)(0, 0), det⁡H<0\det H < 0: a saddle. There fxx=0f_{xx} = 0 on its own says nothing; the determinant decides.

Algebra confirms the maximum. Expanding about (1,1)(1, 1):

f(1+h1,1+h2)=1−6h12+6h1h2−3h22−2h13\begin{aligned} f(1 + h_1, 1 + h_2) ={}& 1 - 6h_1^2 + 6h_1h_2 \\ &- 3h_2^2 - 2h_1^3 \end{aligned}

There are no terms of degree 1: it is a critical point. The quadratic part is 12h⊤Hh\frac{1}{2}\mathbf{h}^\top H\mathbf{h}, and completing the square as in lesson 3.7.1 gives −3h12−3(h1−h2)2-3h_1^2 - 3(h_1 - h_2)^2. That is negative for every step except 0\mathbf{0}.

step h\mathbf{h}(0.1,0)(0.1, 0)(0,0.1)(0, 0.1)(0.1,0.1)(0.1, 0.1)(0.1,−0.1)(0.1, -0.1)(−0.1,0.2)(-0.1, 0.2)
f−1f - 1−0.062-0.062−0.03-0.03−0.032-0.032−0.152-0.152−0.298-0.298
12h⊤Hh\frac{1}{2}\mathbf{h}^\top H\mathbf{h}−0.06-0.06−0.03-0.03−0.03-0.03−0.15-0.15−0.3-0.3

The gaps are the cubic term −2h13-2h_1^3: −0.002-0.002 for h1=0.1h_1 = 0.1, +0.002+0.002 for h1=−0.1h_1 = -0.1, and 0 when h1=0h_1 = 0.

A positive diagonal is not enough. x2+4xy+y2x^2 + 4xy + y^2 has a critical point at (0,0)(0, 0) with fxx=fyy=2f_{xx} = f_{yy} = 2, but fxy=4f_{xy} = 4 and det⁡H=4−16=−12\det H = 4 - 16 = -12. It is a saddle: f(0.1,−0.1)=−0.02f(0.1, -0.1) = -0.02. This is lesson 3.7.1's matrix NN, doubled.

Try it

kind applies the 2×22 \times 2 test to the three entries of HH. It treats a determinant within 10−1210^{-12} of 0 as 0, as lesson 3.7.1 allowed for rounding.

The fourth line is x2+4xy+y2x^2 + 4xy + y^2 at (0.1,−0.1)(0.1, -0.1). The loop evaluates f−1f - 1 near the maximum and the quadratic part, for the table.

⌘/Ctrl + Enter runs the cell

Eigenvalues: the bends along the eigenvectors

Lesson 4.3.1 showed that u⊤Hu\mathbf{u}^\top H\mathbf{u} is the second derivative of ff along a unit vector u\mathbf{u}. Lesson 3.6.3 wrote a symmetric matrix as H=QΛQ⊤H = Q\Lambda Q^\top, with perpendicular unit eigenvectors qi\mathbf{q}_i. Along an eigenvector, qi⊤Hqi=λi\mathbf{q}_i^\top H\mathbf{q}_i = \lambda_i.

Rule: Eigenvalues of H as bends

qi⊤H qi=λif(a+tqi)≈f(a)+12λit2\begin{gathered} \mathbf{q}_i^\top H\,\mathbf{q}_i = \lambda_i \\[4pt] f(\mathbf{a} + t\mathbf{q}_i) \approx f(\mathbf{a}) + \tfrac{1}{2}\lambda_i t^2 \end{gathered}

At a critical point, each eigenvalue is the bend of ff along its eigenvector. Over all unit vectors the bend runs from the smallest eigenvalue to the largest (lesson 3.7.1): a saddle has directions of both signs.

For the cubic at (−1,0)(-1, 0), HH is diagonal, so the eigenvectors are the axes: λ=−6\lambda = -6 along xx, the way down, and λ=2\lambda = 2 along yy, the way up.

For example 2 at the saddle (0,0)(0, 0), the eigenvalues are −9.7082-9.7082 and 3.70823.7082, with unit eigenvectors (−0.5257,0.8507)(-0.5257, 0.8507) and (0.8507,0.5257)(0.8507, 0.5257). A step of t=0.1t = 0.1 along the first gives f=−0.04825f = -0.04825, against 12λt2=−0.048541\frac{1}{2}\lambda t^2 = -0.048541. Along the second, f=0.01731f = 0.01731 against 0.018541.

Over all unit vectors, u⊤Hu\mathbf{u}^\top H\mathbf{u} runs from −9.708-9.708 to 3.7083.708. The bend is most negative along the first eigenvector, so near the saddle ff falls fastest that way.

Try it

eigh (lesson 3.6.3) returns the eigenvalues in increasing order, with the eigenvectors as columns. Their signs are arbitrary, so the cell makes the largest entry of each positive.

The loop steps 0.1 along each eigenvector. The last line checks the range of u⊤Hu\mathbf{u}^\top H\mathbf{u} on 720 directions round the circle.

⌘/Ctrl + Enter runs the cell

Three or more variables

With nn variables, HH is n×nn \times n and the test is the same: the signs of its eigenvalues, or the leading minors of lesson 3.7.1. In code, use eigvalsh and treat tiny eigenvalues as 0.

Take f(x,y,z)=x2+y2+z2−xyzf(x, y, z) = x^2 + y^2 + z^2 - xyz. Its gradient (2x−yz, 2y−xz, 2z−xy)(2x - yz,\ 2y - xz,\ 2z - xy) is 0\mathbf{0} at the origin and at (2,2,2)(2, 2, 2), among other points. At the origin H=2IH = 2I, with eigenvalues 2, 2 and 2: a minimum, f=0f = 0.

At (2,2,2)(2, 2, 2), HH has 2 on the diagonal and −2-2 everywhere else. Its eigenvalues are −2-2, 4 and 4: a saddle, with f=4f = 4. Along the eigenvector (1,1,1)(1, 1, 1) the function falls: f(2.1,2.1,2.1)=3.969f(2.1, 2.1, 2.1) = 3.969.

The leading minors there are 2, 0 and −32-32. They are not all positive, so this is no minimum, and they do not alternate from a negative start, so it is no maximum. The eigenvalues say which directions go down.

Try it

hessian3 writes out the six second partials of x2+y2+z2−xyzx^2 + y^2 + z^2 - xyz. The first line checks that the gradient is 0 at both points.

Each line then prints the eigenvalues and the leading minors at one point. The last line steps along (1,1,1)(1, 1, 1).

⌘/Ctrl + Enter runs the cell

When the test cannot decide

If det⁡H=0\det H = 0, or HH has an eigenvalue 0, the copy is flat along that eigenvector and the test is silent. The three functions below all have ∇f=0\nabla f = \mathbf{0} and H=(0002)H = \begin{pmatrix} 0 & 0 \\ 0 & 2 \end{pmatrix} at the origin.

functionf(0.1,0)f(0.1, 0)f(−0.1,0)f(-0.1, 0)f(0,0.1)f(0, 0.1)the origin is
x4+y2x^4 + y^20.00010.00010.01a minimum
−x4+y2-x^4 + y^2−0.0001-0.0001−0.0001-0.00010.01a saddle
x3+y2x^3 + y^20.001−0.001-0.0010.01a saddle

Along yy each one curves up like y2y^2. Along xx the Hessian sees nothing, and the left-out term, x4x^4, −x4-x^4 or x3x^3, decides. Lesson 2.4.2 met the same silence in one variable with x4x^4; look at ff itself near the point, or at its higher terms (lesson 2.7.1).

Try it

The loop evaluates each function at the three points of the table.

⌘/Ctrl + Enter runs the cell

Local is not global

The test looks only near the point. The cubic's minimum at (1,0)(1, 0) has f=−2f = -2, yet f(−3,0)=−18f(-3, 0) = -18: the slice x3−3xx^3 - 3x falls without limit as xx decreases, so the cubic has no lowest point at all. Example 2's maximum, f(1,1)=1f(1, 1) = 1, is beaten by f(−2,0)=16f(-2, 0) = 16.

To find the lowest value overall, compare the critical points with the values far out and on any edge of the domain, as lesson 2.4.1 did on an interval. Lesson 4.4.1 returns to local and global minima, and lesson 4.5.3 shows when a local minimum must be the lowest point of all.

Common mistakes

  1. Check ∇f=0\nabla f = \mathbf{0} first. At (1,1)(1, 1) the cubic has H=(6002)H = \begin{pmatrix} 6 & 0 \\ 0 & 2 \end{pmatrix}, positive definite, but ∇f=(0,2)\nabla f = (0, 2): ff still falls towards y=0y = 0, so it is no minimum.
  2. fxx>0f_{xx} > 0 and fyy>0f_{yy} > 0 do not make a minimum. x2+4xy+y2x^2 + 4xy + y^2 has both and is a saddle. Check det⁡H\det H.
  3. det⁡H>0\det H > 0 alone does not make a minimum. −x2−2y2-x^2 - 2y^2 has det⁡H=8\det H = 8 and a maximum. Check the sign of fxxf_{xx} too.
  4. det⁡H=0\det H = 0 gives no verdict, not a saddle: x4+y2x^4 + y^2 has a minimum and −x4+y2-x^4 + y^2 a saddle.
  5. Local is not global. A local minimum can be far above the lowest value, and there may be no lowest value.
  6. ∇f=0\nabla f = \mathbf{0} misses points with no gradient. The cone x2+y2\sqrt{x^2 + y^2} has its minimum at its tip, where the gradient does not exist (lesson 4.2.1).

Minima, maxima and saddle points

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

  • A critical point has ∇f=0\nabla f = \mathbf{0}: solve fx=0f_x = 0 and fy=0f_y = 0 together. Points without a gradient need a separate look.
  • At a critical point f(a+h)−f(a)≈12h⊤Hhf(\mathbf{a} + \mathbf{h}) - f(\mathbf{a}) \approx \frac{1}{2}\mathbf{h}^\top H\mathbf{h}, so lesson 3.7.1's tests on HH decide: positive definite, a local minimum; negative definite, a local maximum; indefinite, a saddle; semidefinite, no verdict.
  • For two variables: det⁡H=fxxfyy−fxy2\det H = f_{xx}f_{yy} - f_{xy}^2. det⁡H>0\det H > 0 with fxx>0f_{xx} > 0 is a minimum, with fxx<0f_{xx} < 0 a maximum; det⁡H<0\det H < 0 is a saddle; det⁡H=0\det H = 0 decides nothing.
  • Each eigenvalue of HH is the bend of ff along its eigenvector; a saddle has bends of both signs.
  • The test is local: compare with values far out and on the edges to find the lowest or highest value overall.

Free further reading

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