# Finding the coefficient of $x^m$ in $(x+x^2+x^3+.....+x^i)^n$

EDIT:

My doubt may be silly but if the expansion of $(1-x)^{-n}$ is infinite, how come wolfram displayed 11 terms?

Wolfram result

Can anybody help to solve the whole equation?

I'm trying to solve this question.

I have an equation $(x+x^2+x^3+x^4+x^5+x^6)^2$ [ Taken 6-sided die x 2].

I want to find the coefficient of $x^5$.

I have reduced the equation to $x^2(1-x^6)^2(1-x)^{-2}$.

For $(1-x)^{-2}$,

$$(1-x)^{-2}=\sum_{k\ge0}(-1)^k\binom{-2}{k}x^k=\sum_{k\ge0}\binom{2+k-1}{k}x^k$$

I got -> $1+2x+3x^2$

For $(1-x^6)^2$

$$(1-x^6)^2=\sum_{k\ge0}(-1)^k\binom{2}{k}x^{6k}$$

I got -> $1-2x^6+x^{12}$

So my equation will be$$x^2(1+2x+3x^2)(1-2x^6+x^{12})$$

Am I correct till here? Because when I multiply all the terms I'm getting $$x^2+2x^3+3x^4-2x^8-4x^9-6x^{10}+x^{14}+2x^{15}+3x^{16}$$

Where am I going wrong?

• The expression for $(1-x)^{-2}$ will have infinitely many terms. It will be of the form $1+2x+\frac{(-2)(-3)}{2!}x^2-\frac{(-2)(-3)(-4)}{3!}x^3+\dotsb$ Jan 9, 2017 at 0:55
• @AnuragA So till where should I expand? Like if there are 20 dice and 20 sides? Like for $(1-x^6)^2$ we go till $n$ i.e., till $2$. Jan 9, 2017 at 1:45

$$\left(\sum_{i=1}^n a_i\right) ^2 = \sum_{i,j=1}^n a_i a_j$$ by distributive law, so with $a_i = x^i$ and $n=6$ you have $$\left(\sum_{i=1}^6 x^i\right) ^2 = \sum_{i,j=1}^6 x^{i+j}$$ and therefore $$(\mbox{coefficient of x^5}) = |\{(i,j) \in \{1,\ldots, 6\}:i+j=5\}|$$ You can count that by hand.
For a more general case, you just need to count the number of ways natural $m$ can be expressed as a sum of $k$ naturals, which is a well known problem with an easy recursion formula, see this other question or on wikipedia.
• @unknownymouse Counting the number of ways how natural $n$ can be summed by $k$ summands is a well known problem with an easy recursion. Have a look here: math.stackexchange.com/questions/217597/… Jan 9, 2017 at 9:51
• Since the coefficients for every $x^i$ is one, you can simply convolute the [1 1 1...1] vectors as often as wished to get the result. Jan 9, 2017 at 14:53