Generating function for the solutions of equation $ 2x_1 + 4x_2 = n$

As you observed, if the generating function for $h_n$ is $$f(x) = h_0 + h_1x + h_2x^2 + h_3x^3 + \dots + h_nx^n + \dots,$$ then $$f(x) = (1 + x^2 + x^4 + x^6 + \dots)(1 + x^4 + x^8 + x^{12} + \dots) = \frac{1}{1-x^2}\frac{1}{1-x^4}$$

To actually get the coefficients of $x^n$ in the above, we resort to partial fractions. The denominator of the above can be factored into irreducible factors, using the identity $1-y^2 = (1+y)(1-y)$, as $(1+x)(1-x)(1+x^2)(1+x)(1-x) = (1+x)^2(1-x)^2(1+x^2)$. Therefore, by the general theory of partial fractions, $f(x)$ can be written as $$f(x) = \frac{A}{1+x\vphantom{(1+x)^2}} + \frac{B}{(1+x)^2} + \frac{C}{1-x\vphantom{(1-x)^2}} + \frac{D}{(1-x)^2} + \frac{Ex + F}{1+x^2} + \frac{Gx + H}{(1+x^2)^2}$$ where $A, B, C, D, E, F, G, H$ are constants. Using various painful tricks it's possible to determine the constants, but because I'm not the one doing this as homework, I'll just turn to Wolfram Alpha which says that $$f(x) = \frac{1}{4(1+x)} + \frac{1}{8(1+x)^2} + \frac{1}{4(1-x)} + \frac{1}{8(1-x)^2} + \frac{1}{4(1+x^2)}.$$

Here the five terms are, respectively, $\frac14 \sum_n{(-1)^n x^n}$ and $\frac18 \sum_n {(-1)^n (n+1)x^n}$ and $\frac14 \sum_n x^n$ and $\frac18 \sum_n (n+1)x^n$ and $\frac14 \sum_n{(-1)^n x^{2n}}$, so $$h_{2000} = \frac14 (-1)^{2000} + \frac18 (-1)^{2000}2001 + \frac14 + \frac18 2001 + \frac14 (-1)^{1000} = 501.$$

[That's the answer, but as you can see the whole thing is a quite painful process that I wouldn't wish on my worst enemy, which is why I keep saying that generating functions are not the best way to solve these counting problems, despite the dazzle of the first step where you get some cute expression for the generating function.]


Edit: Just for contrast, the solution without generating functions: Clearly $n$ must be even, so we're counting solutions to $x + 2y = n/2$ in the nonnegative integers. From $0 \le 2y \le n/2$ we have $0 \le y \le \left\lfloor \frac{n/2}{2} \right\rfloor$, and for each such $y$ there is a unique $x = n/2 - 2y$ as solution. So the number of solutions (for even $n$) is $1 + \left\lfloor \frac{n/2}{2} \right\rfloor$, which for $n = 2000$ is $1 + \left\lfloor \frac{1000}{2} \right\rfloor = 501$.

The solution without generating functions is not always this simple, but I think this is a good example of how going down the generating functions route can be a bad idea if you want exact numbers (as opposed to asymptotic estimates, say).


So assuming your generating function is correct we can see that: $$\frac{1}{1-x^2}=\sum_{n=0}^\infty a_nx^n,\ a_n = \text{ 1 if 2 divides $n$, 0 otherwise}$$

$$\frac{1}{1-x^4}=\sum_{n=0}^\infty b_nx^n,\ b_n = \text{ 1 if 4 divides $n$, 0 otherwise}$$

So we can use this to calculate the product:

$$\frac{1}{1-x^2}\cdot \frac{1}{1-x^4}=\sum_{n=0}^\infty c_nx^n$$

Where $c_n=\sum_{k=0}^n a_kb_{n-k}$, we can see $a_kb_{n-k} = $ 1 if 2 divides $k$ and 4 divides $n-k$, 0 otherwise. We can see that for odd $n$ this always evaluates to 0 (sanity check: this makes sense!), and for even $n$ we have 1 only when $n-k$ is divisible by 4. So for even $c_n$ is simply the number of $0\leq k\leq n$ such that $n-k$ is divisible by 4. With a little bit of thought we can see that this is $\lfloor \frac n 4 \rfloor +1$.

So putting in $n=2000$ gives us 501!


let us think n as following variables

$n=6$

only one solution $x_1=1$ and $x_2=1$

$n=8$

again one solution

$x_1=2$ and $x_2=1$

$n=10$

now we have following solutions

$x_1=3$ and $x_2=1$,second pair would be $x_1=1$ and $x_2=2$

now take $n=12$

$x_1=4$ and $x_2=1$ $x_1=2$ and $x_2=2$ so sequences is for this case $1, 1, 2, 2$ i am not sure that there is any clear relationship,let check again

let us add two more case

$n=14$ solutions are

$x_1=3$ and $x_2=2$ and $x_1=1$ and $x_2=3$ and $x_1=5$ and $x_2=1$,so there is three solution.now we get

$1,1,2,2,3$

let take $n=16$

we have following pairs

1)$x_1=2$ and $x_2=3$

2)$x_1=4$ and $x_2=2$

3) $x_1=6$ and $x_2=1$

so i think that for more and more even numbers,it increases by 1(number of solution) and
keeps it for the next even number too,like it for example increases number of solution by $1$ for $n=22$ for exmaple and also it keeps this amount for $n=24$