Giter VIP home page Giter VIP logo

Comments (9)

stevengj avatar stevengj commented on August 29, 2024 1

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.

from quadgk.jl.

stevengj avatar stevengj commented on August 29, 2024

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.)

from quadgk.jl.

MasonProtter avatar MasonProtter commented on August 29, 2024

@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.

from quadgk.jl.

stevengj avatar stevengj commented on August 29, 2024

Also shows up for dimensionful quantities (#17).

from quadgk.jl.

stevengj avatar stevengj commented on August 29, 2024

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.

from quadgk.jl.

pdeffebach avatar pdeffebach commented on August 29, 2024

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?

from quadgk.jl.

pdeffebach avatar pdeffebach commented on August 29, 2024

Leibniz integral rule strikes again! Yes I will port over the Quadrature, thanks for the feedback.

from quadgk.jl.

Moelf avatar Moelf commented on August 29, 2024

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

from quadgk.jl.

stevengj avatar stevengj commented on August 29, 2024

The original StackOverflowError error is gone, I'm going to close this issue.

It now gives the error:

ERROR: MethodError: no method matching kronrod(::Type{ForwardDiff.Dual{ForwardDiff.Tag{var"#3#5", Int64}, Float64, 1}}, ::Int64)
Closest candidates are:
  kronrod(::Type{T}, ::Integer) where T<:AbstractFloat at ~/.julia/dev/QuadGK/src/gausskronrod.jl:150

which stems from this line. I think it could be fixed if one(Dual) returned 1 instead of a dual number, which seems better to me, but in any case it seems like a separate issue (JuliaDiff/ForwardDiff.jl#624).

from quadgk.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.