In one variable, lesson 2.4.1 looked for the highest and lowest points where f′=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 is 0 in every direction (lesson 4.2.1).
Rule: Critical point
∇f(a)=0
A point where every partial derivative is 0 is a critical point. To find them, solve the equations fx=0, fy=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) is the lowest value of f near a;
a local maximum: the highest value near a;
a saddle point: neither, because f rises in some directions and falls in others.
Example 1: f(x,y)=x3−3x+y2. Here ∇f=(3x2−3,2y). The first equation gives x=1 or x=−1, the second y=0. So there are two critical points: (1,0), where f=−2, and (−1,0), where f=2.
Example 2: f(x,y)=6xy−2x3−3y2. Here ∇f=(6y−6x2,6x−6y). The second equation gives y=x; then the first is 6x−6x2=0, so x=0 or x=1. The critical points are (0,0), where f=0, and (1,1), where f=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=0, fy=0 together and lists every solution. The second number on each line is f 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)≈21h⊤Hh
So near a, the sign of the change in f is the sign of h⊤Hh.
For the cubic, fxx=6x, fxy=0 and fyy=2, so H=(6x002).
At (1,0), H=(6002) and the change is about 3h12+h22: positive for every step. A minimum.
At (−1,0), H=(−6002) and the change is about −3h12+h22: negative along x, positive along y. A saddle.
Near the saddle, here is the true change f(−1+h1,h2)−2 against −3h12+h22:
step h
(0.1,0)
(−0.1,0)
(0,0.1)
(0.1,0.1)
(0.1,0.2)
change in f
−0.029
−0.031
0.01
−0.019
0.011
21h⊤Hh
−0.03
−0.03
0.01
−0.02
0.01
The quadratic form is 0 on the lines h2=±3h1, which separate the steps that go up from those that go down, like the hyperbolas of lesson 3.7.1.
Slices of x3−3x+y2 through its two critical points. At (1,0) both slices have a bottom: a minimum. At (−1,0) the slice along x has a top and the slice along y 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
If H 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) with the sliders: H still curves up every way while x>0, but the gradient is no longer 0, so the point is not a minimum. Switch to the saddle x2−y2 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.
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 f near the saddle (−1,0) and the quadratic form −3h12+h22, as in the table.
The second does the same near the minimum (1,0), with 3h12+h22: every change is positive.
⌘/Ctrl + Enter runs the cell
The 2×2 test: detH and fxx
For two variables, lesson 3.7.1's leading minors are fxx and detH=fxxfyy−fxy2. A positive determinant means the two eigenvalues of H have the same sign, and fxx says which.
At (1,1), detH>0 and fxx=−12<0: a local maximum. At (0,0), detH<0: a saddle. There fxx=0 on its own says nothing; the determinant decides.
Algebra confirms the maximum. Expanding about (1,1):
f(1+h1,1+h2)=1−6h12+6h1h2−3h22−2h13
There are no terms of degree 1: it is a critical point. The quadratic part is 21h⊤Hh, and completing the square as in lesson 3.7.1 gives −3h12−3(h1−h2)2. That is negative for every step except 0.
step h
(0.1,0)
(0,0.1)
(0.1,0.1)
(0.1,−0.1)
(−0.1,0.2)
f−1
−0.062
−0.03
−0.032
−0.152
−0.298
21h⊤Hh
−0.06
−0.03
−0.03
−0.15
−0.3
The gaps are the cubic term −2h13: −0.002 for h1=0.1, +0.002 for h1=−0.1, and 0 when h1=0.
A positive diagonal is not enough.x2+4xy+y2 has a critical point at (0,0) with fxx=fyy=2, but fxy=4 and detH=4−16=−12. It is a saddle: f(0.1,−0.1)=−0.02. This is lesson 3.7.1's matrix N, doubled.
Try it
kind applies the 2×2 test to the three entries of H. It treats a determinant within 10−12 of 0 as 0, as lesson 3.7.1 allowed for rounding.
The fourth line is x2+4xy+y2 at (0.1,−0.1). The loop evaluates f−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 is the second derivative of f along a unit vector u. Lesson 3.6.3 wrote a symmetric matrix as H=QΛQ⊤, with perpendicular unit eigenvectors qi. Along an eigenvector, qi⊤Hqi=λi.
Rule: Eigenvalues of H as bends
qi⊤Hqi=λif(a+tqi)≈f(a)+21λit2
At a critical point, each eigenvalue is the bend of f 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), H is diagonal, so the eigenvectors are the axes: λ=−6 along x, the way down, and λ=2 along y, the way up.
For example 2 at the saddle (0,0), the eigenvalues are −9.7082 and 3.7082, with unit eigenvectors (−0.5257,0.8507) and (0.8507,0.5257). A step of t=0.1 along the first gives f=−0.04825, against 21λt2=−0.048541. Along the second, f=0.01731 against 0.018541.
Over all unit vectors, u⊤Hu runs from −9.708 to 3.708. The bend is most negative along the first eigenvector, so near the saddle f 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 on 720 directions round the circle.
⌘/Ctrl + Enter runs the cell
Three or more variables
With n variables, H is n×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−xyz. Its gradient (2x−yz,2y−xz,2z−xy) is 0 at the origin and at (2,2,2), among other points. At the origin H=2I, with eigenvalues 2, 2 and 2: a minimum, f=0.
At (2,2,2), H has 2 on the diagonal and −2 everywhere else. Its eigenvalues are −2, 4 and 4: a saddle, with f=4. Along the eigenvector (1,1,1) the function falls: f(2.1,2.1,2.1)=3.969.
The leading minors there are 2, 0 and −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−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).
⌘/Ctrl + Enter runs the cell
When the test cannot decide
If detH=0, or H has an eigenvalue 0, the copy is flat along that eigenvector and the test is silent. The three functions below all have ∇f=0 and H=(0002) at the origin.
function
f(0.1,0)
f(−0.1,0)
f(0,0.1)
the origin is
x4+y2
0.0001
0.0001
0.01
a minimum
−x4+y2
−0.0001
−0.0001
0.01
a saddle
x3+y2
0.001
−0.001
0.01
a saddle
Along y each one curves up like y2. Along x the Hessian sees nothing, and the left-out term, x4, −x4 or x3, decides. Lesson 2.4.2 met the same silence in one variable with x4; look at f 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) has f=−2, yet f(−3,0)=−18: the slice x3−3x falls without limit as x decreases, so the cubic has no lowest point at all. Example 2's maximum, f(1,1)=1, is beaten by f(−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
Check ∇f=0 first. At (1,1) the cubic has H=(6002), positive definite, but ∇f=(0,2): f still falls towards y=0, so it is no minimum.
fxx>0 and fyy>0 do not make a minimum.x2+4xy+y2 has both and is a saddle. Check detH.
detH>0 alone does not make a minimum.−x2−2y2 has detH=8 and a maximum. Check the sign of fxx too.
detH=0 gives no verdict, not a saddle: x4+y2 has a minimum and −x4+y2 a saddle.
Local is not global. A local minimum can be far above the lowest value, and there may be no lowest value.
∇f=0 misses points with no gradient. The cone x2+y2 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.
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, 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: solve fx=0 and fy=0 together. Points without a gradient need a separate look.
At a critical point f(a+h)−f(a)≈21h⊤Hh, so lesson 3.7.1's tests on H decide: positive definite, a local minimum; negative definite, a local maximum; indefinite, a saddle; semidefinite, no verdict.
For two variables: detH=fxxfyy−fxy2. detH>0 with fxx>0 is a minimum, with fxx<0 a maximum; detH<0 is a saddle; detH=0 decides nothing.
Each eigenvalue of H is the bend of f 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.