Skip to content

The Catalan numbers - #2198

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
the-catalan-numbers
Oct 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
the-catalan-numbers

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

catalannumber(n) was reserved in #2184. It is now a function. Part of #2182.

n value
whole, >= 0 binomial(2n, n) / (n + 1), exact up to n = 1000: 1, 1, 2, 5, 14, …
-1 -1/2, where the poles of the two gamma functions cancel
whole, <= -2 0, where 1/Γ(n + 2) vanishes
negative half-integer no value, at a pole of Γ(n + 1/2)
any other 4^n Γ(n + 1/2) / (√π Γ(n + 2)), evaluated numerically

These match Mathematica's CatalanNumber and SymPy's catalan. catalannumber(1/2) agrees with SymPy's 8/(3π) to 1e-25, and the tests check the recurrence C(n + 1) = Σ C(i) C(n − i). LaTeX output is \operatorname{C}_{n} and SymPy output is catalan.

Input Was (2.6.0) Now
"catalannumber(4)".ToEntity().Simplify() 4 * catalannumber 14
"catalannumber(-1)".ToEntity().Simplify() -catalannumber -1/2

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

catalannumber(n) was reserved by name in #2184 and is now Entity.CatalanNumberf, built by
MathS.CatalanNumber.

For a whole n >= 0 it is binomial(2n, n) / (n + 1), computed exactly up to n = 1000, so 1, 1, 2, 5,
14 from n = 0. Elsewhere it is 4^n Gamma(n + 1/2) / (sqrt(pi) Gamma(n + 2)), as Mathematica's
CatalanNumber and SymPy's catalan are. That is -1/2 at -1, where the poles of the two gammas
cancel, and 0 at every whole number below it, where the reciprocal of Gamma(n + 2) vanishes. A
negative half-integer, a pole of Gamma(n + 1/2), has no value, and any other number is evaluated
numerically: catalannumber(1/2) agrees with SymPy's 8/(3 pi) to 1e-25. The recurrence
C(n + 1) = sum of C(i) C(n - i) holds.

It prints as catalannumber(n), draws as \operatorname{C}_{n} and exports to SymPy's catalan.

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 97.77778% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.56%. Comparing base (2d109df) to head (3286b7d).

Files with missing lines Patch % Lines
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 89.47% 1 Missing and 1 partial ⚠️
.../Continuous/Entity.Continuous.Factorial.Classes.cs 80.00% 1 Missing ⚠️
Sources/AngouriMath/Functions/Substitute.cs 0.00% 0 Missing and 1 partial ⚠️
...AngouriMath/Functions/TreeAnalyzer/Sort.Classes.cs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2198   +/-   ##
=======================================
  Coverage   86.56%   86.56%           
=======================================
  Files         298      298           
  Lines       66493    66529   +36     
  Branches    19292    19300    +8     
=======================================
+ Hits        57557    57589   +32     
- Misses       4862     4865    +3     
- Partials     4074     4075    +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.12% <97.77%> (+<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.31% <100.00%> (+0.03%) ⬆️
Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs 99.21% <100.00%> (ø)
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 87.72% <100.00%> (+0.02%) ⬆️
Sources/AngouriMath/Core/Domains.Classes.cs 100.00% <100.00%> (ø)
...Math/Core/Transformations/Matching/MatchPattern.cs 86.08% <100.00%> (-0.19%) ⬇️
...nuous/Solvers/EquationSolver/InvertNode.Classes.cs 60.47% <100.00%> (+0.15%) ⬆️
...unctions/Output/Latex/Latex.Arithmetics.Classes.cs 97.67% <100.00%> (+0.01%) ⬆️
...ns/Output/ToString/ToString.Arithmetics.Classes.cs 100.00% <100.00%> (ø)
...ions/Output/ToSympy/ToSympy.Arithmetics.Classes.cs 76.19% <100.00%> (+0.38%) ⬆️
.../Continuous/Entity.Continuous.Factorial.Classes.cs 82.85% <80.00%> (-0.48%) ⬇️
... and 3 more

... and 5 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 c05a452 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-catalan-numbers branch October 29, 2026 11:04
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