JuliaDiff / JuliaDiff/ForwardDiff.jl
StackOverflow when differentiating QuadGK Integral
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
When trying to differentiate the numerical integral from QuadGK (here integral of sin(x) for example), I get a stackoverflow error. Differentiating with Zygote works.
using ForwardDiff
using QuadGK
f(x) = quadgk(u->sin(u),0,x,rtol=1e-8)[1]
ForwardDiff.derivative(f,1)
ERROR: StackOverflowError:
Stacktrace:...
Expected value was sin(1) = 0.841471, which is the result I get when using f'(1) with Zygote.
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 reproducing the example using ForwardDiff.derivative, QuadGK.quadgk, and the function f shown in the issue, then inspect the resulting stack trace. Trace the interaction between ForwardDiff and QuadGK until the recursion is understood; done means the example returns sin(1) without a StackOverflowError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100