When the function is twice differentiable and one knows how to compute its first and second differentials, still more efficient algorithms can be used (in our case, a variant of Levenberg-Marquardt). The option "d2f" allows to specify a function that returns the value of the function, the first and second differentials of the minimized function. Entering the commands :
c = foo(x);
dc = diffoo(x);
d2c = diag (cos (x(:)-1) + 2/9);
end
[x,v,n] = minimize ("foo", x0, "d2f", "d2foo")
1.0000 1.0000 1.0000
v = -3
n =
34 5