Solve the following recurrence relation $$P(1)=2$$ $$P(n)=2P(n-1)+2^n\cdot n$$ for $n\ge 2$
I know I need to expand to look for a pattern but it's not clicking for me. I don't see the pattern that will simplify this recursive statement. Any help is much appreciated.
Dividing the both sides by $2^n$ gives us$$\begin{align}P(n)=2P(n-1)+n\cdot 2^n&\iff \frac{P(n)}{2^n}=\frac{2P(n-1)}{2^n}+\frac{n\cdot 2^n}{2^n}\\&\iff \frac{P(n)}{2^n}=\frac{P(n-1)}{2^{n-1}}+n\\&\iff Q(n)=Q(n-1)+n\end{align}$$ where $$Q(n)=\frac{P(n)}{2^n}.$$
Hence, since we have $$Q(n+1)-Q(n)=n+1,$$we have, for $n\ge 2$, $$\begin{align}Q(n)&=Q(1)+\sum_{k=1}^{n-1}(k+1)\\&=\frac{P(1)}{2^1}+\frac{(n-1)n}{2}+(n-1)\\&=\frac{n(n+1)}{2}.\end{align}$$ Note that this holds for $n=1$.
Hence, we have $$P(n)=\frac{n(n+1)}{2}\cdot 2^n=n(n+1)\cdot 2^{n-1}\ \ (n\ge 1).$$