= Solution
Using the <complex forcing method for a real differential equation>, $\operatorname{Im}[(4x+2i)e^{ix}]=4x\sin x+2\cos x$, a suitable complex forcing is $f(x)=(4x+2i)e^{ix}$. Solve $u''+2u=f$ and take its <imaginary part>. Writing $u=p(x)e^{ix}$ reduces the equation to
$$
p''+2ip'+p=4x+2i.
$$
A linear polynomial $p=ax+b$ gives $a=4$ and $b=-6i$. Thus
$$
\boxed{y_p(x)=\operatorname{Im}[(4x-6i)e^{ix}]=4x\sin x-6\cos x.}
$$
For a direct check, $(4x\sin x)''+2(4x\sin x)=8\cos x+4x\sin x$, while $(-6\cos x)''+2(-6\cos x)=-6\cos x$. Their sum is the required forcing. Adding $A\cos(\sqrt2x)+B\sin(\sqrt2x)$ gives the full real solution if needed.
Back to article page