<s>[INST] How many non-negative solutions for $x_{1} + x_{2} + x_{3} + x_{4} = 40$ where $2 \leq x_{1} \leq 8, x_{2} \leq 4, x_{3} \geq 4, x_{4} \leq 5$? My solution:
We have:
$x_{1} + x_{2} + x_{3} + x_{4} = 40$ where $2 \leq x_{1} \leq 8, x_{2} \leq 4, x_{3} \geq 4, x_{4} \leq 5$
$\Leftrightarrow  x_{2} + x_{3} + x_{4} = 40 - x_{1} \quad (*)$
Consider:
$x_{2} + x_{3} + x_{4} = 40 - x_{1}$ where $x_{2} \geq 0, x_{3} \geq 4, x_{4} \geq 0 \quad (**)$
$x_{2} + x_{3} + x_{4} = 40 - x_{1}$ where $x_{2} \geq 5, x_{3} \geq 4, x_{4} \geq 6 \quad (***)$
Let $f$ is the function that compute the number of non-negative solutions of an equation.
$\implies f(*) = f(**) - f(***)$ 
Thus, the number of non-negative solutions of (*) is $\sum_{x_{1} = 2}^{8}( {40 - x_{1} + 3 - 1  \choose 3 - 1} - {25-x_{1}+3 - 1 \choose 3 - 1}) = 3045$
I found that the right answer is 210 by trying some programming script. But I don't know what was wrong with my solution. Please help me. Thank you!
 [/INST] It's the coefficient of $x^{40}$ of the product polynomial
$$(x^2+x^3+x^4 +x^5 + x^6 + x^7 + x^8)(1+x^1+x^2+x^3 +x^4)(x^4 + x^5 + \ldots)(1+x^1+x^2+x^3 +x^4 + x^5)$$
Or equivalently the coefficient of $x^{34}$ of
$$(1+x+x^2+x^3+x^4 +x^5 + x^6 )(1+x^1+x^2+x^3 +x^4)(1 + x + x^2 + \ldots)(1+x^1+x^2+x^3 +x^4 + x^5)$$
which can be found using (generalised) binomials etc.
</s>