Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 54

Classifying Critical Points with the Hessian Matrix

Recommended resources

Hello! Welcome to our next lesson on matrix calculus.

In our previous session, we explored the chain rule for vector-valued functions and saw how it provides the core mechanism for backpropagation in deep learning. We focused on first-order derivatives—gradients and Jacobians—which tell us the direction of steepest ascent and are essential for optimization algorithms like gradient descent.

Today, we move from the direction of change to the curvature of a function. When we find a point where the gradient is zero, how do we know if we've found a valley floor (a minimum), a hilltop (a maximum), or something complex like a Pringles chip (a saddle point)? To answer this, we need second-order derivatives. This lesson introduces the Hessian matrix, the multivariable generalization of the second derivative. Our goal is to learn how to use the Hessian to classify these critical points, a skill crucial for understanding optimization landscapes in both deep learning and physics.


1. From Second Derivative to Hessian Matrix

In single-variable calculus, the second derivative tells you about the concavity of a function. A positive second derivative at a critical point means a local minimum, while a negative one means a local maximum.

For a scalar-valued function of multiple variables, where , the second derivative is no longer a single number. It becomes an matrix called the Hessian matrix.

The Hessian matrix, denoted or , is the matrix of all second-order partial derivatives of the function . For a function , its Hessian is:

An important property, thanks to Clairaut's theorem, is that if the second partial derivatives are continuous, the order of differentiation doesn't matter (e.g., ). This means the Hessian matrix is symmetric. This symmetry is a crucial property we will leverage throughout our course.

To get comfortable with computing the Hessian, let's work through a concrete example.

Hessian Matrix: Concepts, Properties, and Applications

The following article from DataCamp provides a clear definition of the Hessian and a step-by-step example of how to compute it for a function of two variables.

Please read the sections 'What Is the Hessian Matrix?' and 'Hessian Matrix Example'. Focus on understanding how each element of the matrix is constructed from the second partial derivatives of the given function.



2. The Second Derivative Test for Multivariable Functions

Now that we have the Hessian, how do we use it? The process is a direct parallel to the single-variable case:

  1. Find the critical points of the function. These are the points where the gradient is the zero vector, . These are our candidates for local minima, maxima, or saddle points.
  2. At each critical point, evaluate the Hessian matrix.
  3. Analyze the properties of the Hessian matrix at that point to classify it.

The intuition comes from the second-order Taylor expansion of the function around a critical point :

Since at a critical point, this simplifies to:

The expression is a quadratic form. It describes the curvature of the function around . The nature of the critical point depends entirely on whether this quadratic form is always positive, always negative, or changes sign as we move in different directions .

The following video provides an excellent explanation of this core idea.

Multivariable Calculus 18 | Local Extrema

This video from 'The Bright Side of Mathematics' clearly explains the conditions for local extrema and how they relate to the properties of the Hessian matrix.

Please watch from 04:32 to 10:56. Pay close attention to: The definition of a critical point (where the gradient is zero). How the second-order Taylor approximation simplifies at a critical point. The definitions of positive definite, negative definite, and indefinite Hessian matrices and how they correspond to local minima, maxima, and saddle points.

To summarize the Second Derivative Test: at a critical point :

  • If the Hessian is positive definite (i.e., for all non-zero ), then has a local minimum at .
  • If is negative definite (i.e., for all non-zero ), then has a local maximum at .
  • If is indefinite (i.e., takes both positive and negative values), then has a saddle point at .


3. Eigenvalues: The Key to Definiteness

The definitions of definiteness are conceptually clear, but how do we check them in practice? This is where eigenvalues come to the rescue. Since the Hessian is a symmetric matrix, it has real eigenvalues and an orthonormal basis of eigenvectors. This structure gives us a powerful and intuitive way to understand the quadratic form.

Let's explore this connection.

A Practical Guide to the Hessian

This guide provides a fantastic intuition for why eigenvalues are the key to classifying critical points. It shows that along the direction of an eigenvector, the function's curvature is directly determined by the corresponding eigenvalue.

Please read from the top of page 2, starting with 'First, what is a critical point?', up to the end of the second paragraph on page 3, ending with '...in the direction of the eigenvectors.' Focus on the derivation that shows along an eigenvector direction v, the function f behaves like (λ/2)t².

The key insight from the reading is profound: in the direction of an eigenvector with eigenvalue , the function locally behaves like a simple parabola . This simplifies the entire problem! The complex curvature of a multivariable function can be understood by looking at the simple parabolic curvatures along its principal axes (the eigenvectors).

This leads to a direct and powerful test for definiteness:

  • Positive Definite: All eigenvalues are positive ().
  • Negative Definite: All eigenvalues are negative ().
  • Indefinite: At least one positive and at least one negative eigenvalue.
  • Semi-definite: Some eigenvalues are zero, and the rest are all of the same sign (e.g., for positive semi-definite).
Test your understanding!

Suppose you've found a critical point for a function and calculated its Hessian matrix at that point to be:

Is this critical point a local minimum, local maximum, or saddle point? Why?

Show answer

The Hessian is a diagonal matrix, so its eigenvalues are simply the diagonal entries: , , and .

Since there is at least one positive eigenvalue (3 and 5) and at least one negative eigenvalue (-2), the Hessian is indefinite. Therefore, the critical point is a saddle point.

Intuitively, if you move from the critical point along the x-axis or z-axis, the function curves upwards (like a minimum). But if you move along the y-axis, the function curves downwards (like a maximum).



4. A Practical Test for the 2D Case

While the eigenvalue test is the most fundamental, computing eigenvalues can be tedious. For the common 2-variable case, , there is a well-known shortcut using the determinant and the top-left entry of the Hessian. This is likely the "Second Derivative Test" you encountered in Calculus 3.

Let the Hessian at a critical point be and let .

  1. If and , then is positive definite local minimum.
  2. If and , then is negative definite local maximum.
  3. If , then is indefinite saddle point.
  4. If , the test is inconclusive.

Why does this work? The determinant is the product of the eigenvalues ().

  • If , the eigenvalues have the same sign. The sign of (which can be related to the trace, ) then tells you if they are both positive or both negative.
  • If , the eigenvalues must have opposite signs.

The image below beautifully summarizes this test with a concrete example and a 3D plot.

Classification of Critical Points using the Hessian Matrix
This image shows the classification of four critical points for the function f(x, y) = x³/3 - x + y³ - y. It connects the algebraic conditions of the determinant test (in the table) to the visual geometry of the surface plot, where you can see the local min, max, and two saddle points.

What about the inconclusive case, ? This implies at least one eigenvalue is zero. In this situation, the quadratic approximation is "flat" in that direction, and we must analyze higher-order terms of the function to classify the point. The functions (a minimum) and (a saddle) both have a zero Hessian at the origin, showing why the test fails.



Conclusion

In this lesson, we have moved beyond first-order approximations and explored the curvature of multivariable functions using the Hessian matrix.

Key Takeaways:

  • The Hessian matrix is the matrix of second partial derivatives of a scalar-valued function. For most functions we care about, it is symmetric.
  • The Second Derivative Test allows us to classify critical points (where ) as local minima, maxima, or saddle points.
  • The classification depends on the definiteness of the Hessian at the critical point, which is fundamentally determined by the signs of its eigenvalues.
    • All positive eigenvalues Local Minimum.
    • All negative eigenvalues Local Maximum.
    • A mix of positive and negative eigenvalues Saddle Point.
  • For 2D functions, a practical shortcut using the Hessian's determinant provides a quick way to classify points.

Preview of the Next Lesson:

We've established that a positive definite Hessian signals a local minimum. In our next lesson, we will elevate this concept. We'll see that if a function's Hessian is positive definite everywhere in its domain, not just at a critical point, the function has a special property called convexity. Convex functions, which curve upwards everywhere, are the holy grail of optimization because any local minimum is also a global minimum. This property is absolutely central to many optimization algorithms in machine learning.