<s>[INST] Generating functions ( recurrence relations ) Find $a_n$ using Generating Functions : $a_n = -a_{n-1} + 2a_{n−2}$, $n\ge2$ and $a_0 = 1$, $a_1 = 2$.
Approach : So I will form a characteristic equation $ r^2 + r - 2 = 0$ whose roots are $r_1 = -2$, $r_2 = 1$.
So my general solution is $a_n = α_1r_1^n + α_2r_2^n$.
$a_n = α_1(-2)^n + α_2(1)^n$
When $a_0 = 1$, then $1 =  α_1(-2)^0 + α_2(1)^0$, then $α_2 = 1 - α_1 $.
When $a_1 = 2$, then $2 =  α_1(-2)^1 + α_2(1)^1$, then $-2α_1 + 1 - α_1 = 2$.
$α_1 = -1/3$  and $α_2 = 4/3 $
So $a_n = -1/3r_1^n + 4/3r_2^n$.
Can anyone tell me if it is correct or not and any help will be appreciated :) .
Also, if I have $a_{n+2}=a_{n+1}+2a_n$. Can someone tell me if its char. equation should be like $r^2-r-2 = 0$? Just asking because of the addition symbol rather than subtraction.
 [/INST] The standard generating function approach yields
$$GF=\frac{(1+3x)}{1+x-2x^2}$$
which has a denominator which can be factorised
$$GF=\frac{1+3x}{(1+2x)(1-x)}$$
Applying the theory of partial fractions gives
$$GF=-\frac{1}{3(1+2x)}+\frac{4}{3(1-x)}$$
which are all recognizable contributions to a formula for the $n$th term
$$a_n=-\frac{1}{3}(-2)^n+\frac{4}{3}$$
which matches the answer by Cye Waldman
</s>