The Hessian of a scalar valued function f:Rn®R is the n×n matrix of second order partial derivatives of f. In MATLAB we can obtain the Hessian of f by computing the Jacobian of the Jacobian of f. Consider once again the function f(x,y)=(4x2-1)e-x2-y2.
>> syms x y real
>> Hf=jacobian(jacobian(f));
>> Hf=simple(Hf)
Hf =
[2*exp(-x^2-y^2)*(2*x+1)*(2*x-1)*(2*x^2-5), 4*x*y*exp(-x^2-y^2)*(-5+4*x^2)]
[4*x*y*exp(-x^2-y^2)*(-5+4*x^2), 2*exp(-x^2-y^2)*(-1+2*y^2)*(2*x+1)*(2*x-1)]