<s>[INST] Solving $a_n=3a_{n-1}-2a_{n-2}+3$ for $a_0=a_1=1$ I'm trying to solve the recurrence $a_n=3a_{n-1}-2a_{n-2}+3$ for $a_0=a_1=1$.  First I solved for the homogeneous equation $a_n=3a_{n-1}-2a_{n-2}$ and got $\alpha 1^n+\beta 2^n=a_n^h$.  Solving this gives $a_n^h =1$.  The particular solution, as I understand, will be $a_n^*=B$ since $f(n)=3\times 1^n$.  But then I get $B=a^*=3a^*_{n-1}-2a^*_{n-2}+3=B+3$.  This has to be a mistake, but I don't see what I did wrong.
 [/INST] Let $f(x) = \sum_{n=0}^\infty a_nx^n$. Multiplying the recurrence by $x^n$ and summing over $n\geqslant 2$ we find that the LHS is
$$\sum_{n=2}^\infty a_nx^n = f(x)-1-x $$
and the RHS is
$$3\sum_{n=2}^\infty a_{n-1}x^n - 2\sum_{n=2}^\infty a_{n-2}x^n + 3\sum_{n=2}^\infty x^n = 3x(f(x)-1) - 2x^2f(x)+\frac{3x^2}{1-x}.  $$
Equating the above and  $f(x)$ we find that 
$$f(x) = \frac{1-2x}{1-3x+2x^2} + \frac{3x^2}{(1-x)(1-3x+2x^2)}. $$
Partial fraction decomposition yields
$$f(x) = \frac1{1-x} + \frac3{1-2x} - \frac3{(1-x)^2}, $$
which has series representation
$$f(x) = \sum_{n=0}^\infty(1+3\cdot(2^n) - 3(n+1))x^n. $$
It follows that
$$a_n = 1+3\cdot(2^n) - 3(n+1),\ n\geqslant0. $$
</s>