Solve recurring sequence using a generating function I have the sequence $a_n=3a_{n-1}-3a_{n-2}+a_{n-3}$, $\forall\ n \ge 3$, with $a_0=2$, $a_1=2$, $a_2=4$ being the known terms, and I want to find a non-recursive equation for $a_n$ using a generating function.
What I have done:
$$
\begin{align}
A(x)
& = \sum_{n\ge0}{a_nx^n}
  = a_0+a_1x+a_2x^2+\sum_{n\ge 3}\left({3a_{n-1}-3a_{n-2}+a_{n-3}}\right)x^n\\
& = 2+2x+4x^2+3x\sum_{n\ge 3}{a_{n-1}x^{n-1}}
  -3x^2\sum_{n\ge 3}{a_{n-2}x^{n-2}}
  +x^3\sum_{n\ge 3}{a_{n-3}x^{n-3}}\\
& = 2+2x+4x^2+3xA(x)-3x^2A(x)+x^3A(x)\\
& = \frac{2+2x+4x^2}{1-3x+3x^2-x^3}\\
& = \frac{4x^2+2x+2}{(1-x)^3}
\end{align}
$$
As shown above, I have reached a solution for $A(x)$, but I'm not sure how to use it to find a solution for $a_n$. Any tips pointing me in the right direction would be greatly appreciated.

Your calculation is correct up to
$$
\begin{align}
A(x)
& = \sum_{n\ge0}{a_nx^n}
  = a_0+a_1x+a_2x^2+\sum_{n\ge 3}\left({3a_{n-1}-3a_{n-2}+a_{n-3}}\right)x^n\\
& = 2+2x+4x^2+3x\sum_{n\ge 3}{a_{n-1}x^{n-1}}
  -3x^2\sum_{n\ge 3}{a_{n-2}x^{n-2}}
  +x^3\sum_{n\ge 3}{a_{n-3}x^{n-3}}
\end{align}
$$
But then
$$
\begin{align}
 \sum_{n\ge 3}{a_{n-1}x^{n-1}} &= \sum_{n\ge 2}{a_{n}x^{n}} = A(x) - 2 - 2x \\
 \sum_{n\ge 3}{a_{n-2}x^{n-2}} &= \sum_{n\ge 1}{a_{n}x^{n}} = A(x) - 2
\end{align}
$$
so that
$$
 A(x) = 2+2x+4x^2 + 3x(A(a) - 2-2x) -3x^2(A(x) - 2) + x^3A(x)
$$
which gives
$$
 A(x) = \frac{2-4x + 4x^2}{(1-x)^3} \, .
$$
Differentiating the geometric series $\frac{1}{1-x} = \sum_{n=0}^\infty x^n$
twice gives
$$
 \frac{2}{(1-x)^3} = \sum_{n=2}^\infty n(n-1) x^{n-2} = \sum_{n=0}^\infty (n+1)(n+2)x^n \, ,
$$
therefore
$$
\begin{align}
 A(x) &= (1-2x + 2 x^2) \sum_{n=0}^\infty (n+1)(n+2)x^n \\
 &= \sum_{n=0}^\infty (n+1)(n+2)x^n - 2\sum_{n=0}^\infty (n+1)(n+2)x^{n+1} +2\sum_{n=0}^\infty (n+1)(n+2)x^{n+2}  \\
 &= \sum_{n=0}^\infty (n+1)(n+2)x^n - 2\sum_{n=1}^\infty n(n+1)x^n +2\sum_{n=2}^\infty (n-1)nx^n  \\
 &= \sum_{n=0}^\infty (n+1)(n+2)x^n - 2\sum_{n=0}^\infty n(n+1)x^n +2\sum_{n=0}^\infty (n-1)nx^n  \\
 &= \sum_{n=0}^\infty \bigl( (n+1)(n+2) - 2n(n+1) +2(n-1)n\bigr) x^n \\
 &= \sum_{n=0}^\infty (n^2 -n+2) x^n 
\end{align}
$$
and $a_n = n^2-n+2$.
