Skip to content

The falling and the rising factorial - #2194

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
the-falling-and-rising-factorials
Oct 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
the-falling-and-rising-factorials

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

fallingfactorial(x, n) (also factorialpower, Mathematica's name) and risingfactorial(x, n) were reserved in #2184 and are now functions. Part of #2182.

order n falling, x^{\underline{n}} rising, x^{\overline{n}}
whole, >= 0 x (x - 1) ... (x - n + 1) x (x + 1) ... (x + n - 1)
whole, < 0 1 / ((x + 1) ... (x - n)) 1 / ((x - 1) ... (x + n))
any other Γ(x + 1) / Γ(x - n + 1), numerically Γ(x + n) / Γ(x), numerically

The whole orders follow Concrete Mathematics (2.52), and the other orders follow Mathematica's FactorialPower and Pochhammer. A pole of the numerator has no value, and a pole of the denominator gives 0. fallingfactorial(5, 1/2) agrees with mpmath to 1e-20. The tests also check risingfactorial(x, n) = fallingfactorial(x + n - 1, n) and binomial(n, k) = fallingfactorial(n, k) / k!.

LaTeX uses Knuth's bars, and SymPy output is ff and rf. A conjugate that is the whole exponent of a power is now drawn in brackets, x^{\left(\overline{n}\right)}, so it cannot be read as a rising factorial. pochhammer stays refused.

Input Was (2.6.0) Now
"fallingfactorial(5, 2)".ToEntity().Simplify() throws UnhandledParseException 20
"risingfactorial(3, 2)".ToEntity().Simplify() throws UnhandledParseException 12
"fallingfactorial(5, 1/2)".ToEntity().EvalNumerical() throws UnhandledParseException 2.29257989505120015013822761269...

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

fallingfactorial(x, n), also factorialpower(x, n), Mathematica's name, and risingfactorial(x, n)
were reserved by name in #2184 and are now Entity.FallingFactorialf and Entity.RisingFactorialf,
built by MathS.FallingFactorial and MathS.RisingFactorial.

For a whole n >= 0 they are x (x - 1) ... (x - n + 1) and x (x + 1) ... (x + n - 1), x to the n
falling and rising, computed exactly for any number x. For a negative whole n they are the
reciprocals of (x + 1) ... (x - n) and (x - 1) ... (x + n), (2.52) in Graham, Knuth and
Patashnik's Concrete Mathematics, with no value where a factor vanishes. For any other n they are
Gamma(x + 1)/Gamma(x - n + 1) and Gamma(x + n)/Gamma(x), as Mathematica's FactorialPower and
Pochhammer are, evaluated numerically: no value at a pole of the numerator, and 0 at one of the
denominator. fallingfactorial(5, 1/2) agrees with mpmath to 1e-20. risingfactorial(x, n) is
fallingfactorial(x + n - 1, n), and binomial(n, k) is fallingfactorial(n, k)/k!.

They draw with Knuth's bars, x^{\underline{n}} and x^{\overline{n}}, and export to SymPy's ff and
rf. A conjugate as the whole exponent of a power is drawn in brackets,
x^{\left(\overline{n}\right)}, since x^{\overline{n}} is the rising factorial. pochhammer stays
refused, (x)_n being the rising factorial to some authors and the falling one to others.

Part of #2182.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.64033% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.55%. Comparing base (e7b7fd0) to head (85940fe).

Files with missing lines Patch % Lines
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 82.22% 5 Missing and 3 partials ⚠️
.../Continuous/Entity.Continuous.Factorial.Classes.cs 66.66% 4 Missing ⚠️
...nuous/Solvers/EquationSolver/InvertNode.Classes.cs 0.00% 2 Missing ⚠️
...AngouriMath/Functions/TreeAnalyzer/Sort.Classes.cs 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2194   +/-   ##
=======================================
  Coverage   86.54%   86.55%           
=======================================
  Files         297      297           
  Lines       66349    66431   +82     
  Branches    19273    19289   +16     
=======================================
+ Hits        57425    57498   +73     
- Misses       4854     4861    +7     
- Partials     4070     4072    +2     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.11% <95.64%> (+<0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Convenience/MathS.cs 90.28% <100.00%> (+0.06%) ⬆️
Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs 99.21% <100.00%> (-0.01%) ⬇️
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 87.66% <100.00%> (+0.08%) ⬆️
Sources/AngouriMath/Core/Domains.Classes.cs 100.00% <100.00%> (ø)
...Math/Core/Transformations/Matching/MatchPattern.cs 86.27% <100.00%> (+0.06%) ⬆️
...unctions/Output/Latex/Latex.Arithmetics.Classes.cs 97.65% <100.00%> (+0.07%) ⬆️
...ns/Output/ToString/ToString.Arithmetics.Classes.cs 100.00% <100.00%> (ø)
...ions/Output/ToSympy/ToSympy.Arithmetics.Classes.cs 75.80% <100.00%> (+0.80%) ⬆️
Sources/AngouriMath/Functions/Substitute.cs 83.23% <100.00%> (+0.20%) ⬆️
...nuous/Solvers/EquationSolver/InvertNode.Classes.cs 60.31% <0.00%> (-0.49%) ⬇️
... and 3 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit ea08214 into master Oct 29, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 29, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the the-falling-and-rising-factorials branch October 29, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant