JuliaDiff/Diffractor.jl

Wrong derivative of exp(cos(x))

Opened this issue · 0 comments

It seems to me that there is a problem with cos derivatives in composite functions:

julia> D = (f, x) -> AbstractDifferentiation.derivative(DiffractorForwardBackend(), f, x)[1];

julia> D(x -> exp(cos(x)), 1.0)
-1.952024889228184

julia> exp(cos(1.0)) * (-sin(1.0))
-1.4444065708474794

julia> exp(sin(1.0)) * (-sin(1.0))
-1.952024889228184

Surprisingly, everything is OK with sin derivatives:

julia> D(x -> exp(sin(x)), 1.0)
1.253380767493447

julia> exp(sin(1.0)) * cos(1.0)
1.253380767493447