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.

# 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(x,y,z,\dots \right)$, which different authors write as $\mathbf{\text{H}}\left(f\right)$, $\mathbf{\text{H}}f$, or ${\mathbf{\text{H}}}_{f}$, organizes all second partial derivatives into a matrix:
$\mathbf{\text{H}}f=\left[\begin{array}{cccc}\frac{{\partial }^{2}f}{\partial {x}^{2}}& \frac{{\partial }^{2}f}{\partial x\partial y}& \frac{{\partial }^{2}f}{\partial x\partial z}& \cdots \\ \\ \frac{{\partial }^{2}f}{\partial y\partial x}& \frac{{\partial }^{2}f}{\partial {y}^{2}}& \frac{{\partial }^{2}f}{\partial y\partial z}& \cdots \\ \\ \frac{{\partial }^{2}f}{\partial z\partial x}& \frac{{\partial }^{2}f}{\partial z\partial y}& \frac{{\partial }^{2}f}{\partial {z}^{2}}& \cdots \\ \\ ⋮& ⋮& ⋮& \ddots \end{array}\right]$
So, two things to notice here:
• This only makes sense for scalar-valued function.
• This object $\mathbf{\text{H}}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({x}_{0},{y}_{0},\dots \right)$.
$\mathbf{\text{H}}f\left({x}_{0},{y}_{0},\dots \right)=\left[\begin{array}{ccc}\frac{{\partial }^{2}f}{\partial {x}^{2}}\left({x}_{0},{y}_{0},\dots \right)& \frac{{\partial }^{2}f}{\partial x\partial y}\left({x}_{0},{y}_{0},\dots \right)& \cdots \\ \\ \frac{{\partial }^{2}f}{\partial y\partial x}\left({x}_{0},{y}_{0},\dots \right)& \frac{{\partial }^{2}f}{\partial {y}^{2}}\left({x}_{0},{y}_{0},\dots \right)& \cdots \\ \\ ⋮& ⋮& \ddots \end{array}\right]$
As such, you might call this object $\mathbf{\text{H}}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(x,y\right)={x}^{3}-2xy-{y}^{6}$ at the point $\left(1,2\right)$:
Solution: Ultimately we need all the second partial derivatives of $f$, so let's first compute both partial derivatives:
$\begin{array}{rl}\phantom{\rule{1em}{0ex}}{f}_{x}\left(x,y\right)& =\frac{\partial }{\partial x}\left({x}^{3}-2xy-{y}^{6}\right)=3{x}^{2}-2y\\ \\ {f}_{y}\left(x,y\right)& =\frac{\partial }{\partial y}\left({x}^{3}-2xy-{y}^{6}\right)=-2x-6{y}^{5}\end{array}$
With these, we compute all four second partial derivatives:
$\begin{array}{rl}{f}_{xx}\left(x,y\right)& =\frac{\partial }{\partial x}\left(3{x}^{2}-2y\right)=6x\\ \\ {f}_{xy}\left(x,y\right)& =\frac{\partial }{\partial y}\left(3{x}^{2}-2y\right)=-2\\ \\ {f}_{yx}\left(x,y\right)& =\frac{\partial }{\partial x}\left(-2x-6{y}^{5}\right)=-2\\ \\ {f}_{yy}\left(x,y\right)& =\frac{\partial }{\partial y}\left(-2x-6{y}^{5}\right)=-30{y}^{4}\end{array}$
The Hessian matrix in this case is a $2×2$ matrix with these functions as entries:
$\mathbf{\text{H}}f\left(x,y\right)=\left[\begin{array}{cc}{f}_{xx}\left(x,y\right)& {f}_{yx}\left(x,y\right)\\ {f}_{xy}\left(x,y\right)& {f}_{yy}\left(x,y\right)\end{array}\right]=\left[\begin{array}{cc}6x& -2\\ -2& -30{y}^{4}\end{array}\right]$
We were asked to evaluate this at the point $\left(x,y\right)=\left(1,2\right)$, so we plug in these values:
$\mathbf{\text{H}}f\left(1,2\right)=\left[\begin{array}{cc}6\left(1\right)& -2\\ -2& -30\left(2{\right)}^{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:
$\text{det}\left(\left[\begin{array}{cc}6& -2\\ -2& -480\end{array}\right]\right)=6\left(-480\right)-\left(-2\right)\left(-2\right)=-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?

• will there be videos and exercises (mostly interested in the exercises) for these topics any time soon?
• Me too. Would love to see exercises in multivariable calculus, differential equations and linear algebra.
• Is the Hessian in any way related to the Jacobian matrix?
• More formally: H (f(x)) = J (∇ f(x))^T.
It also relates to the Laplacian as an operator: Δf = ∇²f = trace (H(f)).
• Should the determinant in the final step be: 180xy^4 - 4?
• I agree partially with Marcel Brown; as the determinant is calculated in a 2x2 matrix by ad-bc, in this form bc=(-2)^2 = 4, hence -bc = -4. However, ab.coefficient = 6*-30 = -180, not 180 as Marcel stated.
• Why is the last second partial derivative not -30y^4?
• Why is fyx= d/dy(3x^2-2y) and not d/dx(-2x-6y^5)? Wouldn't it be the partial derivative with respect to x of the first partial derivative with respect to y? I ask the same for fxy= d/dx(-2x-6y^5) not being d/dy(3x^2-2y).
• It is both! Whether you derivate with respect to x first then y, or with respect to y first then x, you get the same answer. Notice here that fxy = fyx = -2. That is Clairaut's theorem.
• What are some of the practical applications of the determinant of a Hessian matrix?
• Evaluating it can tell you whether you are at a maximum, minimum, or a saddle point. It has all the same abilities as a second derivative in a uni-variate function.
• why hessian makes sense only for a scalar valued function?