JuliaDiff / JuliaDiff/Diffractor.jl
Wrong derivative of exp(cos(x))
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 453
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Julia REPL reproduction in the issue with DiffractorForwardBackend and compare the derivative of exp(cos(x)) with the stated analytic value. Trace how cos is handled inside the composite derivative path, then verify that the result matches -1.4444065708474794 while the existing exp(sin(x)) behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100