Solve this nonhomegenous ode $y''+4y = \cos(2x)$

Solve the given nonhomogenous linear ODE by variation of parameters or undetermined coefficients $y'' + 4y = \cos(2x)$.

A general solution is $y_1 = \cos(2x), y_2 = \sin(2x)$, and the Wronksin determinant is equal to 2.

Plugging this into the equation for the method of variation of parameters, I get $$-\cos(2x)\int\frac{\sin(2x)\cos(2x)}{2}dx + \sin(2x)\int\frac{\cos^2(2x)}{2}dx$$

The integrals cancel out to $0$. How can I approach this correctly with the method proposed?


As $2i$ is a simple root of the characteristic equation of the l.h.s., a particular solution of the non-homogeneous equation has the form $$y_0(x)=Ax\cos 2x+Bx\sin 2x$$ whence \begin{align} y'_0(x)&=A\cos 2x-2Ax\sin 2x+B\sin 2x+2Bx\cos 2x \\ &= (A+2Bx)\cos 2x+(B-2Ax)\sin 2x,\\ y''_0(x)&=4(B-A)\cos 2x-4(A+Bx)\sin 2x. \end{align} Can you proceed?


Then by variation of parameters we have the particular solution is given by $$y_p=\cos(2x)u_{1}+\sin(2x)u_{2}$$ where $$u_{1}=-\frac{1}{2}\int \cos(2x)\sin(2x){\rm d}x=\frac{1}{16}\cos(4x)$$ and $$u_{2}=\frac{1}{2}\int \cos(2x)\cos(2x){\rm d}x=\frac{x}{4}+\frac{\sin(4x)}{16}.$$

Simplify, we have the general solution

$$y=c_{1}\cos(2x)+c_{2}\sin(2x)+\frac{1}{4}x\sin(2x). $$