Compute multinomial coefficients and natively iterate over multinomial expansions in Julia.
Author m-j-w
1 Star
Updated Last
2 Years Ago
Started In
January 2021


Iterate over multinomial series expansions and compute corresponding multinomial coefficients.

Status: In development, ready for public testing and comments.


Computing a power series or differentiation with respect to several variables in a convenient iteration scheme. Thus, an iterator is provided performing the expansion

Wikipedia Multinomial Theorem

and computing the multinomial coefficients

Wikipedia Multinomial Coefficients

The above equations are taken from the page Multinomial Theorem (Wikipedia) giving further explanation and applications.



Create an iterator over all expanded elements of the multinomial series. Returns a tuple of the requested dimension m. The iterator type MultinomialIterator provides length and element type information, see Base.length, Base.eltype, Base.IteratorSize and Base.IteratorEltype.


Compute the multinomial coefficient from a tuple k of integers, in the same way as the elements of the iterator eachmultinomial provides.


for k in eachmultinomial(3,3)
    @show k, multinomial(k)

# printed output
(k, multinomial(k)) = ((3, 0, 0), 1)
(k, multinomial(k)) = ((2, 1, 0), 3)
(k, multinomial(k)) = ((2, 0, 1), 3)
(k, multinomial(k)) = ((1, 2, 0), 3)
(k, multinomial(k)) = ((1, 1, 1), 6)
(k, multinomial(k)) = ((1, 0, 2), 3)
(k, multinomial(k)) = ((0, 3, 0), 1)
(k, multinomial(k)) = ((0, 2, 1), 3)
(k, multinomial(k)) = ((0, 1, 2), 3)
(k, multinomial(k)) = ((0, 0, 3), 1)


  1. Multinomial Theorem, Wikipedia
  2. Multinomial Series, Wolfram MathWorld
  3. Multinomial, Wolfram Mathematica Reference
  4. SymPy 'multinomial_coefficients' and SymPy 'multinomial_coefficients_iterator', SymPy Manual, Chapter Number Theory


Comments, feature requests and other contributions most welcome via the Github issue tracker or pull requests.

Required Packages

Used By Packages

No packages found.