Given this inhomogeneous linear recurrence relation of 2nd order :
$F_n = F_{n-2} + a$ for $n \geq 2$
with $F_1 = 1$ and $F_0 = 0$
How do I find the generating function of this recurrence relation in dependence of the variable a? I tried solving it but the solution that I got ($\frac{x + a \cdot x^2}{1-x^2} + \frac{a}{1-x}$) doesn't seem to be right. I hope someone can help.
It’s easy enough to derive a closed form directly from the recurrences:
$$\begin{align*} F_{2n}&=an\\ F_{2n+1}&=an+1 \end{align*}$$
Thus,
$$\begin{align*} \sum_{n\ge 0}F_{2n+1}x^{2n+1}&=\sum_{n\ge 0}(an+1)x^{2n+1}\\ &=x\sum_{n\ge 0}anx^{2n}+\sum_{n\ge 0}x^{2n+1}\\ &=x\sum_{n\ge 0}F_{2n}x^{2n}+\frac{x}{1-x^2}\;, \end{align*}$$
so
$$\begin{align*} \sum_{n\ge 0}F_nx^n&=\sum_{n\ge 0}F_{2n}x^{2n}+\sum_{n\ge 0}F_{2n+1}x^{2n+1}\\ &=(1+x)\sum_{n\ge 0}anx^{2n}+\frac{x}{1-x^2}\\ &=a(1+x)\sum_{n\ge 0}nx^{2n}+\frac{x}{1-x^2}\\ &=\frac{a}2(1+x)x\sum_{n\ge 0}2nx^{2n-1}+\frac{x}{1-x^2}\\ &=\frac{a}2(1+x)x\frac{d}{dx}\left(\sum_{n\ge 0}x^{2n}\right)+\frac{x}{1-x^2}\\ &=\frac{a}2(1+x)x\frac{d}{dx}\left(\frac1{1-x^2}\right)+\frac{x}{1-x^2}\\ &=\frac{ax^2(1+x)}{(1-x^2)^2}+\frac{x}{1-x^2}\\ &=\frac{ax^2}{(1-x)(1-x^2)}+\frac{x}{1-x^2}\\ &=\frac{(a-1)x^2+x}{(1-x)(1-x^2)}\;. \end{align*}$$