<s>[INST] Finding the number of solutions to an equation under bounds of $x$ I need to find the number of solutions to this  equation under the following circumstances.
$$x_1 + x_2 + x_3 = 20$$ where $x_1, x_2, x_3 \in \Bbb Z$ and $1\le x_1 \le 4$,  $ 2\le x_2 \le 10$ and $3\le x_3 \le 12$
I'm not 100% sure how to do it but have completed this (i'm not sure if it's anywhere close to being correct):
Attempted Solution

Total # possible solutions of $x_1 + x_2 + x_3 = 20$ is ${22 \choose 20} = 231$
 Rearranging the initial equation/s:
i) $x_1 \le 4$ and $x_1 \ge 2$
ii) $x_2 \le 10$ and $x_2 \ge 3$
iii) $x_3 \le 12$ and $x_3 \ge 4$
Find (i) for "$\le$"
$${(20 - 4) + 3 - 1 \choose (20 - 4)} $$
$${16 + 3 -1 \choose 16}$$
$${18 \choose 16} = 153 $$(solutions that have $x_1 \ge 5$).
Therefore the # solutions where $x_1 \le 4$ $$= 231 - 153$$
$$ = 78$$
This is repeated for the $x_2$ and $x_3$ to get 165 and 186 respectively.

Now to find for "$\ge$":
Same process as above except not "$-$ing" this number away from 231. 
This gives,
i) ${20 \choose 18} = 190$ 
ii) ${19 \choose 17} = 171$ 
iii) ${18 \choose 16} = 153$ 
 Then to find the total number of solutions for each equation(i,ii,iii) I take the first number calculated away from the second.
i) $190 - 78 = 112$
ii) $171 - 165 = 6$
iii) $153 - 186 = -33$ 
Then to find the total number of solutions for the whole initial equation: 
$$ sol = 231 - 112 - 6 - (-)33 $$
$$ sol = 146 $$
Is this correct? If not, where am I going wrong?
 [/INST] What you have to find is just:
$$\begin{eqnarray*}&&[x^{20}](x+x^2+x^3+x^4)(x^2+\ldots+x^{10})(x^3+\ldots+x^{12})\\&=&[x^{14}](1+\ldots+x^3)(1+\ldots+x^8)(1+\ldots+x^9)\\&=&[x^{14}]\frac{(1-x^4)(1-x^9)(1-x^{10})}{(1-x)^3}\\&=&[x^{14}](1-x^4-x^9-x^{10}+x^{13}+x^{14})\sum_{j=0}^{+\infty}\binom{j+2}{2}x^j\\&=&\binom{16}{2}-\binom{12}{2}-\binom{7}{2}-\binom{6}{2}+\binom{3}{2}+1\\&=&\color{red}{22}.\end{eqnarray*}$$
As an alternative approach, you can check that we have $4$ solutions with $x_1=1$, $5$ solutions with $x_1=2$, $6$ solutions with $x_1=3$ and $6$ solutions with $x_1=4$, and:
$$ 4+5+6+7 = \color{red}{22}.$$
</s>