Open RossBoylan opened 8 years ago
The value for the second derivative of the second argument is not very accurate. The hessian in the above test computes a value of 8832.66, but the true value is 8833.06977. I'm not sure what degree of accuracy is reasonable to expect.
I added the following tests (not in the public commits)
# PR 91: Asymmetric Hessian
f6(x) = sin(x[1]^2+3x[2]^4)
h6 = Calculus.hessian(f6, [1.0, 2.0])
@test issym(h6)
g6(x) = [2x[1]*cos(3x[2]^4+x[1]^2), 12x[2]^3*cos(3x[2]^4+x[1]^2)]
h6b = Calculus.hessian(f6, g6, [1.0, 2.0])
@test issym(h6b)
h22 = 8833.06977
@test abs(h6[2,2] - h22) < 10e-4
@test abs(h6b[2,2] - h22) < 10e-4
@test maximum(abs(h6b-h6)) < 10e-4
which show asymmetric result if the gradient is defined, as well as precision failures for the [2,2] term of the hessian. BTW, the [2,2] term computed with the gradient appears correct.
91 partial fix. As noted in the last commit message, there are still quite a few ways to get an asymmetric Hessian.