This Hessian matrix calculator finds the matrix of second partial derivatives of a function at a point, then reports its determinant, eigenvalues and the gradient, and tells you whether the point is a local minimum, a local maximum or a saddle point. Enter the function and the point, and read the classification.
Hessian Matrix Calculator
Second-derivative matrix of f(x, y) or f(x, y, z) at a point, with eigenvalues, determinant, gradient and a minimum / maximum / saddle verdict.
Starting values: the calculator opens with f(x, y) = x^3 + y^3 – 3xy at the point (1, 1). The Hessian there has rows (6, -3) and (-3, 6), the determinant is 27 and the eigenvalues are 3 and 9, so the point is a local minimum.
What the Hessian is
The Hessian of a function of two variables is the matrix of all its second partial derivatives:
H = [ fxx fxy ; fyx fyy ]
Where fxx is the second derivative with respect to x, fyy is the second derivative with respect to y, and fxy and fyx are the mixed derivatives, which are equal for smooth functions. The Hessian describes the curvature of the surface at a point, in the same way that the second derivative describes the curvature of a curve.
The second derivative test
At a critical point, where the gradient is zero, the Hessian tells you the type of point:
- Determinant greater than 0 and fxx greater than 0: local minimum.
- Determinant greater than 0 and fxx less than 0: local maximum.
- Determinant less than 0: saddle point.
- Determinant equal to 0: the test is inconclusive.
The same result follows from the eigenvalues. If both are positive, the point is a minimum. If both are negative, it is a maximum. If they have opposite signs, it is a saddle.
Worked examples
Example 1: the default function at (1, 1)
For f = x^3 + y^3 – 3xy, the first derivatives are 3x^2 – 3y and 3y^2 – 3x, which are both zero at (1, 1), so the point is critical. The second derivatives are fxx = 6x = 6, fyy = 6y = 6 and fxy = -3. The determinant is 6 x 6 – (-3) x (-3) = 27, which is positive, and fxx is positive, so the point is a local minimum. The eigenvalues, 3 and 9, are both positive and agree.
Example 2: the same function at (0, 0)
The gradient is also zero at the origin. Here fxx = 0, fyy = 0 and fxy = -3, so the determinant is -9. A negative determinant means a saddle point, and the eigenvalues, 3 and -3, have opposite signs.
Example 3: simple bowls and saddles
For f = x^2 + y^2, the Hessian is the matrix with 2 on the diagonal, so both eigenvalues are 2 and the origin is a minimum. For f = x^2 – y^2, the diagonal entries are 2 and -2, the determinant is -4 and the origin is a saddle point.
Example 4: when the test fails
For f = x^4 + y^4, the Hessian at the origin is the zero matrix, with determinant 0. The test gives no answer, even though the origin is in fact a minimum. In such a case, look at higher-order terms or compare the function values nearby.
Accuracy and limits
The calculator estimates derivatives numerically, not symbolically, so results are accurate to about five or six significant digits. A value that should be exactly zero may show as a very small number, such as 0.000001, and you should read it as zero. The classification is only meaningful at a point where the gradient is zero, so check the gradient value the calculator reports before trusting the type. For a point that is not critical, the Hessian still describes curvature, but the point is neither a minimum nor a maximum.
Where the Hessian is used
- Optimization, where Newton-type methods use the Hessian to choose the next step.
- Economics and engineering, to confirm that a cost or energy function is at a true minimum.
- Machine learning, where the eigenvalues of the Hessian describe how sharply a loss function curves.
Reading the eigenvalues
The eigenvalues are the principal curvatures of the surface. A large eigenvalue means the function bends sharply in that direction, and a small one means it is nearly flat. In the default example, the eigenvalue 3 belongs to the direction in which x and y move together, and 9 to the direction in which they move in opposite directions, so the surface curves more steeply across that diagonal. When the eigenvalues are very different in size, the surface is shaped like a long, narrow valley, which is the situation where simple gradient methods converge slowly.
A quick check by hand
For two variables, you can verify the calculator with a few lines of algebra. Differentiate twice, substitute the point, and compute the determinant as fxx times fyy minus fxy squared. If your answer disagrees with the calculator by more than a rounding error in the fifth or sixth digit, recheck the function you entered, especially exponents and signs.
Frequently asked questions
What is a Hessian matrix?
It is the square matrix of the second partial derivatives of a function. It describes the local curvature of the function.
How do I use the Hessian to find a minimum or maximum?
Find a point where the gradient is zero, then check the Hessian. Positive eigenvalues mean a minimum, negative ones a maximum, and mixed signs a saddle point.
What does a negative determinant mean?
For a two-variable function, it means the point is a saddle point.
Why does the calculator show tiny numbers instead of zero?
Derivatives are estimated numerically, so a value that should be exactly zero can appear as a very small number.
What if the determinant is zero?
The second derivative test is inconclusive, and you need to look at higher-order terms or nearby values.
