Tutorials › Calculus III › Hessian Matrices and Quadratic Forms

Critical Points and Local Extrema · Tutorial 405 of 999

Hessian Matrices and Quadratic Forms

Construct the Hessian of a function of two variables and use its quadratic form to describe second-order curvature in different directions.

Intermediate 10 min read

What You'll Learn

  • Construct the Hessian matrix from the four second partial derivatives of a two-variable function.
  • State when equality of the mixed partial derivatives ensures that the Hessian is symmetric.
  • Compute the quadratic form associated with a Hessian matrix.
  • Relate the quadratic form to the second derivative along a parametrized line.
  • Identify positive, negative, and mixed curvature from directional values of the quadratic form.
  • Distinguish curvature information from a conclusion about local maxima or minima.

Why Second Derivatives Need a Matrix

A function of two variables can bend differently in different directions. Its first partial derivatives describe first-order changes along the coordinate directions; its second partial derivatives record how those rates change. Collecting the second partial derivatives in a matrix makes it possible to examine the combined curvature along any direction.

The matrix is called the Hessian. From it, a quadratic expression gives the second derivative of the function along a line through a point. Studying that expression lets us distinguish positive, negative, and mixed second-order curvature without considering only the \(x\)- and \(y\)-directions separately.

The Hessian Matrix

Let \(f(x,y)\) have continuous second partial derivatives in a neighborhood of a point \((a,b)\). The Hessian matrix of \(f\) at that point is the matrix whose entries are the second partial derivatives, evaluated at \((a,b)\).

Definition: The Hessian of \(f\) at \((a,b)\) is
$$ \mathbf{H}_f(a,b)= \begin{pmatrix} f_{xx}(a,b) & f_{xy}(a,b)\\ f_{yx}(a,b) & f_{yy}(a,b) \end{pmatrix}. $$

Here, for example, \(f_{xy}\) means differentiate first with respect to \(x\), then with respect to \(y\). Because the second partial derivatives are continuous near \((a,b)\), the equality of mixed partials gives \(f_{xy}(a,b)=f_{yx}(a,b)\). Under this condition, the Hessian is symmetric: its entries on opposite sides of the main diagonal are equal.

The Hessian depends on the point as well as the function. For a function whose second partial derivatives vary with \(x\) and \(y\), the matrix generally changes when the point changes. It is therefore important to evaluate every entry at the same specified point before interpreting the matrix.

Worked Example: Building a Hessian at a Point

Let \(f(x,y)=x^2y+y^3\), and find its Hessian at \((1,0)\). First compute the first partial derivatives:

$$ f_x=2xy,\qquad f_y=x^2+3y^2. $$

Differentiate again to obtain all four second partial derivatives:

$$ f_{xx}=2y,\qquad f_{xy}=2x,\qquad f_{yx}=2x,\qquad f_{yy}=6y. $$

At \((1,0)\), these values are \(f_{xx}(1,0)=0\), \(f_{xy}(1,0)=2\), \(f_{yx}(1,0)=2\), and \(f_{yy}(1,0)=0\). Therefore,

$$ \mathbf{H}_f(1,0)= \begin{pmatrix} 0&2\\ 2&0 \end{pmatrix}. $$

The two mixed entries agree, as expected for this polynomial. Checking the entries against the computed second derivatives confirms that the matrix is assembled in the order \(xx,xy\) in the first row and \(yx,yy\) in the second row.

The Quadratic Form of the Hessian

A direction in the plane can be represented by a vector \(\mathbf{h}=(u,v)^\top\). The quadratic form associated with the Hessian at \((a,b)\) is obtained by multiplying the Hessian on the left by the transpose of the direction vector and on the right by the direction vector itself.

Definition: For a direction vector \(\mathbf{h}=(u,v)^\top\), the Hessian quadratic form at \((a,b)\) is
$$ Q_{(a,b)}(\mathbf{h}) =\mathbf{h}^{\top}\mathbf{H}_f(a,b)\mathbf{h}. $$

If the Hessian is symmetric, expanding the matrix product gives

$$ Q_{(a,b)}(\mathbf{h}) =f_{xx}(a,b)u^2+2f_{xy}(a,b)uv+f_{yy}(a,b)v^2. $$

The factor of \(2\) on the mixed term comes from two entries of the matrix. In detail, the first row contributes \(f_{xx}u^2+f_{xy}uv\), while the second row contributes \(f_{yx}uv+f_{yy}v^2\). Since \(f_{xy}=f_{yx}\), the two mixed contributions add to \(2f_{xy}uv\).

Why the Quadratic Form Measures Directional Curvature

To see why this expression represents second-order change in a direction, follow the straight line that starts at \((a,b)\) with direction \((u,v)\). Define the single-variable function \(g(t)=f(a+tu,b+tv)\). The chain rule first gives \(g'(t)=u f_x(a+tu,b+tv)+v f_y(a+tu,b+tv)\). Differentiating once more and applying the chain rule to each partial derivative gives

$$ g''(t)=u^2 f_{xx}(a+tu,b+tv) +uv f_{xy}(a+tu,b+tv) +uv f_{yx}(a+tu,b+tv) +v^2 f_{yy}(a+tu,b+tv). $$

At \(t=0\), the point on the line is \((a,b)\). Continuous second partial derivatives give \(f_{xy}(a,b)=f_{yx}(a,b)\), so

$$ g''(0)=f_{xx}(a,b)u^2+2f_{xy}(a,b)uv+f_{yy}(a,b)v^2 =\mathbf{h}^{\top}\mathbf{H}_f(a,b)\mathbf{h}. $$

This proves that the Hessian quadratic form is the second derivative along the chosen line at the starting point. If \(\mathbf{h}\) is a unit vector, \(g''(0)\) is the second directional derivative in that unit direction. If \(\mathbf{h}\) is not a unit vector, the value also reflects the length of the direction vector: replacing \(\mathbf{h}\) by \(c\mathbf{h}\) multiplies the quadratic form by \(c^2\).

1
Choose a point and direction.
Write the point as \((a,b)\) and the direction as \(\mathbf{h}=(u,v)^\top\).
2
Evaluate the Hessian there.
Compute each second partial derivative and substitute \((a,b)\).
3
Form the quadratic value.
Calculate \(\mathbf{h}^{\top}\mathbf{H}_f(a,b)\mathbf{h}\); its sign gives the second derivative along that line.

Positive and Negative Curvature

The sign of the quadratic form describes the sign of the second derivative in a direction. If it is positive for every nonzero direction, the second-order curvature is positive in every direction. If it is negative for every nonzero direction, the second-order curvature is negative in every direction. These statements concern the quadratic form at the specified point; they do not, by themselves, assert that the function has a local minimum or maximum there.

Worked Example: Positive Quadratic Form

Consider \(f(x,y)=2x^2+xy+\frac{3}{2}y^2\). Its second partial derivatives are \(f_{xx}=4\), \(f_{xy}=1\), \(f_{yx}=1\), and \(f_{yy}=3\). They are constant, so at \((0,0)\) the Hessian is

$$ \mathbf{H}_f(0,0)= \begin{pmatrix} 4&1\\ 1&3 \end{pmatrix}. $$

For \(\mathbf{h}=(u,v)^\top\), matrix multiplication gives

$$ Q_{(0,0)}(\mathbf{h}) = \begin{pmatrix}u&v\end{pmatrix} \begin{pmatrix}4&1\\1&3\end{pmatrix} \begin{pmatrix}u\\v\end{pmatrix} =4u^2+2uv+3v^2. $$

Complete the square:

$$ 4u^2+2uv+3v^2 =4\left(u+\frac{v}{4}\right)^2+\frac{11}{4}v^2. $$

Both terms on the right are nonnegative. If \(v\ne 0\), the second term is positive. If \(v=0\) and \((u,v)\ne(0,0)\), the first term is \(4u^2>0\). Thus \(Q_{(0,0)}(\mathbf{h})>0\) for every nonzero \(\mathbf{h}\). As a direct check, for \((u,v)=(1,0)\) the formula gives \(4\), and matrix multiplication gives \(\begin{pmatrix}1&0\end{pmatrix}\begin{pmatrix}4&1\\1&3\end{pmatrix}\begin{pmatrix}1\\0\end{pmatrix}=4\).

Worked Example: Negative Quadratic Form

Let \(f(x,y)=-x^2-2xy-3y^2\). Its second partial derivatives are \(f_{xx}=-2\), \(f_{xy}=-2\), \(f_{yx}=-2\), and \(f_{yy}=-6\). Hence

$$ \mathbf{H}_f(0,0)= \begin{pmatrix} -2&-2\\ -2&-6 \end{pmatrix}. $$

For \(\mathbf{h}=(u,v)^\top\), the quadratic form is

$$ Q_{(0,0)}(\mathbf{h}) =-2u^2-4uv-6v^2 =-2\bigl((u+v)^2+2v^2\bigr). $$

The quantity in parentheses is positive for every nonzero vector: if \(v\ne0\), then \(2v^2>0\); if \(v=0\) and the vector is nonzero, then \(u\ne0\) and \((u+v)^2=u^2>0\). Multiplication by \(-2\) makes the quadratic form strictly negative. For a numerical check, using \((u,v)=(1,0)\) gives \(Q=-2\), and the matrix product gives \(\begin{pmatrix}1&0\end{pmatrix}\begin{pmatrix}-2&-2\\-2&-6\end{pmatrix}\begin{pmatrix}1\\0\end{pmatrix}=-2\).

Mixed Curvature and the Role of Direction

A quadratic form has mixed curvature when it takes both positive and negative values on direction vectors. This means that the second derivative along some lines is positive and along other lines is negative. Looking only along the coordinate axes can miss this behavior: the mixed term \(2f_{xy}uv\) matters when both components of the direction are nonzero.

Worked Example: Mixed Curvature in Different Directions

Return to \(f(x,y)=x^2y+y^3\) at \((1,0)\), where

$$ \mathbf{H}_f(1,0)= \begin{pmatrix}0&2\\2&0\end{pmatrix}. $$

Its quadratic form is \(Q_{(1,0)}(\mathbf{h})=4uv\). For \(\mathbf{h}_1=(1,1)^\top\),

$$ Q_{(1,0)}(\mathbf{h}_1) =\begin{pmatrix}1&1\end{pmatrix} \begin{pmatrix}0&2\\2&0\end{pmatrix} \begin{pmatrix}1\\1\end{pmatrix} =4>0. $$

For \(\mathbf{h}_2=(1,-1)^\top\),

$$ Q_{(1,0)}(\mathbf{h}_2) =\begin{pmatrix}1&-1\end{pmatrix} \begin{pmatrix}0&2\\2&0\end{pmatrix} \begin{pmatrix}1\\-1\end{pmatrix} =-4<0. $$

Thus the quadratic form takes both signs. As a direct check along the first line, \(g(t)=f(1+t,t)=t+2t^2+2t^3\), so \(g''(0)=4\). Along the second, \(g(t)=f(1+t,-t)=-t-2t^2-2t^3\), so \(g''(0)=-4\). These agree with the matrix calculations. The coordinate directions give \(Q(1,0)=0\) and \(Q(0,1)=0\), showing why checking only those directions would fail to reveal the mixed behavior.

At this point the gradient is \(\nabla f(1,0)=(0,1)\), so this example is not a critical point. Its mixed curvature describes directional second derivatives, not a classification of a local extremum.

Common Pitfall: Losing the Mixed Term

A frequent error is to read the diagonal entries of the Hessian and write \(f_{xx}u^2+f_{yy}v^2\), omitting the mixed partials. For the Hessian \(\begin{pmatrix}0&2\\2&0\end{pmatrix}\), that incorrect calculation would give \(Q(u,v)=0\) for every direction. It would therefore miss the positive value in direction \((1,1)\) and the negative value in direction \((1,-1)\).

The correction is to multiply the full matrix, including both off-diagonal entries:

$$ \begin{pmatrix}u&v\end{pmatrix} \begin{pmatrix}0&2\\2&0\end{pmatrix} \begin{pmatrix}u\\v\end{pmatrix} =2uv+2uv=4uv. $$

Another important distinction is between curvature and classification. A Hessian records second-order directional behavior. To use it to determine whether a critical point is a local maximum or minimum requires additional results and conditions; the quadratic form alone should not be treated as a complete classification rule.

Why the Hessian Is Useful

The Hessian organizes all the second partial derivatives in one object, while its quadratic form tests how those derivatives combine in any chosen direction. This is useful because a surface may bend differently along different lines through the same point. The diagonal entries describe curvature along the coordinate directions, but the mixed entries affect directions between them.

For a reliable calculation, keep the point, matrix, and direction explicit: compute the second partial derivatives, evaluate them at the point, form the symmetric matrix, and then multiply by the direction vector on both sides. The resulting number is the second derivative along the line with that direction. Its sign describes curvature there, without claiming more than the calculation establishes.

Check Your Understanding

Use the definitions and calculations in this tutorial to answer the following questions.

  1. For a function with continuous second partial derivatives, what are the four entries of its Hessian at \((a,b)\)?
  2. Why does the mixed term in the quadratic form have coefficient \(2f_{xy}(a,b)\)?
  3. What does \(\mathbf{h}^{\top}\mathbf{H}_f(a,b)\mathbf{h}\) equal when interpreted along the line through \((a,b)\) in direction \(\mathbf{h}\)?
  4. What does it mean for a Hessian quadratic form to have mixed curvature?
  5. Why might checking only the coordinate directions fail to reveal mixed curvature?