### 13.7.3 Hessian matrix

Recall, the Hessian of a function F of n variables x1,…,xn is the matrix of second order derivatives:

⎡
⎢
⎢
⎢
⎢
⎢
⎢
⎢
⎢
⎣

∂2 F
∂x12

⋯

∂2 F
∂x1∂xn

⋮ | ⋮ | ⋮

∂2 F
∂xn∂x1

⋯

∂2 F
∂xn2

⎤
⎥
⎥
⎥
⎥
⎥
⎥
⎥
⎥
⎦

The hessian command computes the Hessian of a function.

- hessian takes two arguments:
  - expr, an expression involving several variables.
  - vars, a list of the variable names.
- hessian(expr,vars) returns the Hessian of the expression.

#### Examples

Find the Hessian matrix of F(x,y,z)=2x2y−xz3.

hessian(2*x^2*y-x*z^3,[x,y,z])

⎡
⎢
⎢
⎣

4 y | 4 x | −3 z2
2· 2 x | 0 | 0
−3 z2 | 0 | −2· 3 x z

⎤
⎥
⎥
⎦

To get the Hessian matrix at the critical points:

solve(derive(2*x^2*y-x*z^3,[x,y,z]),[x,y,z])

Output (the critical points):

| ⎡ ⎣ | ⎡ ⎣ | 0,y,0 | ⎤ ⎦ | ⎤ ⎦

Input to evaluate the Hessian at these points:

subst([[4*y,4*x,-3*z^2],[2*2*x,0,0],[-3*z^2,0,6*x*z]],[x,y,z],[0,y,0])

⎡
⎢
⎢
⎣

4 y | 0 | 0
0 | 0 | 0
0 | 0 | 0

⎤
⎥
⎥
⎦