# 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

and computing the 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

- Multinomial Theorem, Wikipedia
- Multinomial Series, Wolfram MathWorld
- Multinomial, Wolfram Mathematica Reference
- 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.