<s>[INST] Find the number of solutions in nonnegative integers of the equation $x_1+x_2+x_3+3x_4=7$. Find the number of solutions in nonnegative integers of the equation $x_1+x_2+x_3+3x_4=7$.
The term $3x_4$ will only be equal to $0,3$, and $6$. So $x_4\in\{0,1,2\}$. By letting $3x_4=0,3$, and $6$ we will have three cases and then by the addition principle we will get the result. So the number of solutions is ${9 \choose 2}+{6 \choose 2}+{3 \choose 2}$. Is this the correct method? Are there other or more slick ways of doing this?
 [/INST] Lets use generating functions for it such that :
$x_1 = \frac {1}{1-x}$ ,$x_2 = \frac {1}{1-x}$, $x_3 = \frac {1}{1-x}$ , $x_4 =\sum_{0}^{\infty} {x}^{3m}$
So , the result of multiplication is ${\frac {1}{1-x}}^3 \times x^{3m} = C(3+k-1,k)\times x^k \times x^{3m}$ ,because the coefficient of $x^{3m}$ is always $1$
We want to calculate the coefficient of $x^7$ , so we should find the values for $k,m$ , when $k+3m=7$
It is possible when $m=0,k=7$ or $m=1,k=4$ or $m=2,k=1$
So , $C(3+7-1,7)+C(3+4-1,4)+C(3+1-1,1)=54$
</s>