Hessian Matrices Examples 1
Hessian Matrices Examples 1
Recall from the Hessian Matrices page that the Hessian matrix of an $n$ variable real-valued function $z = f(x_1, x_2, ..., x_n) = f (\mathbf{x})$ (where $\mathbf{x} = (x_1, x_2, ..., x_n)$) whose second partial derivatives exist is the defined as the following $n \times n$ matrix of second partial derivatives:
(1)
\begin{align} \mathcal H (\mathbf{x}) = \begin{bmatrix} f_{11} (\mathbf{x}) & f_{12} (\mathbf{x}) & \cdots & f_{1n} (\mathbf{x})\\ f_{21} (\mathbf{x}) & f_{22} (\mathbf{x}) & \cdots & f_{2n} (\mathbf{x})\\ \vdots & \vdots & \ddots & \vdots \\ f_{n1} (\mathbf{x}) & f_{n2} (\mathbf{x}) & \cdots & f_{nn} (\mathbf{x}) \end{bmatrix} \end{align}
We will see the importance of Hessian matrices in finding local extrema of functions of more than two variables soon, but we will first look at some examples of computing Hessian matrices.
Example 1
Find the Hessian matrix of the function $f(x, y, z) = x^2 + y^2 + z^2$.
It should intuitively be clear that the second partial derivatives of $f$ will be continuous on all of $\mathbb{R}^3$, and by Clairaut's Theorem on the equality of mixed second partial derivatives, we will have that our Hessian matrix is symmetrix about the main diagonal and as a result, we will not need to compute all nine second partial derivatives directly.
We first compute the three first partial derivatives of $f$:
(2)
\begin{align} \quad \frac{\partial f}{\partial x} = 2x \\ \quad \frac{\partial f}{\partial y} = 2y \\ \quad \frac{\partial f}{\partial z} = 2z \end{align}
We will now compute the necessary second partial derivatives of $f$:
(3)
\begin{align} \quad \frac{\partial^2 f}{\partial x^2} = 2 \\ \quad \frac{\partial^2 f}{\partial y^2} = 2 \\ \quad \frac{\partial^2 f}{\partial z^2} = 2 \\ \quad \frac{\partial^2 f}{\partial y \partial x} = \frac{\partial^2 f}{\partial x \partial y} = 0 \\ \quad \frac{\partial^2 f}{\partial z \partial x} = \frac{\partial^2 f}{\partial x \partial z} = 0 \\ \quad \frac{\partial^2 f}{\partial z \partial y} = \frac{\partial^2 f}{\partial y \partial z}= 0 \end{align}
Therefore we have that:
(4)
\begin{align} \quad \mathcal H (x, y, z) = \begin{bmatrix} 2 & 0 & 0\\ 0 & 2 & 0\\ 0 & 0 & 2 \end{bmatrix} \end{align}
Example 2
Find the Hessian matrix of the function $f(x, y, z) = \sin (xyz)$.
Once again, it should be intuitively clear that the second partial derivatives of $f$ will be continuous on all of $\mathbb{R}^3$, so Clairaut's theorem applies once again.
We begin by computing the first partial derivatives of $f$:
(5)
\begin{align} \quad \frac{\partial f}{\partial x} = yz \cos (xyz) \\ \quad \frac{\partial f}{\partial y} = xz \cos (xyz) \\ \quad \frac{\partial f}{\partial z} = xy \cos (xyz) \end{align}
We now compute the second partial derivatives of $f$:
(6)
\begin{align} \quad \frac{\partial^2 f}{\partial x^2} = -y^2z^2 \sin (xyz) \\ \quad \frac{\partial^2 f}{\partial y^2} = -x^2z^2 \sin (xyz) \\ \quad \frac{\partial^2 f}{\partial z^2} = -x^2y^2 \sin (xyz) \\ \quad \frac{\partial^2 f}{\partial y \partial x} = \frac{\partial^2 f}{\partial x \partial y} = -xyz^2 \sin (xyz) + z\cos (xyz) \\ \quad \frac{\partial^2 f}{\partial z \partial x} = \frac{\partial^2 f}{\partial z \partial x} = -xy^2z\sin(xyz) + y\cos (xyz) \\ \quad \frac{\partial^2 f}{\partial z \partial y} = \frac{\partial^2 f}{\partial y \partial z} = -x^2yz \sin (xyz) + x \cos (xyz) \end{align}
Therefore the Hessian matrix of $f$ is:
(7)
\begin{align} \quad \mathcal H(x, y, z) = \begin{bmatrix} -y^2z^2 \sin (xyz) & -xyz^2 \sin (xyz) + z\cos (xyz) & -xy^2z\sin(xyz) + y\cos (xyz)\\ -xyz^2 \sin (xyz) + z\cos (xyz) & -x^2z^2 \sin (xyz) & -x^2yz \sin (xyz) + x \cos (xyz)\\ -xy^2z\sin(xyz) + y\cos (xyz) & -x^2yz \sin (xyz) + x \cos (xyz) & -x^2y^2 \sin (xyz) \end{bmatrix} \end{align}