Repository navigation
Take a Catalan number through one quotient of factorials - #2349
Merged
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2349 +/- ##
=======================================
Coverage 86.79% 86.79%
=======================================
Files 312 312
Lines 68664 68675 +11
Branches 19987 19988 +1
=======================================
+ Hits 59595 59605 +10
- Misses 4902 4903 +1
Partials 4167 4167
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Two defects in numerical factorial quotients. Sweep 7's compilesweep found the first on
catalannumber(Ei(sinh(x)))at 6, and probing it turned up the second. No issues were filed.catalannumber(449.5)NaN2.4958e2662.4958e266catalannumber(500.5)NaN1.0774e2971.0774e297catalannumber(-60.3)NaN-8.3875e-40-8.3875e-40catalannumber(2000.5)NaN+oo1.66e1199, past the rangefallingfactorial(0.5, -100.5)09.4020e-1619.4020e-161risingfactorial(100.5, -60.5)02.1884e-1112.1884e-1114^n Γ(n + 1/2) / (√π Γ(n + 2))took each gamma in the context's exponent range. Both were+oofrom n = 449.5, so the quotient was NaN. The gammas are now oneQuotientOfFactorials, as the binomial's are since Divide a quotient of factorials before rounding it into the exponent range #2338. For a real n, 4^n times the quotient is formed in decimals with no bound on the exponent. An entity is not made from4^(1e20)itself: its exponent is near 6e19, and the downcasting's integer check throwsNotSupportedExceptionon it, which an earlier version of this branch did.QuotientOfFactorials(from Divide a quotient of factorials before rounding it into the exponent range #2338) made its result withReal.Create. That reads a value under the downcasting tolerance, 1e-50, as what a cancellation left, and rounds it onto zero. A quotient cancels nothing, so it is now made at a zero scale, as The derivative of an answer at a large hyperbolic argument evaluates to NaN or loses its imaginary part #1944 does for every product and quotient. So is the falling factorial over k! beside it. These were wrong answers: an exact 0 for a value that is not 0.Agreement with mpmath is to 1e-99 relative everywhere, except
catalannumber(1600.25)at 1.2e-96. There, 4^n multiplies the error of ln 4 by n ln 4 ≈ 2200, as it did on the old path.Tests:
ACatalanNumberPastTheExponentRangeTest, 9 cases against mpmath at 120 digits. 8 fail on master; the control,catalannumber(10.5), passes on both. The full suite, AOT and the nine harnesses pass. None ofcatalannumber,fallingfactorialorrisingfactorialis in 2.6.0, so there is no breaking entry.🤖 Generated with Claude Code