How to derive the closed form of this recurrence? For the recurrence, $T(n) = 3T(n-1)-2$, where $T(0)= 5$, I found the closed form to be $4\cdot 3^n +1$(with help of Wolfram Alpha). Now I am trying to figure it out for myself. So far, I have worked out: $T(n-1) = 3T(n-2)-2, T(n-2) = 3T(n-3)-2, T(n-3) = 3T(n-4)-2$ leading me to: $T(n)=81\cdot T(n-4)-54-18-6-2 $ etc. I have noticed the constants follow a Geometric Series whose sum is given by $1-3^n$. I am having trouble putting this together to end up with the final closed form.

By making use of the generating function method the difference equation $T_{n} = 3 T_{n-1} - 2$, $T_{0} = 5$, can be seen as follows
\begin{align}
T(x) &= \sum_{n=0}^{\infty} T_{n} x^{n} = 3 \sum_{n=0}^{\infty} T_{n-1} x^{n} - 2 \sum_{n=0}^{\infty} x^{n} \\
T(x) &= 3 \left( T_{-1} + \sum_{n=1}^{\infty} T_{n-1} x^{n} \right) - \frac{2}{1-x} \\
&= 3 \left( T_{-1} + x T(x) \right) - \frac{2}{1-x} 
\end{align}
which yields
\begin{align}
(1-3x) T(x) = 3 T_{-1} - \frac{2}{1-x}.
\end{align}
Since $T_{-1} = \frac{7}{3}$ then
\begin{align}
T(x) &= \frac{5 - 7x}{(1-x) (1-3x)} = \frac{1}{1-x} + \frac{4}{1-3x} \\
&= \sum_{n=0}^{\infty} \left( 4 \cdot 3^{n} + 1 \right) x^{n}
\end{align}
and provides $T_{n} = 4 \cdot 3^{n} + 1$. 
