TITLE: How can I solve $a_{n+2} + 4a_n = n \cdot 2^n$ for non homogeneous solution?
QUESTION [6 upvotes]: Solve $a_{n+2} + 4a_n = n \cdot 2^n\;$ for non homogeneous $a_0 =1$ and $a_1 =0$

I was trying but I think it's wrong. I solved a question with $2^n$ but that had a form with $A \cdot 2^n$ but I think this requires a different solution than this.

REPLY [3 votes]: We have here a linear recurrence relation.
Solve first the homogeneous equation : $$h_{n+2}+4h_n=0$$
It has characteristic equation $x^2+4=0$ thus $\pm 2i$ are roots.
The solutions of homogeneous equation are then given by $h_n=2^n(A\cos(\frac{n\pi}2)+B\sin(\frac{n\pi}2))$
Now we have to find a particular solution of the full equation: $$p_{n+2}+4p_n=n\times2^n$$
When the RHS is of the form $P(n)\times r^n$ with $P$ a polynomial, we have to look whether $r$ is a root of the characteristic equation or not.
Here $r=2$ is not a root, so we will search for a solution $Q(n)\times 2^n$ with $\deg Q=\deg P$. 
[In case $r$ is a root, we search for $\deg Q=\deg P+1$, or even $+2$ is $r$ is a double root, and so on]
Thus with $p_n=(Cn+D)2^n$ we get $b_{n+2}+4b_n=2^n(8Cn+8C+8D)=n2^n\iff\begin{cases}C=\frac 18\\ D=-\frac 18\end{cases}$
Finally we apply the initial conditions:
The general solution is : $a_n=h_n+p_n=\left(\frac{n-1}8+A\cos(\frac{n\pi}2)+B\sin(\frac{n\pi}2)\right)2^n$
$a_0=-\frac 18+A=1\iff A=\frac 98$
$a_1=2B=0\iff B=0$

$a_n=\left(n-1+9\cos(\frac{n\pi}2)\right)2^{n-3}$