<s>[INST] Find sequence function and general rule the function $$a_{n+2}=3a_{n+1}-2a_n+2$$
is given, and $$a_0=a_1=1, (a_n)_{n\ge0}$$
multiplying everything by $$/\sum_{n=0}^\infty x^{n+2}$$
also adding $$\sum_{n=0}^\infty (a_{n+2}x^{n+2}+a_1x+a_0)-a_1x-a_0=\sum_{n=0}^\infty (3a_{n+1}x^{n+2}+a_0)-a_0-\sum_{n=0}^\infty 2a_nx^{n+2}+\sum_{n=0}^\infty 2x^{n+2}$$
we get $$R(X)-2x-1=3x(R(X)-1)-2x^2R(X)+\frac{2x^2}{1-x}$$
$$R(X)(1-3x+2x^2)+x-1=\frac{2x^2}{1-x}$$
$$R(X)(1-3x+2x^2)=\frac{3x^2-2x+1}{1-x}$$
$$R(X)=\frac{3x^2-2x+1}{(1-x)^2(1-2x)}=\frac{A}{(1-x)^2}+\frac{B}{1-2x}$$
so $$3x^2-2x+1=A(1-2x)+B(1-x)^2$$
$$3x^2-2x+1=x^2(B)+x(-2A-2B)+A+B$$
B=3
-2A-2B=-2
A+B=1$$\quad\Longrightarrow\quad A=-2, B=3$$
$$R(X)=\frac{-2}{(1-x)^2}+\frac{3}{1-2x}=-2\sum_{n=0}^\infty nx^{n-1}+3\sum_{n=0}^\infty (2x)^2=$$
how to proceed?
 [/INST] It is better to work generating functions by multiplying by $z^n$ and sum over $n \ge 0$, which here gives:
$$
\frac{A(z) - a_0 - a_1 z}{z^2}
  = 3 \frac{A(z) - a_0}{z} 
      - 2 A(z)
      + 2 \frac{1}{1 - z}
$$
This results in:
$$
A(z) = \frac{1 - 3 z + 4 z^2}{1 - 4 z + 5 z^2 - 2 z^3}
     = \frac{2}{1 - 2 z} + \frac{1}{1 - z} - \frac{2}{(1 - z)^2}
$$
Read off the coefficients:
$$
a_n = 2 \cdot 2^n + 1 - 2 \binom{-2}{n}
    = 2^{n + 1} - 2 n - 1
$$
</s>