Let $a(1)= 1,\ a(2)= 5,\ a(n+2) = a(n+1)+2a(n)+3\ (n\in \mathbb{N})$. Find a formula for $a(n)$ in terms of $n$.
I tried to solve this problem by finding a pattern in each of the terms, but I was unsuccessful in any such attempts. Does anyone know the correct way to solve this?
You have $$\begin{pmatrix}a_{n+2} \\ a_{n+1} \\1 \end{pmatrix} = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 0 & 0 \\ 0 & 0 & 1\end{pmatrix}\begin{pmatrix}a_{n+1} \\ a_{n} \\1 \end{pmatrix} $$ so that $$ \begin{pmatrix}a_{n+2} \\ a_{n+1} \\1 \end{pmatrix} = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 0 & 0 \\ 0 & 0 & 1\end{pmatrix}^n\begin{pmatrix}5 \\ 1 \\1 \end{pmatrix}$$ and then diagonalizing gives $$ \begin{pmatrix}a_{n+2} \\ a_{n+1} \\1 \end{pmatrix} = \begin{pmatrix} -1 & -3 & 2 \\ 1 & -3 & 1 \\ 0 & 2 & 0\end{pmatrix}\begin{pmatrix} -1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 2\end{pmatrix}^n\begin{pmatrix} -1 & -3 & 2 \\ 1 & -3 & 1 \\ 0 & 2 & 0\end{pmatrix}^{-1}\begin{pmatrix}5 \\ 1 \\1 \end{pmatrix}$$ and then multiplying this out gives $$ \begin{pmatrix}a_{n+2} \\ a_{n+1} \\1 \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \left(-3+(-1)^n+3 \cdot 2^{n+2} \right) \\ \frac{1}{2} \left(-3+(-1)^{n+1}+3 \cdot 2^{n+1} \right) \\ 1\end{pmatrix}$$ so that we finally get the closed form solution $$\boxed{a_n =\left.\left.\frac{1}{2} \right[3 \cdot 2^n-3+(-1)^n \right]} $$