4.4 Numerical Hessian function
Helptext:
numhessian(f, {args}, minarg)
Numeric second derivative of f with respect
to argument \"minarg\".
* first argument: function name (string)
* second argument: all arguments of the function (cell array)
* third argument: (optional) the argument to differentiate w.r.t.
(scalar, default=1)
If the argument
is a k-vector, the Hessian will be a kxk matrix
function a = f(x, y)
a = x'*x + log(y);
endfunction
numhessian(\"f\", {ones(2,1), 1})
ans =
2.0000e+00 -7.4507e-09
-7.4507e-09 2.0000e+00
Now, w.r.t. second argument:
numhessian(\"f\", {ones(2,1), 1}, 2)
ans = -1.0000