Given $a_0 = 1$ and $a_n = (n + 1)a_{n - 1} + 3^n$ for $n \geq 1$, find formula for $a_n$.
First remind the definition of power series $F(x) = \sum_{n \geq 0}f_n \frac{x^n}{n!}$ and exponential generating function $G(x) = \sum_{n \geq 0}\frac{x^n}{n!} = e^x$
Note we have to use exponential generating function to solve this question. So let $f(x) = \sum_{n \geq 0}a_n\frac{x^n}{n!}$, multiplying both sides of $a_n = (n + 1)a_{n - 1} + 3^n$ by $\frac{x^n}{n!}$ and sum over all $n \geq 1$. We get, $$\sum_{n \geq 1}a_n\frac{x^n}{n!} = \sum_{n \geq 1}(n + 1)a_{n - 1}\frac{x^n}{n!} + \sum_{n \geq 1}3^n\frac{x^n}{n!}$$ $$\sum_{n \geq 1}a_n\frac{x^n}{n!} = \sum_{n \geq 1}na_{n - 1}\frac{x^n}{n!} + \sum_{n \geq 1}a_{n - 1}\frac{x^n}{n!} + \sum_{n \geq 0}\frac{(3x)^{n}}{n!} - 1$$ $$\underbrace{\sum_{n \geq 0}a_n\frac{x^n}{n!}}_{f(x)} - 1 = x\underbrace{\sum_{n \geq 1}a_{n - 1}\frac{x^{n-1}}{(n-1)!}}_{f(x)} + \underbrace{\sum_{n \geq 1}a_{n - 1}\frac{x^{n}}{(n)!}}_{\int{f(x)} = F(x) + C} + e^{3x} - 1$$ $$F'(x) - 1 = xF'(x) + F(x) + e^{3x} - 1 + C$$ $$F'(x)(1 - x) - F(x) = e^{3x} + C$$ I think I'm essentially stuck here, I'm trying my best to manipulate each term so that we can express each term in terms of $f(x)$. But I can't go further from here because it doesn't like look this form can lead us to the solution.
Any feedback or suggestion?
It's easier if you divide through by $n+1$ and consider the exponential generating function of $a_n/(n+1)!$ to get
\begin{align}f(x)&=\sum_{n=0}^\infty\frac{a_n}{(n+1)n!}x^n=\sum_{n=0}^\infty\frac{a_n}{(n+1)!}x^n\\&=\sum_{n=0}^\infty\frac{a_{n-1}}{n!}x^n+\sum_{n=0}^\infty\frac1{(n+1)n!}(3x)^n\\&=a_{-1}+\sum_{n=0}^\infty\frac{a_n}{(n+1)!}x^{n+1}+\sum_{n=0}^\infty\frac{(3x)^n}{(n+1)!}\\&=a_{-1}+xf(x)+\frac1{3x}\sum_{n=1}^\infty\frac{(3x)^n}{n!}\\&=a_{-1}+xf(x)+\frac{\exp(3x)-1}{3x}\\{}\\f(x)&=\frac{a_{-1}+(\exp(3x)-1)/(3x)}{1-x}\end{align}