I would like to know whether I have correctly solved the following differential equation since the book gives a different answer than I did. $$y''+2y'+2y=e^{-x}\sin(x)$$ We guess the solution has the form of, $e^{rt}[A \cos(kt)+B \sin(kt)]$.
First we try $e^{-t}[A\cdot \cos(t) + B \cdot \sin(t)]$, then $$y'=-e^{-t}[A \cos(t) + B \sin(t)]+e^{-t}[-A\sin(t) + B \cos(t)] $$ and $$y''=e^{-t}[A \cos(t) + B \sin(t)] + e^{-t}[-A\cos(t) - B \sin(t)].$$ We get the form: $$e^{-t}\big[(A-A-2A+2B+2A)\cos(t)+(B-B-2B-2A+2B)\sin(t)\big] \\=e^{-t}(2B \cos(t) - 2A \sin(t))$$
hence $B=0 $ and $A=-\frac{1}{2}$ and thus $$y_{p}=e^{-t}(-\frac{1}{2}\cos(t)).$$
since $y_{h}=e^{-t}(A\cos(t)+B \sin(t))$ the solution to the differential equation is
$$y_{s}=e^{-t}[A \cos(t)+B \sin(t) - \frac{1}{2} \cos(t)].$$
However my book get the solution;
$$y_{s}=-\frac{1}{2} t e^{-t}\cos(t)+e^{-t}(A \cos(t) +B \sin(t)).$$
So somehow they included $x$ in their initial guess, can you explain why?
Make for the particular solution the ansatz $$y_P=Ae^{-x}x\cos(x)$$