If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

The Hessian

The Hessian is a matrix that organizes all the second partial derivatives of a function.

The Hessian matrix

The "Hessian matrix" of a multivariable function f, left parenthesis, x, comma, y, comma, z, comma, dots, right parenthesis, which different authors write as start bold text, H, end bold text, left parenthesis, f, right parenthesis, start bold text, H, end bold text, f, or start bold text, H, end bold text, start subscript, f, end subscript, organizes all second partial derivatives into a matrix:
Hf=[2fx22fxy2fxz2fyx2fy22fyz2fzx2fzy2fz2]\textbf{H}f = \left[ \begin{array}{ccc} \dfrac{\partial^2 f}{\partial \blueD{x}^2} & \dfrac{\partial^2 f}{\partial \blueD{x} \partial \redD{y}} & \dfrac{\partial^2 f}{\partial \blueD{x} \partial \greenE{z}} & \cdots \\\\ \dfrac{\partial^2 f}{\partial \redD{y} \partial \blueD{x}} & \dfrac{\partial^2 f}{\partial \redD{y}^2} & \dfrac{\partial^2 f}{\partial \redD{y} \partial \greenE{z}} & \cdots \\\\ \dfrac{\partial^2 f}{\partial \greenE{z} \partial \blueD{x}} & \dfrac{\partial^2 f}{\partial \greenE{z} \partial \redD{y}} & \dfrac{\partial^2 f}{\partial \greenE{z}^2} & \cdots \\\\ \vdots & \vdots & \vdots & \ddots \end{array} \right]
So, two things to notice here:
  • This only makes sense for scalar-valued function.
  • This object start bold text, H, end bold text, f is no ordinary matrix; it is a matrix with functions as entries. In other words, it is meant to be evaluated at some point left parenthesis, x, start subscript, 0, end subscript, comma, y, start subscript, 0, end subscript, comma, dots, right parenthesis.
    Hf(x0,y0,)=[2fx2(x0,y0,)2fxy(x0,y0,)2fyx(x0,y0,)2fy2(x0,y0,)]\textbf{H}f(x_0, y_0, \dots) = \left[ \begin{array}{ccc} \dfrac{\partial^2 f}{\partial \blueD{x}^2}(x_0, y_0, \dots) & \dfrac{\partial^2 f}{\partial \blueD{x} \partial \redD{y}}(x_0, y_0, \dots) & \cdots \\\\ \dfrac{\partial^2 f}{\partial \redD{y} \partial \blueD{x}}(x_0, y_0, \dots) & \dfrac{\partial^2 f}{\partial \redD{y}^2}(x_0, y_0, \dots) & \cdots \\\\ \vdots & \vdots & \ddots \end{array} \right]
As such, you might call this object start bold text, H, end bold text, f a "matrix-valued" function. Funky, right?
One more important thing, the word "Hessian" also sometimes refers to the determinant of this matrix, instead of to the matrix itself.

Example: Computing a Hessian

Problem: Compute the Hessian of f, left parenthesis, x, comma, y, right parenthesis, equals, x, cubed, minus, 2, x, y, minus, y, start superscript, 6, end superscript at the point left parenthesis, 1, comma, 2, right parenthesis:
Solution: Ultimately we need all the second partial derivatives of f, so let's first compute both partial derivatives:
fx(x,y)=x(x32xyy6)=3x22yfy(x,y)=y(x32xyy6)=2x6y5\begin{aligned} \quad f_x(x, y) &= \dfrac{\partial}{\partial x} (x^3 - 2xy - y^6) = 3x^2 - 2y \\\\ f_y(x, y) &= \dfrac{\partial}{\partial y} (x^3 - 2xy - y^6) = -2x - 6y^5 \end{aligned}
With these, we compute all four second partial derivatives:
fxx(x,y)=x(3x22y)=6xfxy(x,y)=y(3x22y)=2fyx(x,y)=x(2x6y5)=2fyy(x,y)=y(2x6y5)=30y4\begin{aligned} f_{xx}(x, y) &= \dfrac{\partial}{\partial x} (3x^2 - 2y) = 6x \\\\ f_{xy}(x, y) &= \dfrac{\partial}{\partial y} (3x^2 - 2y) = -2 \\\\ f_{yx}(x, y) &= \dfrac{\partial}{\partial x} (-2x - 6y^5) = -2 \\\\ f_{yy}(x, y) &= \dfrac{\partial}{\partial y} (-2x - 6y^5) = -30y^4 \end{aligned}
The Hessian matrix in this case is a 2, times, 2 matrix with these functions as entries:
Hf(x,y)=[fxx(x,y)fyx(x,y)fxy(x,y)fyy(x,y)]=[6x2230y4]\textbf{H}f(x, y) = \left[ \begin{array}{cc} f_{xx}(x, y) & f_{yx}(x, y) \\ f_{xy}(x, y) & f_{yy}(x, y) \end{array} \right] = \left[ \begin{array}{cc} 6x & -2 \\ -2 & -30y^4 \end{array} \right]
We were asked to evaluate this at the point left parenthesis, x, comma, y, right parenthesis, equals, left parenthesis, 1, comma, 2, right parenthesis, so we plug in these values:
Hf(1,2)=[6(1)2230(2)4]=[622480]\textbf{H}f(1, 2) = \left[ \begin{array}{cc} 6(1) & -2 \\ -2 & -30(2)^4 \end{array} \right] = \left[ \begin{array}{cc} 6 & -2 \\ -2 & -480 \end{array} \right]
Now, the problem is ambiguous, since the "Hessian" can refer either to this matrix or to its determinant. What you want depends on context. For example, in optimizing multivariable functions, there is something called the "second partial derivative test" which uses the Hessian determinant. When the Hessian is used to approximate functions, you just use the matrix itself.
If it's the determinant we want, here's what we get:
det([622480])=6(480)(2)(2)=2884\text{det}\left( \left[ \begin{array}{cc} 6 & -2 \\ -2 & -480 \end{array} \right] \right) = 6(-480) - (-2)(-2) = -2884

Uses

By capturing all the second-derivative information of a multivariable function, the Hessian matrix often plays a role analogous to the ordinary second derivative in single variable calculus. Most notably, it arises in these two cases:

Want to join the conversation?