On this post we explain what the Hessian matrix is and how to calculate it (with examples). Also, you will find several solved exercises so that you can practice. In addition, you will see all the applications of the Hessian matrix. And finally, we will show you what the bordered Hessian matrix is.
Table of Contents
What is the Hessian matrix?
The definition of the Hessian matrix is as follows:
The Hessian matrix, or simply Hessian, is an n×n square matrix composed of the second-order partial derivatives of a function of n variables.
The Hessian matrix was named after Ludwig Otto Hesse, a 19th century German mathematician who made very important contributions to the field of linear algebra.
Thus, the formula for the Hessian matrix is as follows:
Therefore, the Hessian matrix will always be a square matrix whose dimension will be equal to the number of variables of the function. For example, if the function has 3 variables, the Hessian matrix will be a 3×3 dimension matrix.
Furthermore, the Schwarz’s theorem (or Clairaut’s theorem) states that the order of differentiation does not matter, that is, first partially differentiate with respect to the variable and then with respect to the variable is the same as first partially differentiating with respect to and then with respect to
In other words, the Hessian matrix is a symmetric matrix.
Thus, the Hessian matrix is the matrix with the second-order partial derivatives of a function. On the other hand, the matrix with the first-order partial derivatives of a function is the Jacobian matrix.
Hessian matrix example
Once we have seen how to calculate the Hessian matrix, let’s see an example to fully understand the concept:
- Calculate the Hessian matrix at the point (1,0) of the following multivariable function:
First of all, we have to compute the first order partial derivatives of the function:
Once we know the first derivatives, we calculate all the second order partial derivatives of the function:
Now we can find the Hessian matrix using the formula for 2×2 matrices:
So the Hessian matrix evaluated at the point (1,0) is:
Practice problems on finding the Hessian matrix
Problem 1
Find the Hessian matrix of the following 2 variable function at the point (1,1):
First we compute the first-order partial derivatives of the function:
Then we calculate all the second-order partial derivatives of the funciton:
So the Hessian matrix is defined as follows:
Finally, we evaluate the Hessian matrix at the point (1,1):
Problem 2
Calculate the Hessian matrix at the point (1,1) of the following function with two variables:
First we differentiate the function with respect to x and with respect to y:
Once we have the first derivatives, we calculate the second-order partial derivatives of the function:
So the Hessian matrix of the function is a square matrix of order 2:
And we evaluate the Hessian matrix at the point (1,1):
Problem 3
Compute the Hessian matrix at the point (0,1,π) of the following 3 variable function:
To compute the Hessian matrix first we have to calculate the first-order partial derivatives of the function:
Once we have computed the first derivatives, we calculate the second-order partial derivatives of the function:
So the Hessian matrix of the function is a square matrix of order 3:
And finally, we substitute the variables for their respective values at the point (0,1,π):
Problem 4
Determine the Hessian matrix at the point (2, -1, 1, -1) of the following function with 4 variables:
The first step is to find the first-order partial derivatives of the function:
Now we solve the second-order partial derivatives of the function:
So the expression of the 4×4 Hessian matrix obtained by solving all the partial derivatives is the following:
And finally, we substitute the unknowns for their respective values of the point (2, -1, 1, -1) and perform the calculations:
Applications of the Hessian matrix
You may be wondering… what is the Hessian matrix for? Well, the Hessian matrix has several applications in mathematics. Next, we will see what the Hessian matrix is used for.
Minimum, maximum or saddle point
If the gradient of a function is zero at some point, that is f(x)=0, then function f has a critical point at x. In this regard, we can determine whether that critical point is a local minimum, a local maximum or a saddle point using the Hessian matrix:
- If the Hessian matrix is positive definite (all the eigenvalues of the Hessian matrix are positive), the critical point is a local minimum of the function.
- If the Hessian matrix is negative definite (all the eigenvalues of the Hessian matrix are negative), the critical point is a local maximum of the function.
- If the Hessian matrix is indefinite (the Hessian matrix has positive and negative eigenvalues), the critical point is a saddle point.
Note that if an eigenvalue of the Hessian matrix is 0, we cannot know whether the critical point is a extremum or a saddle point.
Convexity or concavity
Another utility of the Hessian matrix is to know whether a function is concave or convex. And this can be determined applying the following theorem.
Let be an open set and a function whose second derivatives are continuous, its concavity or convexity is defined by the Hessian matrix:
- Function f is convex on set A if, and only if, its Hessian matrix is positive semidefinite at all points on the set.
- Function f is strictly convex on set A if, and only if, its Hessian matrix is positive definite at all points on the set.
- Function f is concave on set A if, and only if, its Hessian matrix is negative semi-definite at all points on the set.
- Function f is strictly concave on set A if, and only if, its Hessian matrix is negative definite at all points on the set.
Taylor polynomial
The expansion of the Taylor polynomial for functions of 2 or more variables at the point begins as follows:
As you can see, the second order terms of the Taylor expansion are given by the Hessian matrix evaluated at point This application of the Hessian matrix is very useful in large optimization problems.
Bordered Hessian matrix
Another use of the Hessian matrix is to calculate the minimum and maximum of a multivariate function restricted to another function To solve this problem, we use the bordered Hessian matrix, which is calculated applying the following steps:
Step 1: Calculate the Lagrange function, which is defined by the following expression:
Step 2: Find the critical points of the Lagrange function. To do this, we calculate the gradient of the Lagrange function, set the equations equal to 0, and solve the equations.
Step 3: For each point found, calculate the bordered Hessian matrix, which is defined by the following formula:
Step 4: Determine for each critical point whether it is a maximum or a minimum:
- The critical point will be a local maximum of function under the restrictions of function if the last n-m (where n is the number of variables and m the number of constraints) major minors of the bordered Hessian matrix evaluated at the critical point have alternating signs starting with the negative sign.
- The critical point will be a local minimum of function under the restrictions of function if the last n-m (where n is the number of variables and m the number of constraints) major minors of the bordered Hessian matrix evaluated at the critical point all have negative signs.
Note that the local minimums or maximums of a restricted function do not have to be that of the unrestricted function. So the bordered Hessian matrix only works for this type of problems.