Method of Undetermined Coefficients with complex root

I'm trying to solve the following ODE and am stuck at the end. The question is: $$y''+4y=2\sin(2x)+x^2+1$$ I first solve the homogeneous part. Writing the characteristic equation: \begin{align*} r^2 + 4 = 0 \implies r=\pm2i \end{align*} So the complementary solution is $$Y_c=c_1\cos(2x)+c_2\sin(2x)$$ Next, I guess a particular solution of the form: $$Y_p(x)=2A\sin(2x)+2B\cos(2x)+Cx^2+Dx+E.$$ Computing its first and second derivatives yields: \begin{align*} Y'_p(x) & =4A\cos(2x)-4B\sin(2x)+2Cx+D \\ Y''_p(x) & =-8A\sin(2x)-8B\cos(2x)+2C. \end{align*} Substituting these into the ODE gives: $$-8A\sin(2x)-8B\cos(2x)+2C+2A\sin(2x)+2B\cos(2x)+Cx^2+Dx+E$$ $$= 2C+Cx^2+Dx+E =2\sin(2x)+x^2+1$$ I know $C=1$ and $E=1$ but then I'm unsure. Any help would be really appreciated

• Since the inhomogeneous term contains $\sin(2x)$ which is part of the complementary solution, you should guess $Ax\sin(2x) + Bx\cos(2x) + Cx^2 + Dx + E$ for $Y_p(x)$ instead. – Chee Han Apr 26 '17 at 12:51

$$Y_p(x)= \color{red}{2A\sin(2x)+2B\cos(2x)}+Cx^2+Dx+E$$

The red part in your $Y_p$ above can't work because that's already a part of the solution to the homogeneous part $Y_c$ (so that will simplify to $0$...!):

$$Y_c=c_1\cos(2x)+c_2\sin(2x)$$

The trick is to multiply by $x$, so take:

$$Y_p(x)= \color{blue}{A\,x\sin(2x)+B\,x\cos(2x)}+Cx^2+Dx+E$$

Note that you can omit the factors $2$ since you still have the undetermined coefficients $A$ and $B$.

Hoover over to see what you should get:

$$\displaystyle Y_p(x)= -\frac{1}{2}\,x\cos(2x)+\frac{x^2}{4}+\frac{1}{8}$$