How many integer solutions are there to $$\begin{aligned} x_{1}+x_{2}+x_{3}=n \end{aligned}$$ where $x_{1}\ge 0$ and is even, $x_{2}\ge 0$ , and $0\le x_{3}\le 2$ .
I don't think this problem can be easily solved by inclusion-exclusion, so I tried to use generating function. By the restriction, the generating function should be $$\begin{aligned} &(1+x^2+x^4+\cdots )(1+x+x^2+x^3+\cdots )(1+x+x^2) \\ =& \frac{ 1}{1-x^2} \cdot \frac{ 1}{1-x} \cdot \frac{ 1-x^3}{1-x} \end{aligned}$$ Then I want to expand this so I can determine the coefficient in front of $x^n$, which is the number of integer solutions. However, I got stuck here. Any help or other method to approach this? Thanks.
You got the generating function $$ f(x)=\frac{ 1}{1-x^2} \cdot \frac{ 1}{1-x} \cdot \frac{ 1-x^3}{1-x}=\frac{x^2+x+1}{(x-1)^2(x+1)}. $$ From here the standard step is to use partial fractions decomposition. This way you would find $$ f(x)=\frac{1}{4}\frac{1}{1+x}+\frac{3}{2}\frac{1}{(1-x)^2}-\frac{3}{4}\frac{1}{1-x}. $$ Then we expand the individual summands using mainly geometric series sum and $\frac{1}{(1-x)^2}=\frac{d}{dx}(\frac{1}{1-x})$, hence we have $$ f(x)=\frac{1}{4}\sum_{n \geq 0} (-x)^n+\frac{3}{2}\sum_{n \geq 0} nx^{n-1}-\frac{3}{4}\sum_{n \geq 0} x^n. $$ Removing the term for $n=0$ for the middle sum and shifting the index we therefore arrive to $$ f(x)=\sum_{n \geq 0} \left[\frac{1}{4}(-1)^n+\frac{3}{2}(n+1)-\frac{3}{4}\right]x^n. $$ So the resulting formula is after some clean up $$ \frac{(-1)^n+6n+3}{4}. $$ I let you fill in the details which are mostly just algebraic manipulations (you can find very similar questions on the topic on this site as well, for example Using partial fractions to find explicit formulae for coefficients?).