Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Classifying Critical Points with the Hessian Matrix

Hello! Let's dive into the next crucial topic in our journey through optimization theory.

Introduction

In our last lesson, we established how to construct a second-order Taylor approximation for a multivariable function around a point :

We previewed that this approximation becomes particularly powerful at critical points, where the gradient is the zero vector. At such points, the linear term vanishes, and the local behavior of the function—whether it curves upwards like a valley, downwards like a hilltop, or both like a saddle—is determined entirely by the quadratic term involving the Hessian matrix, .

Today, we will formalize this idea. Our learning outcome is to identify critical points of a function and use the Hessian matrix to classify them as local minima, maxima, or saddle points. This is the multivariable equivalent of the second derivative test from single-variable calculus and is a cornerstone of optimization in machine learning.

Step 1: Finding Critical Points

First, let's formally define our terms.

Visualizing Critical Points: Local Minima, Saddle Points, and Local Maxima
A visual depiction of the types of critical points we aim to classify: local minima (valleys), local maxima (peaks), and saddle points.
  • A point is a local minimum if for all in a small neighborhood around .
  • A point is a local maximum if for all in a small neighborhood around .
  • A local extremum is a point that is either a local minimum or a local maximum.

A critical point (also called a stationary point) is a point in the interior of the function's domain where the gradient is zero: .

A zero gradient is a necessary condition for a point to be a local extremum. Intuitively, if the gradient were non-zero at a point , it would point in the direction of steepest ascent. We could take a small step in that direction to find a higher function value, or a small step in the opposite direction to find a lower value. Therefore, could not be a local extremum. The only points that can be local extrema are those where the tangent plane is flat.

To find critical points, we must therefore solve the system of equations that arises from setting each partial derivative to zero:

This often results in a system of non-linear equations, which can be challenging to solve.

Local extrema and saddle points of a multivariable function (KristaKingMath)

The following video provides a clear, step-by-step example of finding the critical points for a two-variable function by setting up and solving this system of equations.

Please watch from 00:30 to 05:56. The first part (until 01:38) shows the calculation of first-order partial derivatives. The second part (from 02:27 to 05:56) demonstrates how to set these derivatives to zero and solve the resulting system for the (x, y) coordinates of the critical points.

Step 2: Classifying Critical Points with the Hessian

Finding a critical point only tells us the function's surface is momentarily flat. It doesn't tell us what happens next. Is it the bottom of a bowl (minimum), the top of a hill (maximum), or a mountain pass (saddle point)?

As we saw in the Taylor expansion, this is governed by the quadratic form , where is a small displacement vector and is the Hessian at the critical point. The sign of this term for different directions tells us how the function curves.

Gradients, Hessians, and All Those Derivative Tests

This video gives an excellent conceptual overview of why we need more than just the gradient. It introduces the Hessian as the tool for classifying critical points and connects its properties to the concept of directional second derivatives.

Watch from 12:27 to 16:52. Pay close attention to the analogy with the single-variable second derivative test and how it's generalized to higher dimensions using the Hessian. The key idea is that instead of checking the sign of a single number (the second derivative), we must check the 'sign' of a matrix.

Definiteness of the Hessian Matrix

The video correctly points out that classifying a critical point comes down to determining if the Hessian matrix is "positive" or "negative" in some sense. This "sign" of a symmetric matrix is called its definiteness. This is a concept from linear algebra that is deeply connected to the signs of the matrix's eigenvalues.

2.7: Critical Points

This resource from the University of Toronto provides the rigorous definitions we need. It formally defines positive/negative definite matrices and, most importantly, provides the theorem that links these definitions to the signs of the eigenvalues.

Please read the two subsections under 'Symmetric matrices'. The first defines 'positive definite', 'negative definite', and 'indefinite' matrices. The second, 'Eigenvalues of definite matrices', states the crucial theorem connecting definiteness to the signs of the eigenvalues. This is the central theoretical tool for the second derivative test.

To summarize the key theorem from the reading: for a symmetric matrix (and the Hessian is always symmetric for functions you'll encounter in ML):

  • is positive definite all of its eigenvalues are positive ().
    • This means for all non-zero vectors . Geometrically, the function curves upwards in every direction from the critical point.
  • is negative definite all of its eigenvalues are negative ().
    • This means for all non-zero vectors . Geometrically, the function curves downwards in every direction.
  • is indefinite it has at least one positive and at least one negative eigenvalue.
    • This means is positive for some directions and negative for others. Geometrically, the function curves up in some directions and down in others.
  • If any eigenvalue is zero and the others are all non-negative (or all non-positive), the matrix is semidefinite.

The Second Derivative Test

We can now state the full second derivative test for a function at a critical point where .

  1. If is positive definite (all eigenvalues > 0), then is a local minimum.
  2. If is negative definite (all eigenvalues < 0), then is a local maximum.
  3. If is indefinite (mixed positive and negative eigenvalues), then is a saddle point.
  4. If is semidefinite (some eigenvalues are zero, and the rest have the same sign), the test is inconclusive. The point could be a min, max, saddle, or something else entirely (like the flat bottom of a trough).
Critical Points and Hessian Matrix for a Multivariable Function
An example showing the full process: finding critical points, calculating the Hessian at each point, determining its properties (via its determinant, D, and f_xx), and classifying the points.

Step 3: A Complete Worked Example

Let's return to the video example and see the classification step in action. The video uses a common shortcut for 2x2 matrices that avoids directly computing eigenvalues.

Local extrema and saddle points of a multivariable function (KristaKingMath)

Now, let's watch the rest of the KristaKingMath video. It will calculate the second-order partial derivatives to form the Hessian and then apply the classification test at each critical point.

Watch from 01:27 to 02:38 to see the calculation of the Hessian components. Then, watch from 05:42 to the end (11:20) to see how the Hessian is evaluated at each critical point and how the 'D-test' is used to classify them.

Connecting the "D-Test" to Eigenvalues

The video uses a quantity . You should recognize this as the determinant of the 2x2 Hessian matrix. For a 2x2 matrix, the determinant is the product of the eigenvalues (), and the trace is the sum of the eigenvalues ().

This provides the rigorous justification for the "D-test":

  • If , then and have the same sign. The sign is determined by their sum, . If , the trace must be positive, so both eigenvalues are positive (local min). If , the trace must be negative, so both eigenvalues are negative (local max).
  • If , then and have opposite signs. The Hessian is indefinite (saddle point).
  • If , at least one eigenvalue is zero. The Hessian is semidefinite, and the test is inconclusive.

While this shortcut is handy for 2x2 cases, for higher dimensions (which are common in machine learning), you must rely on computing the eigenvalues to determine the definiteness of the Hessian.

Test your understanding!

Let's find and classify the critical points of the function .

Step 1: Find the critical points.
Step 2: Compute the Hessian matrix.
Step 3: Evaluate the Hessian at each critical point and find its eigenvalues to classify the point.

Show answer

1. Find critical points:
First, we compute the gradient and set it to zero.


Substitute into the second equation:

Factoring this gives , so or .
Since , our critical points are and .

2. Compute the Hessian:

3. Classify the critical points:

  • At point :

    The determinant is .
    Since , the eigenvalues have opposite signs. The Hessian is indefinite. Therefore, is a saddle point.

  • At point :

    The determinant is .
    Since , the eigenvalues have the same sign. We check , which is positive. Therefore, the Hessian is positive definite. is a local minimum.
    (To be fully rigorous, the characteristic polynomial is . The roots are . Both are positive, confirming our conclusion.)

Conclusion

Today, we built a complete framework for analyzing the local behavior of multivariable functions, a critical skill for understanding machine learning optimization.

Key Takeaways:

  • Critical points are found by solving . They are necessary candidates for local extrema.
  • The Hessian matrix at a critical point describes the local curvature of the function.
  • The definiteness of the Hessian (positive definite, negative definite, or indefinite) determines the nature of the critical point.
  • The definiteness is determined by the signs of the Hessian's eigenvalues. This is the multivariable second derivative test.
    • All Local Minimum
    • All Local Maximum
    • Mixed signs Saddle Point

Preview of the Next Lesson:
We have focused on characterizing local minima. However, in machine learning, we are often interested in finding the global minimum of a loss function. A major challenge is that an algorithm might get stuck in a local minimum that isn't the global one. In our next lesson, we will introduce the powerful concepts of convex sets and convex functions. For convex functions, the landscape is shaped like a single bowl, which guarantees that any local minimum is also a global minimum. This property is fundamental to proving why optimization works for many important ML models.

Can't find a good explanation? Sign up and we'll make it for you

Sign up