Hessian Matrix Calculator

Compute second partial derivatives, Hessian determinants, eigenvalue signs, and local critical-point classification.

Results are calculated automatically as you enter data.

Formula and interpretation
ResultEnter a function to build the Hessian.

▼ See explanations and tips below ▼

What Is a Hessian Matrix?

A Hessian matrix is a square matrix that organizes the second partial derivatives of a multivariable function. In single-variable calculus, the second derivative helps describe whether a graph bends upward or downward. The Hessian extends that idea to functions with two or three variables, where the function can bend differently in different directions.

For a real-valued function \(f(x_1, x_2, \ldots, x_n)\), the Hessian matrix is

$$ H_f(\mathbf{x}) = \left[\frac{\partial^2 f}{\partial x_i\,\partial x_j}\right]_{i,j=1}^n $$

For a function of two variables, this becomes

$$ H_f(x,y)= \begin{bmatrix} f_{xx} & f_{xy} \\ f_{yx} & f_{yy} \end{bmatrix} $$

Each entry measures how a first partial derivative changes as one variable changes. The diagonal entries, such as \(f_{xx}\) and \(f_{yy}\), measure curvature along a coordinate direction. The off-diagonal entries, such as \(f_{xy}\), measure mixed curvature involving more than one variable.

The Hessian is most useful near a critical point, where the gradient is zero or close to zero. At such a point, first-derivative information has stopped giving a clear increase or decrease direction, so second-derivative information helps describe the local shape.


Why the Hessian Matrix Matters

The Hessian connects calculus, linear algebra, and optimization. It helps answer questions such as:

  • Is a critical point likely a local minimum, local maximum, or saddle point?
  • Does the function curve upward in every nearby direction?
  • Does it curve downward in every nearby direction?
  • Does it rise in some directions and fall in others?
  • Is the second-derivative test unable to decide because the curvature is too flat or too close to zero?

This matters in multivariable calculus because a point can look flat in the first-derivative sense while still having very different behavior in nearby directions. It also matters in optimization, where the Hessian describes local curvature around candidate solutions.


Key Terms to Know

  • Partial derivative: A derivative taken with respect to one variable while the other variables are held fixed.
  • Gradient: The vector of first partial derivatives. For a function of three variables, \(\nabla f=(f_x,f_y,f_z)\).
  • Critical point: A point where the gradient is zero, or close enough to zero for a numerical test.
  • Second partial derivative: A derivative of a partial derivative, such as \(f_{xx}\), \(f_{xy}\), or \(f_{yz}\).
  • Eigenvalue: A number that describes how a matrix stretches or reverses certain directions. For a symmetric Hessian, eigenvalue signs reveal curvature directions.
  • Positive definite Hessian: A Hessian whose eigenvalues are all positive. At a critical point, this indicates upward curvature in every direction.
  • Negative definite Hessian: A Hessian whose eigenvalues are all negative. At a critical point, this indicates downward curvature in every direction.
  • Indefinite Hessian: A Hessian with both positive and negative eigenvalues. At a critical point, this indicates saddle-like behavior.
  • Tolerance: A small positive threshold used to decide whether values are close enough to zero for a numerical classification.

How Hessian-Based Classification Works

The Hessian is built by differentiating the function once to form the gradient, then differentiating each gradient component again.

For variables \(x_1, x_2, \ldots, x_n\), the entry in row \(i\) and column \(j\) is

$$ H_{ij}=\frac{\partial^2 f}{\partial x_i\,\partial x_j} $$

At a point \(\mathbf{a}\), the second-order Taylor approximation has the form

$$ f(\mathbf{a}+\mathbf{h}) \approx f(\mathbf{a}) + \nabla f(\mathbf{a})\cdot \mathbf{h} + \frac{1}{2}\mathbf{h}^T H_f(\mathbf{a})\mathbf{h} $$

When \(\mathbf{a}\) is a critical point, \(\nabla f(\mathbf{a})=\mathbf{0}\), so the linear term disappears. The nearby behavior is then controlled mainly by the quadratic term

$$ \frac{1}{2}\mathbf{h}^T H_f(\mathbf{a})\mathbf{h} $$

That is why the Hessian can classify local curvature:

  • If all Hessian eigenvalues are positive, the quadratic term is positive in every nonzero direction, so the point is likely a local minimum.
  • If all Hessian eigenvalues are negative, the quadratic term is negative in every nonzero direction, so the point is likely a local maximum.
  • If the Hessian has both positive and negative eigenvalues, the function rises in some directions and falls in others, so the point is a saddle point.
  • If one or more eigenvalues are zero or very close to zero, the second-derivative test may not have enough information, so the result is inconclusive.

For two-variable functions, the same idea is often written using the Hessian determinant:

$$ D=f_{xx}f_{yy}-f_{xy}^2 $$

At a critical point:

  • If \(D>0\) and \(f_{xx}>0\), the point is a local minimum.
  • If \(D>0\) and \(f_{xx}<0\), the point is a local maximum.
  • If \(D<0\), the point is a saddle point.
  • If \(D=0\), the test is inconclusive.

The eigenvalue version is more general and works naturally for both 2D and 3D Hessian matrices.


Examples of Hessian Matrices in Practice

Example 1: A local minimum

Consider

$$ f(x,y)=x^2+2y^2+xy $$

The first partial derivatives are

$$ f_x=2x+y $$
$$ f_y=x+4y $$

At \((0,0)\), both partial derivatives are zero, so \((0,0)\) is a critical point.

The Hessian is

$$ H_f(x,y)= \begin{bmatrix} 2 & 1 \\ 1 & 4 \end{bmatrix} $$

Its eigenvalues are

$$ \lambda_1=3+\sqrt{2}, \qquad \lambda_2=3-\sqrt{2} $$

Both are positive, so the function has upward curvature in every direction near \((0,0)\). The point is classified as a local minimum.


Example 2: A saddle point

Consider

$$ f(x,y)=x^2-y^2 $$

The gradient is

$$ \nabla f(x,y)=(2x,-2y) $$

At \((0,0)\), the gradient is zero. The Hessian is

$$ H_f(x,y)= \begin{bmatrix} 2 & 0 \\ 0 & -2 \end{bmatrix} $$

The eigenvalues are \(2\) and \(-2\). One is positive and one is negative, so the graph curves upward in one direction and downward in another. The origin is a saddle point.


Example 3: An inconclusive second-derivative test

Consider

$$ f(x,y)=x^4+y^4 $$

The origin is a critical point because

$$ \nabla f(0,0)=(0,0) $$

The Hessian is

$$ H_f(x,y)= \begin{bmatrix} 12x^2 & 0 \\ 0 & 12y^2 \end{bmatrix} $$

At \((0,0)\), this becomes

$$ H_f(0,0)= \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} $$

Both eigenvalues are zero, so the Hessian test is inconclusive. In this particular example, the origin is still a local minimum, but the second-derivative information alone is too flat to prove it. This is an important reminder: “inconclusive” does not mean “no minimum” or “no maximum.” It means the Hessian test cannot decide.


Example 4: A 3D saddle point

For

$$ f(x,y,z)=x^2+y^2-z^2+xy $$

at \((0,0,0)\), the gradient is zero. The Hessian is

$$ H_f(x,y,z)= \begin{bmatrix} 2 & 1 & 0 \\ 1 & 2 & 0 \\ 0 & 0 & -2 \end{bmatrix} $$

The eigenvalues are \(3\), \(1\), and \(-2\). Because the signs are mixed, the point is classified as a saddle point.


How to Interpret the Result

A Hessian result should be read together with the gradient. The Hessian describes curvature, but local minimum and maximum classification only makes sense when the point is critical or close enough to critical under the chosen tolerance.

The main result labels mean:

  • Strict local minimum: The evaluated gradient is zero and the Hessian is positive definite beyond its scale-aware numerical threshold.
  • Strict local maximum: The evaluated gradient is zero and the Hessian is negative definite beyond its scale-aware numerical threshold.
  • Saddle point: The evaluated gradient is zero and the Hessian has both positive and negative eigenvalues beyond its scale-aware numerical threshold.
  • Near a local-minimum candidate: The gradient is within the entered gradient tolerance, but is not exactly zero, and the Hessian is positive definite.
  • Near a local-maximum candidate: The gradient is within the entered gradient tolerance, but is not exactly zero, and the Hessian is negative definite.
  • Near a saddle-type candidate: The gradient is within the entered gradient tolerance, but is not exactly zero, and the Hessian is indefinite.
  • Inconclusive: At least one eigenvalue is near zero, so the second-derivative test does not provide enough information.
  • Not a critical point: The gradient norm is larger than the entered gradient tolerance, so the point is not classified using the Hessian test.
  • Hessian computed: The Hessian-related values were computed, but point classification was turned off.

The supporting outputs add more detail:

  • Hessian matrix: Shows the second partial derivatives and their evaluated values at the selected point.
  • Gradient: Shows whether the chosen point is close to critical.
  • Eigenvalues: Show curvature signs and are the main basis for classification.
  • det\((H)\): In 2D, its sign helps distinguish same-sign curvature from mixed-sign curvature.
  • trace\((H)\): Adds the diagonal Hessian entries together and gives another summary of the matrix.
  • Contour preview: Helps visualize nearby behavior in the \(x\)-\(y\) plane. In 3D mode, it is an \(x\)-\(y\) slice at the selected \(z\) value, not a full 3D visualization.

Common Mistakes and Misconceptions

Mistake 1: Classifying a point that is not critical.
A Hessian can be computed at many points, but the second-derivative test for local extrema is intended for critical points. If the gradient is not close to zero, the point may simply be on a slope.

Mistake 2: Treating “inconclusive” as a final classification.
An inconclusive result means the Hessian test cannot decide. Higher-order terms, direct reasoning, graphing, or another method may still classify the point.

Mistake 3: Choosing an unsuitable tolerance.
The entered tolerance applies only to the gradient norm. A value that is too large can treat a merely nearby point as approximately stationary. Hessian eigenvalues use a separate scale-aware floating-point threshold.

Mistake 4: Forgetting domain restrictions.
Expressions such as \(\ln(x)\), \(\sqrt{x}\), and division by a variable have restricted domains. A point outside the domain, or on a nondifferentiable boundary, cannot be classified in the usual way.

Mistake 5: Assuming log means base 10.
In this calculator, log is treated as the natural logarithm, the same as ln.

Mistake 6: Typing implicit multiplication.
Use explicit multiplication such as 2*x or x*(y+1). Inputs such as 2x or x(y+1) are not accepted.

Mistake 7: Expecting the 3D preview to show a full 3D surface.
The visual preview is an \(x\)-\(y\) slice. In 3D mode, it holds \(z\) fixed at the selected value.


When to Use a Hessian Matrix

Use Hessian analysis when you want to study second-order behavior of a multivariable function. Common use cases include:

  • Classifying critical points in multivariable calculus.
  • Checking whether a candidate solution in an optimization problem looks like a local minimum or maximum.
  • Understanding saddle points, where first derivatives vanish but the function is not locally highest or lowest.
  • Studying local quadratic approximations of a function.
  • Comparing curvature directions using eigenvalues.
  • Exploring how a two-variable or three-variable function behaves near a selected point.

Limitations and Things to Keep in Mind

The Hessian test depends on assumptions. The function should be real-valued and differentiable enough near the point for the second partial derivatives to make sense. When the relevant second partial derivatives are continuous, the Hessian is symmetric, which is the setting where eigenvalue-based curvature interpretation is standard.

The classification is local, not global. A local minimum is only lower than nearby values; it may not be the lowest value over the whole domain. A local maximum is only higher than nearby values; it may not be the largest value overall.

The entered gradient tolerance decides whether a nonzero gradient is close enough to flag the point as a nearby critical-point candidate. Eigenvalue signs use a separate threshold derived from the Hessian scale and eigensolver residual.

Ordinary values are shown with up to 7 decimal places, while very large or very small nonzero values use exponential notation. Exact zeros are displayed as \(0\).

Some functions are outside the supported input set. The calculator supports variables \(x\) and \(y\) in 2D mode, and \(x\), \(y\), and \(z\) in 3D mode. It supports constants such as \(\pi\) and \(e\), arithmetic operators, parentheses, powers, and functions such as sin, cos, tan, exp, ln, log, sqrt, and abs. It does not support more than three variables, complex-valued results, piecewise definitions, conditional expressions, or functions such as arcsin, sinh, max, min, floor, or factorial.

Be especially careful with nondifferentiable expressions. The calculator rejects unresolved abs corners when the absolute-value argument is zero, but safely normalizes smooth even powers such as abs(x)^2. It also rejects division by zero, 0^0, logarithms of non-positive values, square roots of negative values, exact tangent poles, and other invalid real-valued operations before simplifying the expression. If a finite Hessian has a determinant outside JavaScript's floating-point range, the matrix and classification remain available and the determinant card reports its sign and logarithmic magnitude.

A calculator result should support mathematical reasoning, not replace it. For coursework, proofs, engineering models, scientific work, or optimization decisions with real consequences, double-check assumptions and review the result with an appropriate method or qualified professional.


How to Use This Calculator

  1. Choose 2D or 3D mode.
  2. Enter the objective function using the supported variables: \(x\) and \(y\) in 2D, or \(x\), \(y\), and \(z\) in 3D.
  3. Use explicit multiplication, such as 2*x, x*y, or x*(y+1).
  4. Enter the point coordinates. In 3D mode, include the \(z\) coordinate.
  5. Enter a positive gradient tolerance for the stationarity check. The calculator determines the curvature threshold automatically.
  6. Leave classification enabled if you want the point classified, or turn it off if you only want the Hessian-related outputs.
  7. Review the result label, determinant, trace, gradient, eigenvalues, Hessian table, and interpretation notes.
  8. Use the graph download option only after a valid contour preview appears.

Frequently Asked Questions

What does the Hessian matrix tell me?

The Hessian tells you how a multivariable function curves near a point. At or near a critical point, the signs of its eigenvalues can indicate whether the function behaves like a local minimum, local maximum, saddle point, or an inconclusive flat case.


Is the Hessian the same as the gradient?

No. The gradient is a vector of first partial derivatives, while the Hessian is a matrix of second partial derivatives. The gradient helps identify critical points; the Hessian helps classify curvature at those points.


Why does the calculator say “Not a critical point”?

This means the gradient norm at the selected point is larger than the entered gradient tolerance. The Hessian can still be computed there, but the second-derivative classification should not be applied as if the point were critical.


What does an eigenvalue near zero mean?

An eigenvalue near zero means the function is very flat in at least one curvature direction relative to the Hessian's numerical scale. In that situation, the second-derivative test may be inconclusive because higher-order terms can control the actual local behavior.


Can a point be a local minimum even if the Hessian test is inconclusive?

Yes. For example, \(f(x,y)=x^4+y^4\) has a local minimum at the origin, but its Hessian at the origin is the zero matrix. The second-derivative test cannot detect that minimum because the decisive behavior comes from fourth-degree terms, not second-degree terms.


Does this calculator support 3D functions?

Yes. It supports functions using \(x\), \(y\), and \(z\) in 3D mode. The Hessian is then a \(3\times3\) matrix, and classification combines the gradient tolerance with scale-aware signs of the three Hessian eigenvalues.


Does the calculator use base-10 logarithms?

No. The input log is interpreted as the natural logarithm, the same as ln. For base-10 logarithms, rewrite the expression using the change-of-base relationship if needed.


Sources and References

Books

  1. Gilbert Strang and Edwin “Jed” Herman. Calculus Volume 3. OpenStax, 2016. Section 4.7, “Maxima/Minima Problems.” https://openstax.org/books/calculus-volume-3/pages/4-7-maxima-minima-problems
  2. Joel Feldman, Andrew Rechnitzer, and Elyse Yeager. CLP-3 Multivariable Calculus. University of British Columbia, online text. Section 2.9.2, “The Second Derivative Test.” https://personal.math.ubc.ca/~CLP/CLP3/clp3mc/sec_max.html
  3. Jorge Nocedal and Stephen J. Wright. Numerical Optimization. 2nd ed., Springer, 2006. Background on second-order information and optimization methods.

Online and Educational Sources

  1. University of Toronto, MAT237Y1 Course Notes. “2.7: Critical Points.” Accessed June 28, 2026. https://www.math.utoronto.ca/courses/mat237y1/20199/notes/Chapter2/S2.7.html
  2. MIT OpenCourseWare. “Positive Definite Matrices and Minima,” 18.06SC Linear Algebra, Fall 2011. Accessed June 28, 2026. https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/pages/positive-definite-matrices-and-applications/positive-definite-matrices-and-minima/