Skip to content

The multinomial coefficient - #2197

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
the-multinomial-coefficient
Oct 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
the-multinomial-coefficient

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

multinomial(k_1, ..., k_m) was reserved in #2184. It is now (k_1 + ... + k_m)! / (k_1! ... k_m!), written that way at parse time, as agreed on #2182. Part of #2182.

Off the whole numbers the factorial is the gamma function. So the coefficient is symmetric in its arguments everywhere, and has no value where an argument or their sum is a negative integer.

It is not the product of binomials the multinomial theorem factors it into. That product depends on the argument order where binomial is 0, at a negative whole lower index: multinomial(-3, 1) would be -2 and multinomial(1, -3) would be 0.

Input Was (2.6.0) Now
"multinomial(2, 3, 4)".ToEntity().Simplify() throws UnhandledParseException 1260
"multinomial(1/2, 1/2)".ToEntity().Simplify() throws UnhandledParseException 4 / pi
"multinomial(n)".ToEntity() multinomial * n n! / n!

multinomial(1/2, 1/3) agrees with mpmath to 1e-25.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

multinomial(k_1, ..., k_m) was reserved by name in #2184. It is now (k_1 + ... + k_m)! /
(k_1! ... k_m!), written so when it is parsed, as Happypig375 agreed on #2182.

The factorial is the gamma function off the whole numbers, so the coefficient is symmetric in its
arguments everywhere, and it has no value where an argument or their sum is a negative integer,
a pole of the gamma function. multinomial(2, 3, 4) is 1260, multinomial(1/2, 1/2) is 4 / pi, and
multinomial(1/2, 1/3) agrees with mpmath to 1e-25.

It is not built as the product of binomial coefficients the multinomial theorem factors it into.
binomial is 0 at a negative whole lower index, and that product depends on the order of the
arguments there: multinomial(-3, 1) would be -2 and multinomial(1, -3) would be 0.

Part of #2182.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.54%. Comparing base (1e2daa0) to head (0ae687e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2197      +/-   ##
==========================================
- Coverage   86.56%   86.54%   -0.02%     
==========================================
  Files         298      298              
  Lines       66489    66493       +4     
  Branches    19292    19292              
==========================================
- Hits        57553    57547       -6     
- Misses       4862     4872      +10     
  Partials     4074     4074              
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.10% <100.00%> (-0.02%) ⬇️
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/Core/Antlr/AngouriMathLexer.cs 99.21% <100.00%> (+<0.01%) ⬆️
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 87.69% <100.00%> (+0.02%) ⬆️
Sources/AngouriMath/Core/Antlr/ParsingHelpers.cs 93.18% <100.00%> (+0.24%) ⬆️

... and 10 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 2d109df 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-multinomial-coefficient branch October 29, 2026 10:07
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