Please have a look at the following test function:
function X=hesstest3()
% Definition of the manifold
Man = euclideanfactory(1,1);
problem.M = Man;
% Define the problem cost function
problem.cost = @cost;
function f = cost(t)
f=(t-2)^2*exp(t);
end
% Define the problem gradient and Hessian
problem.egrad = @egrad;
function g = egrad(t)
g=exp(t)*(-2+t)*t;
end
problem.ehess = @ehess;
function h=ehess(t,s)
h=exp(t)*(-2+t^2)*s^2;
end
% Check numerically whether gradient is correct
% checkgradient(problem);
checkhessian(problem);
% Solve
X = steepestdescent(problem,3.01);
end
Running this function, it SOMETIMES produces an error like
<d1, H[d2]> - <H[d1], d2> should be zero, or very close.
Value: -0.880626 - 0.880626 = -1.76125.
If I did everything correctly, this should not happen ...