III.11 · Calculus
Is a flat point a valley, a peak — or neither?
At a point where the gradient vanishes, second derivatives decide the shape — when they can. Compare a surface with its quadratic model and meet the cases where the test cannot decide.
Read curvature from second derivatives
Contours of f = x² + y²
Contours of f = x² + y². At (0, 0) the dashed lines are the principal curvature directions (eigenvectors of the Hessian, eigenvalues ≈ 2.0000 and 2.0000). Classification: minimum.
Quadratic model Q(δ) near the point
Near the point, solid contours of f and dashed contours of its quadratic model share the same levels. Close to the point they agree; farther away higher-order terms separate them.
- Point
- (0, 0)
- Height
- 0
- Gradient
- (0, 0)
- Curvature along x
- 2
- Curvature along y
- 2
- Mixed partials (both orders)
- 0 = 0 (symmetric)
- Determinant
- 4
- Principal curvatures (eigenvalues)
- 2
- Second eigenvalue
- 2
- Curvature in the chosen direction
- 2
- Second-derivative test
- local minimum
Exact values use =; binary64 approximations use ≈. Undefined values state their reason.
det H > 0 and f_xx > 0: both principal curvatures are positive, so the critical point is a strict local minimum.
Is the point critical?
∇f = 0: the test may be applied.
from −2 to 2, up to 2 decimal places
from −2 to 2, up to 2 decimal places
from −180 to 180, whole numbers only
At the bottom of the bowl both principal curvatures are and the test reports a minimum. Choose Saddle: the curvatures are and . Now choose x⁴ + y⁴ and x² + y³: both have a zero gradient and a singular Hessian at the origin, the test is inconclusive, and indeed the first is a minimum while the second is neither a minimum nor a maximum.
Intuition: how the slope itself changes
The gradient says which way is uphill. Second derivatives say how that slope changes as you move — how the surface curves. Along a direction , the curvature of the slice at is a number; positive means the slice bends upward. A minimum curves upward in every direction, a maximum downward in every direction, and a saddle upward in some directions and downward in others.
Definition
The Hessian of at is the matrix of second partial derivatives,
For smooth functions (and all polynomials) the mixed partials agree, , so is symmetric. The curvature along a unit vector is ; its extreme values are the eigenvalues of , the principal curvatures, along the eigenvector directions.
Second-derivative test. At a critical point (): if and , a strict local minimum; if and , a strict local maximum; if , a saddle; if , the test is inconclusive.
Mechanics: what the explorer computes
All second partials, the determinant and the trace are exact; both mixed partials are computed separately and compared. The classification is an exact rational decision. Principal curvatures are binary64 roots from the exact trace and discriminant. The right plane draws contours of the quadratic model with the same levels as . If the point is not critical, the stage says that the test does not apply.
Derivation: why the determinant decides
Near a critical point . For a symmetric with eigenvalues and orthonormal eigenvectors, writing in that basis gives
If both eigenvalues are positive the quadratic is positive for every (minimum); both negative, a maximum; opposite signs, a saddle. Since and , the sign of tells whether the signs agree, and (or the trace) tells which. If some eigenvalue is zero, the quadratic is flat in that direction, and higher-order terms decide.
Worked example
has , so its critical points are . The Hessian is
At : , — a minimum. At : — a saddle.
Replay the worked derivation
Is the point critical?
∇f = 0: the test may be applied.
When the test is inconclusive
For , and the monkey saddle , the origin is critical and . The first has a minimum, the second takes negative values along the negative -axis and positive values along the -axis, and the monkey saddle goes down in three directions and up in three. Same Hessian test result, three different shapes: second derivatives alone cannot decide, and the quadratic model on the right is visibly degenerate.
Executable reference code
The reference computes exact Hessians with Fraction, checks symmetry of mixed partials and classifies critical points, reporting the degenerate cases as inconclusive. The NumPy version computes eigenvalues with numpy.linalg.eigh and verifies that lies between them for many directions.
"""Exact Hessians, symmetric mixed partials and the second-derivative test (III.11)."""
from fractions import Fraction as F
def d(p, var):
k = 0 if var == "x" else 1
out = {}
for (i, j), c in p.items():
e = (i, j)[k]
if e:
key = (i - 1, j) if k == 0 else (i, j - 1)
out[key] = out.get(key, 0) + c * e
return out
def ev(p, x, y):
return sum(c * x**i * y**j for (i, j), c in p.items())
def classify(p, x, y):
if ev(d(p, "x"), x, y) != 0 or ev(d(p, "y"), x, y) != 0:
return "not critical"
fxx, fyy = ev(d(d(p, "x"), "x"), x, y), ev(d(d(p, "y"), "y"), x, y)
fxy, fyx = ev(d(d(p, "x"), "y"), x, y), ev(d(d(p, "y"), "x"), x, y)
assert fxy == fyx
det = fxx * fyy - fxy * fxy
if det < 0:
return "saddle"
if det == 0:
return "inconclusive"
return "minimum" if fxx > 0 else "maximum"
well = {(3, 0): F(1), (1, 0): F(-3), (0, 2): F(1)} # x**3 - 3x + y**2
assert classify(well, F(1), F(0)) == "minimum"
assert classify(well, F(-1), F(0)) == "saddle"
assert classify(well, F(0), F(1, 2)) == "not critical"
for degenerate in ({(4, 0): F(1), (0, 4): F(1)}, {(2, 0): F(1), (0, 3): F(1)}, {(3, 0): F(1), (1, 2): F(-3)}):
assert classify(degenerate, F(0), F(0)) == "inconclusive""""Directional curvature u^T H u lies between the eigenvalues of a symmetric Hessian (III.11)."""
import numpy as np
H = np.array([[6.0, 1.5], [1.5, 2.0]])
lam, V = np.linalg.eigh(H)
theta = np.linspace(0, np.pi, 721)
U = np.stack([np.cos(theta), np.sin(theta)], axis=1)
curv = np.einsum("ni,ij,nj->n", U, H, U)
assert lam[0] - 1e-12 <= curv.min() and curv.max() <= lam[1] + 1e-12
assert np.isclose(curv.max(), lam[1], atol=1e-4) and np.isclose(np.prod(lam), np.linalg.det(H))Explore
Drag the point away from a critical point: the classification becomes “not a critical point” even though the Hessian still describes curvature. Change the direction angle and watch move between the two principal curvatures. On the double well, move from toward and find where changes sign.
Common mistakes
Applying the test at a point where . Concluding “minimum” or “maximum” when . Using only and and forgetting the mixed term , which rotates the principal directions.
Numerical considerations
Deciding in floating point is a tolerance choice, not a fact: nearly singular Hessians make classification sensitive to rounding. The explorer decides exactly because its inputs are rational. Numerically, eigenvalues of symmetric matrices are well conditioned, but the eigenvectors of nearly repeated eigenvalues are not.
Engineering and ML connections
Newton’s method for optimisation solves ; curvature also explains why gradient descent zig-zags in narrow valleys and how step sizes relate to the largest eigenvalue (VI.5). In high dimensions most critical points of loss landscapes are saddles. This chapter supplies the vocabulary; the optimisation algorithms come later.
Exercises
Summary and checkpoints
The Hessian collects second partial derivatives and is symmetric for smooth functions. At a critical point its determinant and diagonal classify minima, maxima and saddles; when the test is inconclusive. The quadratic model is the local second-order picture. Next, III.12 turns from rates to accumulation: integrals.