Generating functions and closed form solution for fibonacci sequence Doing some extra practice problems and am having a hard time with this concept. Thanks!

 A: The main thing with the Fibonnacci sequence is that recurrence relation, so let's analyze:
If
$$f(x)=\sum_{n=0}^\infty F_nx^n$$
with $F_n$ the nth Fibonnacci number, then since $F_{n+2}=F_{n}+F_{n+1}$ if we multiply the series by $x$ and $x^2$ we get:
$$x^2f(x)=\sum_{n=0}^\infty F_{n}x^{n+2}=\sum_{n=2}^\infty F_{n-2}x^n$$
$$xf(x)=\sum_{n=0}^\infty F_{n}x^{n+1}=\sum_{n=1}^\infty F_{n-1}x^n=\sum_{n=2}^\infty F_{n-1}x^n$$
the last equality since $F_0=0$.
Adding these together gives:

$$xf(x)+x^2f(x)=\sum_{n=2}^\infty (F_{n-2}+F_{n-1})x^n=f(x)-x\tag{$*$}$$

again we are using that $F_0=0$.
Hence by equating the far left of $(*)$ with the far right, we get
$$f(x)(x^2+x-1)=-x$$ and so

$$f(x)={x\over 1-x-x^2}$$


A commentary on the idea:  notice that the polynomial in the denominator is $1-x-x^2$ this is supposed to reflect the recurrence relation. think of it as $1-(x+x^2)$ to indicate that one term is the sum of the previous term and the term two prior, the $x$ powers act as indices so that multiplying by the power lowers the index after switching back to $x^n$. The $x$ in the numerator is just to indicate the first term is $0$, any multiplication of a power series by a power, $x^k$, just shifts the whole sequence so that it starts with $k$ zeroes and then proceeds according to the original sequence.
