# Solve for the coefficient of an even generating function

Using a generating function, find the number of ways to select 10 candies from a huge pile of red, blue, and green lollipops if the selection has an even number of blue lollipops.

I started, but I don't understand how to continue

$$(1 + x + x^2 + x^3 ...)^2 \cdot (1 + x^2 + x^4 + x^6 ...)$$

$$=(\frac{1}{1-x})^2 \cdot \frac{1}{1-x^2}$$

$$=\big(1 + \binom{1 + 2 - 1}{1}x + \binom{2 + 2 - 1}{2}x^2 ...\big) \cdot ???$$

How do you find coefficient to $$x^{10}$$?

Also, our textbook tells us $$(1 + x^2 + x^4 + x^6 ...)$$ = $$\frac{1}{1-x^2}$$ how?

## 2 Answers

Notice that $$\left(\frac{1}{1-x}\right)^2=\frac{d}{dx}\left(\frac{1}{1-x}\right)$$, and hence $$\left(\frac{1}{1-x}\right)^2=1+2x+3x^2+\dots$$ You can then find the $$x^{10}$$ coefficient just by multiplying out.

The equality stated in the textbooks holds for the same reason that $$1+x+x^2+\dots=\frac{1}{1-x}$$.

The original problem is $$(1 + x + x^2 + x^3 ...)^2 \cdot (1 + x^2 + x^4 + x^6 ...)$$

$$\frac{1}{1-x} = (1 + x + x^2 + x^3 ...)$$

Which can be shown by,

$$1 = (1 + x + x^2 + x^3 ...)(1-x)$$

$$1 = (1 + x + x^2 + x^3 ...) - x \cdot (1 + x + x^2 + x^3 ...)$$

$$1 =1$$

To show, $$\frac{1}{1-x^2} = (1 + x^2 + x^4 + x^6 ...)$$

we substitute $$y = x^2$$

$$\frac{1}{1-y} = (1 + y + y^2 + y^3 ...)$$ which is equivalent due to $$\frac{1}{1-x} = (1 + x + x^2 + x^3 ...)$$ shown above.

To solve the equation,

$$=(\frac{1}{1-x})^2 \cdot \frac{1}{1-x^2}$$

$$=\frac{1}{(1-x)^2} \cdot \frac{1}{1-x^2}$$

$$=\big(1 + \binom{1 + 2 - 1}{1}x + \binom{2 + 2 - 1}{2}x^2 ...\big) \cdot (1 + x^2 + x^4 + x^6 ...)$$

Thus the coefficient of $$x^{10}$$ is the coefficient of

$$=1 \cdot x^{10} + \binom{3}{1}x^2 \cdot x^{8} + \binom{5}{1}x^4 \cdot x^{6} + \binom{7}{1}x^6 \cdot x^{4} + \binom{9}{1}x^8 \cdot x^{2} + \binom{11}{1}x^{10} \cdot 1$$