<s>[INST] generating function: how many possibilities are there to throw 10 different dice so that their sum is 25 My discrete math textbook has the following solution to the problem using generating functions (the solution has to use generating functions):
$$f(x)=(x+x^2+x^3+x^4+x^5+x^6)^{10}$$
Once we start developing the formal power series we get the following:
$$x^{10}(1-x^6)^{10}\frac{1}{(1-x)^{10}}$$
Because of $x^{10}$ we now need to find the coefficient of only $x^{15}$:
$$\binom{10}{0}\binom{10-1+15}{15}-\binom{10}{1}\binom{10-1+9}{9}+\binom{10}{2}\binom{10-1+3}{3}$$
I completely understand the first two expressions but why are we using the third one:
$$\binom{10}{2}\binom{10-1+3}{3}$$
Where does the $3$ come from and why this isn't enough:
$$\binom{10}{0}\binom{10-1+15}{15}-\binom{10}{1}\binom{10-1+9}{9}$$
?
 [/INST] The coefficient of $x^{25}$ in $(x+x^2+\ldots+x^6)^{10}$ equals the coefficient of $x^{15}$ in 
$$ (1+x+\ldots+x^5)^{10} = (1-x^6)^{10}\cdot\frac{1}{(1-x)^{10}} $$
so the answer is given by
$$ [x^{15}] \left(\sum_{k=0}^{10}\binom{10}{k}(-1)^k x^{6k}\right)\cdot\left(\sum_{j\geq 0}\binom{9+j}{j}x^j\right) $$
and it is enough to consider just the terms associated with $k=0,1,2$, since $x^{6k}$ has an exponent greater than $15$ for any $k>2$. By computing the Cauchy product between the above series it follows that the answer is given by:
$$ \underbrace{\binom{10}{0}\binom{24}{15}}_{k=0,\;j=15}-\underbrace{\binom{10}{1}\binom{18}{9}}_{k=1,\;j=9}+\underbrace{\binom{10}{2}\binom{12}{3}}_{k=2,\;j=3}.$$
</s>