# combinatorics: sum of product of integer compositions

I am trying to solve a problem from Stanley's book, it says:

Fix $$k,n \in \mathbb{P}$$. Show that: \begin{align} \sum a_1 a_2 \cdots a_k = \binom{n+k-1}{2k-1} \end{align} where the sum ranges over all compositions $$(a_1 , a_2 , \ldots , a_k)$$ of $$n$$ into $$k$$ parts.

I am trying to reason like this:

we need to find the coefficient $$c_n = \sum a_1 a_2 \cdots a_k$$ from this generating function --

\begin{align} \sum_n c_n x^n &= \sum_n \sum a_1 a_2 \cdots a_k x^n \\ &= \sum_n \sum a_1 a_2 \cdots a_k x^{a_1 + a_2 + \cdots + a_k}\\ &= \sum_n \sum a_1x^{a_1} a_2x^{a_2} \cdots a_kx^{a_k} \end{align}

after that, I have no clue, how do I solve this ?

moreover, what is the range in the inner sum ?

If we consider Mark Riedel's answer, and assume $$n=4$$, $$k=2$$; then the sum will be \begin{align} \sum (z + 2z^2)^2 = z^2 + 4z^3 + 4z^4 \end{align}

On the other hand the compositions will be $$(1,3), (2,2), (3,1)$$, therefore the above sum will be counted as:

\begin{align} (1.3)z^{1+3} + (2.2)z^{2+2} + (3.1)z^{3+1} &= 1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1\\ &= 3z^4 + 4z^4 + 3z^4 = 10z^4 \end{align}

what's going on? what am I missing?

Compositions of $$n$$ into $$k$$ parts can be represented as a string of $$n$$ stars and $$k-1$$ bars. The $$k-1$$ bars break the stars into $$k$$ groups, and the number of stars in the $$i^{th}$$ group represents $$a_i$$.

For each of these compositions, we are adding $$a_1a_2\dots a_k$$. This represents the number of ways to choose one star from each of the $$k$$ blocks, and color it red. For example, with $$n=6, k=3$$, and the composition $$\star\star|\star\star\star|\star$$, the number of ways to color one star in each group red like $$\star\color{red}\star|\star\color{red}\star\star|\color{red}\star$$ would be $$2\cdot 3\cdot 1$$.

However, there is a more direct way to count these arrangements of black stars, red stars, and bars. If you ignore the black stars, then what remains is an alternating pattern of red stars and bars; in the example, this is $$\color{red}\star|\color{red}\star|\color{red}\star$$. There are $$k+(k-1)=2k-1$$ symbols which are red stars or bars, and $$n+k-1$$ symbols total. Therefore, there are $$\binom{n+k-1}{2k-1}$$ arrangements, since an arrangement is specified by choosing which of the $$2k-1$$ symbols are red stars or bars, and then assigning these in an alternating fashion.

We have using generating functions the closed form

$$[z^n](z+2z^2+3z^3+\cdots)^k = [z^n] \frac{z^k}{(1-z)^{2k}} \\ = [z^{n-k}] \frac{1}{(1-z)^{2k}}.$$

Using the Newton binomial this becomes $${n-k+2k-1\choose 2k-1} = {n+k-1\choose 2k-1}.$$

• I do not understand at all, how does $(z + 2z^2 + \cdots)^k$ equate to $\sum a_1x^{a_1} a_2x^{a_2} \cdots$? could you please explain a little bit more ? Oct 19, 2016 at 22:31
• If you write down these $k$ sums say making a list then the product consists of choosing one term from the first sum one from the second and so on up to the $k$th term ... in doing so the exponent accumulates the sum and the coefficient the product of the parts. At the end extract the contributions where the parts sum to $n.$ Oct 19, 2016 at 22:37
• I see, let's try a concrete example, let's say $n = 4$ and $k=2$, then we will have these compositions $(1,3), (2,2), (3,1)$. So, in this case the sum will be $1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1$, but if I take $(z + 2z^2)(z + 2z^2)$, it is not equal to $1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1$, why ? by equal, I mean a similar polynomial form. Oct 19, 2016 at 22:44
• The generating function includes many more terms than what sums to $n.$ That's why we extract the coefficient on $[z^n]$ with the coefficient extraction operator. Oct 19, 2016 at 23:01
• so does it mean that $\sum_n z^2 + 4z^3 + 4z^4$ must be equal to $10z^4$ for some combination of $n$ such $z^2 + 4z^3 + 4z^4$ terms? Don't you think it's a bit far fetched? then how does $z^3$ term vanish? because all these terms supposed to be positive. Oct 19, 2016 at 23:15

This is a supplement to @MarkoRiedel's answer which should clarify OPs question. At first we look at the compositions of $n=4$ which consists of two terms ($k=2$) and look at the corresponding terms of the generating function.

When looking at the three compositions above, we see the first summand is either $1$ or $2$ while the second summand is either $3$ or $2$. In general the first summand is a positive integer encoded as generating function \begin{align*} (x^1+2x^2+3x^3+\cdots)=\sum_{n=1}^\infty n x^n=x\frac{d}{dx}\left(\frac{1}{1-x}\right)=\frac{x}{(1-x)^2} \end{align*} The same holds for all the other summands of a composition. Since we want to multiply the summands and $k=2$ we have to consider \begin{align*} (x^1+2x^2+3x^3+\cdots)^2=\frac{x^2}{(1-x)^4}\tag{1} \end{align*}

We use the coefficient of operator $[x^n]$ to denote the coefficient of $x^n$.

The number of compositions of $n=4$ is according to (1) \begin{align*} [x^4](x^1+2x^2+3x^3+\cdots)^2&=[x^4](x^1+2x^2+3x^3)^2\tag{2}\\ &=([x^3]+2[x^2]+3[x^1])(x^1+2x^2+3x^3)\tag{3}\\ &=3+2\cdot 2+3\\ &=\color{blue}{10} \end{align*}

Comment:

• In (2) we see it is sufficient to consider terms with exponents up to $3$, since higher exponents do not contribute to $x^4$.

• In (3) we use the linearity of the coefficient of operator and apply the rule $$[x^p]x^qA(x)=[x^{p-q}]A(x)$$

On the other hand we obtain with $n=4$ and $k=2$ \begin{align*} \binom{n+k-1}{2k-1}=\binom{5}{3}=\color{blue}{10} \end{align*}

• Thanks for helping to explain this to the OP. (+1). The problem at this MSE link required the use of complex residues. I wonder if it can be done using formal power series methods only (coefficient extraction operator). Oct 21, 2016 at 23:06