Method on @sym: hessian (f)
Method on @sym: hessian (f, x)

Symbolic Hessian matrix of symbolic scalar expression.

The Hessian of a scalar expression f is the matrix consisting of second derivatives:

syms f(x, y, z)
hessian(f)
  ⇒ (sym 3×3 matrix)
    ⎡   2                  2                  2             ⎤
    ⎢  ∂                  ∂                  ∂              ⎥
    ⎢ ───(f(x, y, z))   ─────(f(x, y, z))  ─────(f(x, y, z))⎥
    ⎢   2               ∂y ∂x              ∂z ∂x            ⎥
    ⎢ ∂x                                                    ⎥
    ⎢                                                       ⎥
    ⎢   2                  2                  2             ⎥
    ⎢  ∂                  ∂                  ∂              ⎥
    ⎢─────(f(x, y, z))   ───(f(x, y, z))   ─────(f(x, y, z))⎥
    ⎢∂y ∂x                 2               ∂z ∂y            ⎥
    ⎢                    ∂y                                 ⎥
    ⎢                                                       ⎥
    ⎢   2                  2                  2             ⎥
    ⎢  ∂                  ∂                  ∂              ⎥
    ⎢─────(f(x, y, z))  ─────(f(x, y, z))   ───(f(x, y, z)) ⎥
    ⎢∂z ∂x              ∂z ∂y                 2             ⎥
    ⎣                                       ∂z              ⎦

x can be a scalar, vector or cell list. If omitted, it is determined using symvar.

Example:

f = x*y;
hessian(f)
  ⇒ (sym 2×2 matrix)
      ⎡0  1⎤
      ⎢    ⎥
      ⎣1  0⎦

See also: @sym/jacobian, @sym/divergence, @sym/gradient, @sym/curl, @sym/laplacian.

Package: symbolic