Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 39 · Optimization in Several Variables

Critical Points and the Second Derivative Test

Find critical points of f(x, y), classify them as minima, maxima or saddle points with the Hessian determinant, and check every step with SymPy.

In one variable you find a peak or a valley by setting f'(x) = 0 and then checking the sign of f''(x). Functions of two variables work the same way, with one new twist: a point can be a peak in one direction and a valley in another. That shape is called a saddle point, and it has no one-variable counterpart.

In this lesson you will find the critical points of a function f(x, y), then classify each one with the second derivative test. You will also see why the test works, so you can trust it and know when it stays silent.

Critical points

A point (a, b) in the interior of the domain is a critical point of f when both first partial derivatives vanish there (or when one of them does not exist):

Text
fx(a, b) = 0   and   fy(a, b) = 0

Equivalently, the gradient is the zero vector: ∇f(a, b) = (0, 0). At such a point the tangent plane to the graph is horizontal. A local maximum or minimum in the interior must be a critical point, just as in one variable. The reverse is false: a critical point may be neither.

Example. Let f(x, y) = x³ - 3x + y² - 4y.

  1. fx = 3x² - 3, so fx = 0 gives x = 1 or x = -1.
  2. fy = 2y - 4, so fy = 0 gives y = 2.

The critical points are (1, 2) and (-1, 2). Notice that the equations here separate nicely. Usually you must solve a system of two equations, and that can be the hardest part of the problem.

The Hessian and the test

The second derivatives of f form a 2 × 2 table called the Hessian matrix:

Text
H = | fxx  fxy |
    | fyx  fyy |

For smooth functions fxy = fyx, so the matrix is symmetric. Its determinant is the number you need:

Text
D = fxx · fyy - (fxy)²

Second derivative test. Let (a, b) be a critical point, with continuous second partials near it. Compute D and fxx at the point.

Condition Conclusion
D > 0 and fxx > 0 local minimum
D > 0 and fxx < 0 local maximum
D < 0 saddle point
D = 0 the test tells you nothing

For the example, fxx = 6x, fyy = 2, fxy = 0, so D = 12x.

  • At (1, 2): D = 12 > 0 and fxx = 6 > 0, a local minimum with value f = 1 - 3 + 4 - 8 = -6.
  • At (-1, 2): D = -12 < 0, a saddle point.
Python Find and classify critical points with SymPy

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Change f to -(x**2) - y**2 + x*y + 3*x or any polynomial and run it again. The solver handles any system SymPy can solve exactly.

Why the sign of D matters

Near a critical point the function looks like its second-order Taylor polynomial, a quadratic bowl or saddle:

Text
f(a+h, b+k) ≈ f(a, b) + ½ (fxx h² + 2 fxy h k + fyy k²)

When D > 0, the quadratic form has the same sign in every direction (a bowl). If fxx > 0 the bowl opens upward (minimum), otherwise downward (maximum). When D < 0, the form is positive in some directions and negative in others: a saddle. Linear algebra gives a cleaner description: the Hessian has two real eigenvalues, and D is their product. Both positive means a minimum, both negative a maximum, opposite signs a saddle.

Because D is the product of the eigenvalues, a positive D means they share a sign, and fxx (or fyy) tells you which sign. That is why you only need to look at one of the diagonal entries.

When the test fails

If D = 0, at least one eigenvalue is zero and the quadratic approximation says nothing. Consider these three functions at the origin:

Function Behavior at (0, 0)
x⁴ + y⁴ minimum
-x⁴ - y⁴ maximum
x³ + y³ neither (saddle-like)

Each has fx = fy = 0 and D = 0 at the origin. You must then study the function directly, for example by looking along lines through the point or by comparing values nearby.

Seeing the shapes

A contour plot is the quickest way to recognize a minimum (closed loops around the point), and a saddle (contours that cross like a hyperbola).

Python Contours with the critical points marked

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Around (1, 2) the contours close into small loops. Around (-1, 2) they pinch and cross.

A numerical classifier

Sometimes you have a function you cannot differentiate by hand. You can estimate the Hessian with finite differences and look at its eigenvalues. This is a calculator that applies the idea; it is an approximation, not a proof.

Python Classify a point with a finite-difference Hessian

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. At a critical point of f(x, y), what is true of the gradient?

    A critical point is where fx and fy are both zero, so the gradient is (0, 0) and the tangent plane is horizontal.
  2. 2. At a critical point, D = fxx·fyy - (fxy)² is negative. What is the point?

    A negative determinant means the Hessian has eigenvalues of opposite signs, so the graph curves up in some directions and down in others.
  3. 3. For f(x, y) = x² + y², what is D at the origin, and what is the point?

    fxx = fyy = 2 and fxy = 0, so D = 4 > 0 and fxx > 0, which is a local minimum.
  4. 4. If D = 0 at a critical point, what should you do?

    With D = 0 the quadratic approximation is degenerate. Functions such as x⁴ + y⁴ and x³ + y³ both have D = 0 at the origin but behave differently.

Summary

  • A critical point has fx = 0 and fy = 0 (the gradient is zero).
  • Use the Hessian determinant D = fxx·fyy - fxy² to classify it.
  • D > 0, fxx > 0: minimum. D > 0, fxx < 0: maximum. D < 0: saddle. D = 0: no conclusion.
  • D is the product of the Hessian's eigenvalues, which explains the test.
  • Contour plots and finite-difference eigenvalues give a quick visual or numerical check.

Next: Absolute Extrema on Closed Regions