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$


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?

  • 1
    $\begingroup$ 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$ $\endgroup$
    – Anurag A
    Jan 9, 2017 at 0:55
  • $\begingroup$ @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$. $\endgroup$ Jan 9, 2017 at 1:45

2 Answers 2


$$\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.

  • $\begingroup$ But it gets difficult when both dice and sides are increased. Like sides are 6 and dice are 10. First I also tried your solution and wrote code. But it is highly time consuming. $\endgroup$ Jan 9, 2017 at 1:41
  • $\begingroup$ @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/… $\endgroup$
    – Ayutac
    Jan 9, 2017 at 9:51
  • $\begingroup$ 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. $\endgroup$
    – Laray
    Jan 9, 2017 at 14:53

This GitHub repository solved my problem.

  • $\begingroup$ @Ayutac 5 more min $\endgroup$ Jan 11, 2017 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .