Gradient and hessian matrix of $f(x,y,z) = xe^{\sin y} + xyz^2$

170 Views Asked by At

I want to find out the gradient and the Hessian Matrix of $f:\mathbb{R^3} \to \mathbb{R}$ with

$$f(x,y,z) = xe^{\sin y} + xyz^2$$

I do

$$f_x = \frac{\partial f(x,y,z)}{\partial x} = yz^2+e^{\sin y}$$ $$f_y = \frac{\partial f(x,y,z)}{\partial y} = xe^{\sin(y)} \cos(y)+xz^2$$ $$f_z = \frac{\partial f(x,y,z)}{\partial z} = 2xyz$$

The gradient is

$$\text{grad}(f) = \left(\begin{array}{c}yz^2+e^{\sin y}\\xe^{\sin(y)} \cos(y)+xz^2\\ 2xyz\end{array}\right)$$

For the Hessian Matrix I have read that it looks like this:

$$H_{f(x,y,z)}= \left(\begin{array}{c}f_{xx} & f_{xy} & f_{xz}\\f_{yx} & f_{yy} & f_{yz}\\f_{xz} & f_{zy} & f_{zz}\end{array}\right)$$

So, I get

$$H_{f(x,y,z)}= \left(\begin{array}{c}0 & e^{\sin(y)}\cos(y)+z^2 & 2yz\\z^2 + e^{\sin(y)}\cos(y) & xe^{\sin(y)}\cos^2(y)-xe^{\sin(y)}\sin(y) & 2xz \\2yz & 2xz & 2xy\end{array}\right)$$

Is this correct?