<s>[INST] Find closed formula $f(n)$ from generating function I'm asked to find a closed formula for
$f(n)=6f(n-1)-9f(n-2)$ for $n>1$ with $f(0)=-1. f(1)=0$,
using the ordinary generating function $F(X)$. 
I found $F(X)=-1/(1-3x)^2$ but from there I don't manage to get a satisfactory formula for $f(n)$. Can anyone give me a hint ?
Thanks
 [/INST] The reason you're not getting the closed form from your generating function is that the generating function is wrong. Let $F(x) = \sum_{n \ge 0} f(n) x^n$, then 
$$\begin{align} F(x) 
&= f(0) + f(1)x + \sum_{n \ge 2} f(n) x^n \\
&= f(0) + f(1)x + \sum_{n \ge 2} (6f(n-1) - 9f(n-2))x^n \\
&= f(0) + f(1)x + 6x\sum_{n \ge 2} f(n-1)x^{n-1} - 9x^2\sum_{n \ge 2}f(n-2)x^{n-2}\\
&= f(0) + f(1)x + 6x\sum_{n \ge 1}f(n)x^n - 9x^2\sum_{n \ge 0}f(n)x^n \\
&= f(0) + f(1)x + 6x(F(x) - f(0)) - 9x^2F(x)
\end{align}$$
so with $f(0) = -1$ and $f(1) = 0$, you get
$$F(x) = -1 + 6x(F(x) + 1) - 9x^2F(x)$$
$$(1 - 6x + 9x^2)F(x) = -1 + 6x$$
which gives
$$F(x) = \frac{-1 + 6x}{1- 6x + 9x^2} = \frac{-1+6x}{(1-3x)^2} = \frac{-1}{(1-3x)^2} + \frac{6x}{(1-3x)^2}$$
so
$$f(n) = -(n+1)3^n + 6n3^{n-1} = 3^n (-n - 1 + 2n) = 3^n(n - 1)$$
</s>