-
Notifications
You must be signed in to change notification settings - Fork 89
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
add derivatives for exponential integrals #292
Comments
If I understand @gxyd this is blocked by SpecialFunctions not having defined a |
@oxinabox, that is only if you want derivatives with respect to order. For now, I would treat it like the Bessel functions, where you can only differentiate with respect to the second argument and not with respect to the order at the moment. |
Oh, we should not be doing that, that is not good. |
The perfect seems like the enemy of the good here? There are lots of applications for differentiating with respect to the argument alone, so it is useful to be able to do that automatically even if you can't handle differentiating the order. For both Bessel functions and exponential integrals, in most applications the order will be a constant (usually an integer), not something that you would consider continuous perturbations of. (Though it's theoretically possible to differentiate both Bessel functions and exponential integrals with respect to the order, and useful in rare applications, these both require special functions that are not currently implemented efficiently in any finite-precision open-source code that I'm aware of.) |
For reference: Here's the For exponential integral: https://www.wolframalpha.com/input/?i=diff%28expint%28nu%2C+z%29%2C+nu%29 (here
Agreed. |
We might want to document the meaning of |
We also do this for ChainRules.jl/src/rulesets/LinearAlgebra/factorization.jl Lines 28 to 29 in 2eb203f
I in general also don't think we should do this except in cases where no current Julia AD can AD through the function. Then there's no harm in writing a rule that ignores a differential that will be almost never used, as long as we can throw a sensible error should someone try. And of course we can always remove the rule if some future AD can handle the primal function. My two cents. |
We also shouldn't be doning that for SVD, there is a (long standing) issue open about that. #106
I agree with this. If so we we should do (kind of like SVD does) |
Or you could even have a predefined |
Nice think about Thunks are cheap to create I hope, they live in the stack. |
There was something similar #28 sometime back, though probably not exactly same. |
Related issue: #208 |
Should be transferred to SpecialFunctions (#319). |
Note that Zygote seems to be capable of accurately differentiating our Differentiation with respect to julia> using Zygote, SpecialFunctions, BenchmarkTools
julia> f(x) = expint(3,x)
julia> fp(x) = -expint(2,x) # analytical derivative
julia> f'(3.7)
-0.004566575240288366
julia> fp(3.7)
-0.00456657524028863
julia> @btime f'(3.7);
825.321 μs (5983 allocations: 173.81 KiB)
julia> @btime fp(3.7);
118.380 ns (0 allocations: 0 bytes)
julia> g(ν) = expint(ν,4.2)
julia> g'(4) # matches high-order finite-difference result to 12 digits
-0.0002319482036089421 It would be nice if there were some way to declare a chain rule for only one of the arguments, and let Zygote handle the other one if needed. |
I wonder if we could solve this with #68 if we can do that without triggering an infinite loop. |
Can anyone transfer this to SpecialFunctions.jl? We are deleting the special functions rules in the next breaking release |
It is not possible to transfer issues between orgs. |
Just added to SpecialFunctions.jl: JuliaMath/SpecialFunctions.jl#236
The derivative with respect to
x
is a simple recurrence: https://en.wikipedia.org/wiki/Exponential_integral#DerivativesThe text was updated successfully, but these errors were encountered: