-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stack overflow for integrating other Number types #13
Comments
Thanks for the report. The quadgk endpoints only support real and complex numbers right now, and probably there is an infinite loop in the promotion rules for other number types. It would be good to make this work, if only to make sure the methods are defined generically enough to work with any number type. (But even if we get this working, I’m guessing that using the analytical derivative “manually” will always be much more efficient.) |
@stevengj Yeah, I wasn't expecting this to work but I decided to give it a try anyways and ended up segfaulting due to the stack overflow so it was suggested I submit an issue. |
Also shows up for dimensionful quantities (#17). |
The case of dimensionful quantities is fixed by #36. I'm not sure how to fix this in general — the problem is that I need a package-independent way to get the underlying real-numeric types out of things like Measurement and Dual numbers, and there doesn't seem to be an API for this right now. |
I also encountered this error. I have a non-linear problem trying to find zeros. I have a working solution in NLSolve but needed additional constraints, so I turned to JuMP. Is there a solution for Dual numbers that exists now? |
If you want the derivative with respect to the endpoints of a function that involves integration, you can just take the derivative analytically and expose it to automatic differentiation via the ChainRules package. The https://github.com/SciML/Quadrature.jl package (which wraps around QuadGK) does this for you. |
Leibniz integral rule strikes again! Yes I will port over the Quadrature, thanks for the feedback. |
SciML actually doesn't work: julia> f(z) = solve(IntegralProblem((x, _)->sin(x)^2, 0.0, z), QuadGKJL())[1]
f (generic function with 2 methods)
julia> f(3.14)
1.5707963254482846
julia> ForwardDiff.derivative(f, 3.14)
ERROR: StackOverflowError:
Stacktrace:
[1] cachedrule(#unused#::Type{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 1}}, n::Int64) (repeats 79984 times)
@ QuadGK ~/.julia/packages/QuadGK/ENhXl/src/gausskronrod.jl:253 |
The original StackOverflowError error is gone, I'm going to close this issue. It now gives the error:
which stems from this line. I think it could be fixed if |
I have a function if I have a function
f(x)
which is the integral another function (using QuadGK) andx
is the upper limit of integration. If I want to take an automatic derivative of that function using ForwardDiff, it results in a stack overflow. Here are instructions to reproduce the errorThe text was updated successfully, but these errors were encountered: