-
Notifications
You must be signed in to change notification settings - Fork 100
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 differentiation rules from ChainRules #238
Conversation
BTW I'm not sure what's the best way to avoid rule redefinition for users with old versions of ChainRules since it does neither depend on nor bound SpecialFunctions. |
On the ChainRules side we can check for: |
-1 from me. Integrating things like this should be in a separate package, not in a core package this far down the dependency tree of so many other packages. |
Not a maintainer here, but it looks a bit weird also to me if such functionality was here, since this isn't needed for |
Its no different to TimeZones.jl having a dependency on RecipieBase. Which I know @ararslan would also disagree with, and I think it is a legit enough disagreement. |
A lightweight dependency on ChainRulesCore seems fine to me — that's what it's for, and I expect that more and more packages will be adding this dependency in the future. |
Codecov Report
@@ Coverage Diff @@
## master #238 +/- ##
=======================================
Coverage 87.68% 87.68%
=======================================
Files 11 11
Lines 2526 2526
=======================================
Hits 2215 2215
Misses 311 311
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
To elaborate — going forward, I expect that more and more there will be an expectation that basic numerical functions will be differentiable, and the easiest place to do that is in the packages themselves. Putting the derivatives in a separate package just makes it harder to keep in sync, while eliminating a dependency on ChainRulesCore that most users will have anyway. |
9cb40d2
to
7c306c4
Compare
Looks good to merge? |
Currently, ChainRules defines a set of differentiation rules for functions from SpecialFunctions. As noted in the README and mentioned in this discussion, ideally these rules would be defined in SpecialFunctions. This PR adds these rules that are currently defined in ChainRules together with their corresponding tests to SpecialFunctions, with the following modifications:
lgamma
is removed and the one forlbeta
replaced with one forlogbeta
sincelgamma
andlbeta
are deprecatedbeta
andlogbeta
are addedI'm not sure if the maintainers of SpecialFunctions are willing to take a dependency on ChainRulesCore (it is designed as a lightweight interface for AD with LinearAlgebra and MuladdMacro as its only dependencies) and include these differentiation rules in their code base. This PR is motivated by an issue about potentially defining derivatives of Bessel functions with respect to the order as well that I opened a while ago in the ChainRules repo. In this issue, it was suggested to first move the code base to SpecialFunctions before modifying or extending the existing set of rules.