Repository navigation
The double factorial is the postfix n!! - #2187
Merged
Rafael-SOWNet merged 1 commit intoOct 28, 2026
Merged
Rafael-SOWNet merged 1 commit into
Rafael-SOWNet merged 1 commit into
Conversation
Mathematics writes the double factorial n!!, as it writes the factorial n!, and 5!! was a parse error. It is Entity.DoubleFactorialf, MathS.DoubleFactorial, written n!! and exported as SymPy's factorial2: the product of the positive integers up to n with its parity, 0!! and (-1)!! being the empty product 1, and below them n!! = (n + 2)!!/(n + 2), so (-3)!! is -1 and (-5)!! is 1/3. A negative even integer has none, and nothing off the integers has one: the extension through the gamma function gives 0!! = sqrt(2/pi), so no extension is the double factorial's. (n!)! keeps its parentheses. Three marks are the triple factorial in the literature, which the library does not have, so n!!! is refused rather than read as (n!!)!. The refusals of doublefactorial and factorial2 now point to n!!, and the native smoke test evaluates one. Part of #2182. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2187 +/- ##
==========================================
- Coverage 86.53% 86.51% -0.03%
==========================================
Files 297 297
Lines 66096 66161 +65
Branches 19227 19237 +10
==========================================
+ Hits 57199 57240 +41
- Misses 4834 4854 +20
- Partials 4063 4067 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Oct 28, 2026
Rafael-SOWNet
added a commit
that referenced
this pull request
Oct 28, 2026
The Kernel Benchmark gate failed twice today on unchanged library code: on #2187's first run, and on #2188 after its rebase. Both times it was SimplifyEasy, SolveEasy and EvalTrigPrecise, at 3-12x their time, and SimplifyEasy at 3% more allocation. Their re-runs matched the baseline to the byte. BenchmarkDotNet times one call before it decides how to measure, and where that call takes more than two thirds of its 500 ms iteration, it times one call per iteration from then on. The first call of those three took 349-362 ms on the failing runs and 252-300 ms on the passing ones. For a call of tens of microseconds, one call per iteration is another measurement. That first call paid for parsing every static expression of the class and for the library's own set-up: EvalEasy, a cache lookup, took 133 ms the first time on one machine. A [GlobalSetup] now touches the class and runs one simplification, one solve and one evaluation before the timed call. Measured on one machine, master against this, the first call drops from 172 to 8 ms (SimplifyEasy), 164 to 5 ms (SolveEasy) and 158 to 45 ms (EvalTrigPrecise). What the gated benchmarks allocate is unchanged: SimplifyEasy is 79,682 B/op on both, and the largest move is ParseEasy's +0.11% (21 B/op). The two compilation benchmarks, which the gate leaves out for their own spread, moved -0.5% and +2.0%. SolveHard, a call of 70 ms, is now timed one call per iteration rather than piloted, and allocates 9,832,912 B/op against 9,831,370. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
deleted the
the-double-factorial-is-the-postfix-double-exclamation-mark
branch
October 29, 2026 00:26
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.
On #2182 Happypig375 pointed out that a
doublefactorialfunction is dubious "when the factorial is the postfix!operator and we likely want the postfix!!". So the double factorial is the postfixn!!, as Wikipedia, MathWorld and Mathematica write it.5!!was a parse error, so nothing changes meaning. The node isEntity.DoubleFactorialf, and alsoMathS.DoubleFactorial. It exports as SymPy'sfactorial2.What it is, as Wikipedia defines it:
nwith its parity:7!!is105, and8!!is384;0!!and(-1)!!are the empty product,1;n!! = (n + 2)!!/(n + 2), so(-3)!!is-1and(-5)!!is1/3;0!! = sqrt(2/pi), not1, so no extension is the double factorial's.n! = n!! (n - 1)!!is a test. An integer argument past 10000 keeps the node, as a huge whole power does (#1448).The spellings around it
(n!)!keeps its parentheses.n!!!is the triple factorial in the literature, which the library does not have. So it is refused, rather than read as(n!!)!, with a message that says how to write the factorial of a double factorial.doublefactorialandfactorial2now point ton!!.7!!, simplifiedUnhandledParseException105(-5)!!, simplifiedUnhandledParseException1/3n!!UnhandledParseExceptionn!!n!!!UnhandledParseExceptionUnrecognizedFunctionParseExceptionMeasured
FromStringTest.TestFormula21, which assertedx!!is a parse error; it now asserts the double factorial.x!!case.Part of #2182.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura