Repository navigation
Divide a quotient of factorials before rounding it into the exponent range - #2338
Merged
Rafael-SOWNet merged 1 commit intoNov 3, 2026
Merged
Conversation
…range A binomial, falling or rising factorial of an order that is not whole is a quotient of factorials, and each factorial was rounded into the evaluation's context, whose exponent ends at 1e1000. Past n of about 450 the numerator overflowed and binomial(450.5, 3.25) was +oo; a little further both did, and binomial(2500.5, 3.25) was NaN, where it is 13324626798.14. They are now taken at the caller's precision with no bound on the exponent and divided before the quotient is rounded. Real arguments stay decimals throughout: as complex numbers, every product added a zero imaginary part to a number whose exponent was in the millions, and binomial(10^7, 1.43) took over 20 s. A whole n was computed as an exact factorial, so binomial(479001600, 1.43) built a number of four billion digits and did not stop when cancelled; a decimal factorial is now exact only within the cached factorials, and Spouge's approximation takes the rest, as it took everything past an int32. It is 2042181498707.57 in 83 ms. A whole k with a decimal n was the falling factorial over k!, which overflowed the same way: binomial(pi, 2000) was NaN, where it is 2.1e-14. It is now built as binomial(n, i) one factor at a time. Every value in the test is mpmath's at 50 digits. Found by compilesweep, whose seed 13 stopped on binomial((2x)!, W(x)) at x = 6; no issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2338 +/- ##
==========================================
- Coverage 86.77% 86.76% -0.02%
==========================================
Files 312 312
Lines 68563 68598 +35
Branches 19950 19962 +12
==========================================
+ Hits 59498 59519 +21
- Misses 4905 4914 +9
- Partials 4160 4165 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
a-quotient-of-factorials-past-the-exponent-range
branch
November 3, 2026 03:11
Rafael-SOWNet
added a commit
that referenced
this pull request
Nov 3, 2026
A Catalan number of a number that is not whole is 4^n Γ(n + 1/2) over √π Γ(n + 2), and each gamma was computed in the evaluation's exponent range. From n = 449.5, whose number is 2.5e266, both were +oo and the quotient NaN, and catalannumber(-60.3), -8.4e-40, was NaN as well. The two gammas are now one QuotientOfFactorials, as the binomial's are since #2338, and for a real n the 4^n times it is formed in decimals with no bound on the exponent and rounded at the end: a number made of 4^(1e20) itself has an exponent near 6e19, which the downcasting cannot read as an integer. Found by compilesweep, on catalannumber(Ei(sinh(x))) at 6. And QuotientOfFactorials made its result as any number, which reads a value under the downcasting tolerance as a cancellation's residual and rounds it onto zero. A quotient cancels nothing: fallingfactorial(0.5, -100.5), 9.4e-161, was 0, and risingfactorial(100.5, -60.5), 2.2e-111, was 0. The quotient, and the falling factorial over k! beside it, are now made at a zero scale. None of the three functions is in 2.6.0, so there is no breaking entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A binomial, falling or rising factorial of an order that is not whole is a quotient of factorials, and each factorial was rounded into the evaluation's exponent range (it ends at
1e1000) before the quotient was taken.binomial(450.5, 3.25)+oo+oo50428864.5080...50428864.5080...binomial(2500.5, 3.25)NaNNaN13324626798.1423...13324626798.1423...binomial(10000, 1.43)NaN414189.539...414189.539...binomial(479001600, 1.43)2042181498707.571..., 83 ms2042181498707.571...binomial(pi, 2000)NaNNaN2.10439...E-142.10439...E-14fallingfactorial(10000, 1.43)NaN524791.324...524791.324...binomial(10^7, 1.43)take over 20 s.kwith a decimalnis built asbinomial(n, i)one factor at a time, not as the falling factorial overk!.Found by compilesweep, whose seed 13 stopped on
binomial((2x)!, lambertw(0, x))atx = 6. No issue was filed. The suite (18743), the five test projects and the eight harnesses pass, with 0 warnings. A BREAKING-CHANGES entry is included.🤖 Generated with Claude Code