Hessian Calculator

Calculate the Hessian matrix of a multivariable function using symbolic second-order partial derivatives. Evaluate the Hessian at a point and calculate its determinant for two- and three-variable functions.

Enter Your Function

Enter a scalar function such as x^2 + y^2, x^2 + xy + y^2, or x^2 + y^2 + z^2.

Enter x,y for 2 variables or x,y,z for 3 variables.

Quick examples

What Is a Hessian Matrix?

The Hessian matrix is a square matrix containing the second-order partial derivatives of a scalar function.

\[ H_f= \begin{pmatrix} f_{xx} & f_{xy}\\ f_{yx} & f_{yy} \end{pmatrix} \]

For three variables:

\[ H_f= \begin{pmatrix} f_{xx} & f_{xy} & f_{xz}\\ f_{yx} & f_{yy} & f_{yz}\\ f_{zx} & f_{zy} & f_{zz} \end{pmatrix} \]

Hessian matrices are important in multivariable optimization, curvature analysis, critical-point classification and second-order approximations.

Hessian Matrix Formula

For a function of two variables \(f(x,y)\), the Hessian matrix contains all four second-order partial derivatives.

\[ H_f(x,y)= \begin{pmatrix} \dfrac{\partial^2 f}{\partial x^2} & \dfrac{\partial^2 f}{\partial x\partial y} \\[12pt] \dfrac{\partial^2 f}{\partial y\partial x} & \dfrac{\partial^2 f}{\partial y^2} \end{pmatrix}. \]

For three variables:

\[ H_f= \begin{pmatrix} f_{xx}&f_{xy}&f_{xz}\\ f_{yx}&f_{yy}&f_{yz}\\ f_{zx}&f_{zy}&f_{zz} \end{pmatrix}. \]

When the relevant second partial derivatives are continuous, the mixed partial derivatives agree: \(f_{xy}=f_{yx}\).

Hessian and Critical Points

The Hessian is especially useful after finding a critical point where the gradient is zero.

\[ \nabla f(a,b)= \begin{pmatrix} f_x(a,b)\\ f_y(a,b) \end{pmatrix} = \begin{pmatrix} 0\\ 0 \end{pmatrix}. \]

For a two-variable function, define

\[ D= f_{xx}f_{yy} - (f_{xy})^2. \]
  • \(D>0\) and \(f_{xx}>0\): local minimum.
  • \(D>0\) and \(f_{xx}<0\): local maximum.
  • \(D<0\): saddle point.
  • \(D=0\): the second derivative test is inconclusive.

Why Is the Hessian Important?

Multivariable Optimization

Hessians describe local curvature and help distinguish minima, maxima and saddle points.

Numerical Optimization

Newton-type optimization algorithms use second-order derivative information to improve search directions.

Curvature

The Hessian describes how the gradient changes around a point.

Taylor Approximation

The Hessian appears in the quadratic term of the multivariable Taylor expansion.

Hessian and Taylor Approximation

Near a point \(a\), a twice-differentiable scalar function can be approximated by

\[ f(a+h) \approx f(a) + \nabla f(a)^T h + \frac12 h^T H_f(a)h. \]

The Hessian therefore supplies the second-order curvature information in the local quadratic model.

Hessian Calculator Examples

Example 1

\(f(x,y)=x^2+y^2\)

\[ H_f= \begin{pmatrix} 2&0\\ 0&2 \end{pmatrix}. \]

The Hessian is positive definite.

Example 2

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

\[ H_f= \begin{pmatrix} 2&0\\ 0&-2 \end{pmatrix}. \]

The Hessian is indefinite.

Example 3

\(f(x,y,z)=x^2+y^2+z^2\)

\[ H_f= \begin{pmatrix} 2&0&0\\ 0&2&0\\ 0&0&2 \end{pmatrix}. \]

How to Use the Hessian Calculator

  1. Enter a scalar function.
  2. Select either two or three variables.
  3. Use \(x,y\) for two-variable functions.
  4. Use \(x,y,z\) for three-variable functions.
  5. Optionally enter an evaluation point.
  6. Click Calculate Hessian.

The symbolic Hessian is calculated first. If you provide a point, the function, gradient, Hessian and determinant are also evaluated numerically at that point.

Supported Mathematical Expressions

  • Addition and subtraction
  • Multiplication and division
  • Powers such as \(x^2\)
  • Implicit multiplication such as \(2x\)
  • Parentheses
  • \(x,y,z\)
  • \(e,\pi\)
  • \(\sin,\cos,\tan\)
  • \(\sec,\csc,\cot\)
  • \(\arcsin,\arccos,\arctan\)
  • \(\ln,\log,\log_{10}\)
  • \(\exp\)
  • \(\sqrt{x}\)

Frequently Asked Questions

A Hessian matrix is a square matrix containing the second-order partial derivatives of a scalar multivariable function.

First calculate the partial derivatives with respect to each variable. Then differentiate those derivatives again with respect to each variable.

The Hessian determinant is the determinant of the Hessian matrix. For two-variable functions it is commonly used in the second derivative test.

Yes. Enter coordinates such as 2,3 or 2,3,4 and the calculator evaluates the function, gradient, Hessian and determinant at that point.

If the relevant second partial derivatives are continuous in a neighborhood, mixed partial derivatives agree and the Hessian is symmetric.