Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Derivative for Integration Limits Broken #34

Closed
wesselb opened this issue Aug 28, 2020 · 2 comments
Closed

Derivative for Integration Limits Broken #34

wesselb opened this issue Aug 28, 2020 · 2 comments

Comments

@wesselb
Copy link

wesselb commented Aug 28, 2020

Derivatives for the integration limits appear to be broken. For example, consider

julia> g(z) = solve(QuadratureProblem((x, p) -> exp(p * x), -Inf, z[1], z[2]), QuadGKJL(), reltol=1e-4).u
g (generic function with 1 method)

julia> g([1.5, 2.0])
10.042768453453952

julia> FiniteDifferences.grad(central_fdm(5, 1), g, [1.5, 2.0])[1]
2-element Array{Float64,1}:
 20.085536906907155
 10.042768652810555

Then

julia> Zygote.gradient(g, [1.5, 2.0])
ERROR: MethodError: no method matching getindex(::Float64, ::Tuple{})
Closest candidates are:
  getindex(::Number) at number.jl:75
  getindex(::Number, ::Integer) at number.jl:77
  getindex(::Number, ::Integer...) at number.jl:82
  ...
Stacktrace:
 [1] getindex(::DiffEqBase.QuadratureSolution{Float64,0,Float64,Float64,QuadratureProblem{false,Float64,var"#15#16",Float64,Float64,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}},QuadGKJL,Nothing}) at /Users/wessel/.julia/packages/DiffEqBase/V7P18/src/solutions/solution_interface.jl:5
 [2] _broadcast_getindex at ./broadcast.jl:578 [inlined]

and

julia> ForwardDiff.gradient(g, [1.5, 2.0])
ERROR: StackOverflowError:
Stacktrace:
 [1] cachedrule(::Type{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,2}}, ::Int64) at /Users/wessel/.julia/packages/QuadGK/zzx9s/src/gausskronrod.jl:249 (repeats 79984 times)

Removing the dependence on the integration limit makes the error go away for ForwardDiff:

julia> g(z) = solve(QuadratureProblem((x, p) -> exp(p * x), -Inf, 1.5, z[2]), QuadGKJL(), reltol=1e-4).u
g (generic function with 1 method)

julia> FiniteDifferences.grad(central_fdm(5, 1), g, [1.5, 2.0])[1]
2-element Array{Float64,1}:
  0.0
 10.042768652810555

julia> ForwardDiff.gradient(g, [1.5, 2.0])
2-element Array{Float64,1}:
  0.0
 10.04276865281165

Zygote.gradient still breaks, unfortunately.

@ChrisRackauckas
Copy link
Member

Same as #28 . They aren't implemented.

@ChrisRackauckas
Copy link
Member

Closing as a duplicate of #28 . Follow that issue to stay up to date.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants