Open rzyu45 opened 9 months ago
This is probably fixed by #481, as master gives the right answer:
julia> H([1,0]) ≈ H([1,1e-10])
true
(jl_JRlWH7) pkg> st ForwardDiff
Status `/private/var/folders/yq/4p2zwd614y59gszh7y9ypyhh0000gn/T/jl_JRlWH7/Project.toml`
[f6369f11] ForwardDiff v0.11.0-DEV `https://github.com/JuliaDiff/ForwardDiff.jl.git#master`
(#481 was pulled from v0.10 as it seemed that some people relied on the old behaviour, and we haven't tagged v0.11 yet... because making a breaking release of such a widely used package creates a lot of work downstream, and people have ideas for other things they would quite like to roll into a breaking 1.0 release.)
I was trying to calculate the Hessian of a simple function such as
At point
[1,0]
, the above codes produce the wrong Hessian. However, if I set very small perturbation toVθ
, then the results are correct.It is found to be more robust to use
cos.(θ)+im .*sin.(θ)
, which functioned correctly at point[1,0]
, instead ofexp.(im .*θ)
. I think the problem has something in common with #653.The difference between
cos.(θ)+im .*sin.(θ)
andexp.(im .*θ)
is printed as followsIt is clear that the above Dual is not all zero.
The dependencies are
ForwardDiff v0.10.36
andJulia V1.9.3
.