Repository navigation
Avoid overflow in gamma_inc derivatives - #862
vera-rubin wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #862 +/- ##
==========================================
+ Coverage 91.23% 91.25% +0.02%
==========================================
Files 11 11
Lines 1072 1075 +3
==========================================
+ Hits 978 981 +3
Misses 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for spotting the overflow and for the PR! Unfortunately, computing the derivative in log space suffers from cancellation in the exponent for large SpecialFunctions already computes I'd suggest continuing in #871, which also includes a fallback for older SpecialFunctions versions. |
If the closed form of the derivative of `gamma_inc` overflows, compute it in log space instead (as proposed in #862). Co-Authored-By: Nathan Chandrasekar <322284620+vera-rubin@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Differentiating
gamma_inc(a, x, 0)with respect toxata = x = 150.0or200.0returnsInforNaN:The documented normalization and derivative identity give finite derivatives of about
0.03255540946and0.02819772769, respectively.We evaluate the derivative in log space using
loggammato avoid overflowing intermediate values while retaining the power rule at zero for higher derivatives.The new regression tests and the existing dual-number tests pass.
Tested versions: ForwardDiff 1.4.6, Julia 1.10.12, SpecialFunctions 2.9.0.
— ChipLab