quick question with 2nd order linear differential equations I am solving $y''+4y'+5y=2e^{-2x}cos(x)$
I am working on determining $A$ and $B$ in  the particular function. I have the following 2 equations:
for the sine part : 
$-2A+3Ax-3B+Bx=0$ 
for the cosine part: 
$-3A+Ax+2B-3Bx=2$ 
What do I need to set x to?
 A: Trying a particular solution of the form $xe^{rx}$, where $r$ is either root of the quadratic equation $r^2+4r+5=0$.  
Note that these roots are $r_1=-2+i$ and $r_2=-2-i$. 
Then, we have 
$$\begin{align}
&y_p(x)=x(Ae^{r_1x}+Be^{r_2x})\\
&y'_p(x)=(Ae^{r_1x}+Be^{r_2x})+x(r_1Ae^{r_1x}+r_2Be^{r_2x})\\
&y''_p(x)=2(Ar_1e^{r_1x}+Br_2e^{r_2x})+x(r_1^2Ae^{r_1x}+r_2^2Be^{r_2x})
\end{align}$$
Now, for the ODE, we gather "like" terms as follows and write
$$\begin{align}
y''_p(x)+4y_p(x)+5y_p(x)&=Ae^{r_1x}\left((r_1^2+4r_1+5)x+(2r_1+4)\right)+Be^{r_2x}\left((r_2^2+4r_2+5)x+(2r_2+4)\right)\\\\
&=A(2r_1+4)e^{r_1x}+B(2r_2+4)e^{r_2x}
\end{align}$$
since both $r_1^2+4r_1+5=0$ and $r_2^2+4r_2+5=0$.  Now, note that $e^{-2x}\cos x=\frac12 e^{r_1x}+\frac12 e^{r_2x}$.  By linear independence of $e^{r_1x}$ and $e^{r_1x}$, we must have 
$$A(2r_1+4)=\frac12$$
and 
$$B(2r_2+4)=\frac12$$
Solving for $A$ and $B$, gives $A=-i/4$ and $B=i/4$.  Thus, substituting back into the expression for $y_p(x)$ leads to the particular solution 
$$y_p(x)=\frac{xe^{-2x}}{4}(-ie^{ix}+ie^{-ix})=\frac12 xe^{-2x}\sin x$$
