MultinomialSeries.jl

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

MultinomialSeries

Iterate over multinomial series expansions and compute corresponding multinomial coefficients.

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

Motivation

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.

Methods

eachmultinomial(m,n)

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.

multinomial(k)

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

Example

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

# 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)

References

  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

Contributions

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

Used By Packages

No packages found.