Solution (source code)

= Solution

The forcing $\sec(2x)$ is undefined at $x=\pm\pi/4$, both inside the printed interval. Therefore \b[there is no classical solution on the whole stated interval]. Solve separately on the three connected components obtained by removing those two points.

Choose $u_1=\cos(2x)$ and $u_2=\sin(2x)$, whose <Wronskian> is two. <Variation of parameters> gives $t_1'=-(1/2)\tan(2x)$ and $t_2'=1/2$, so a particular solution is $\tfrac14\cos(2x)\log|\cos(2x)|+\tfrac x2\sin(2x)$. The full answer on each regular component is
$$
\boxed{y=A\cos(2x)+B\sin(2x)+\frac14\cos(2x)\log|\cos(2x)|+\frac x2\sin(2x).}
$$
The constants $A,B$ can differ between $(-\pi/2,-\pi/4)$, $(-\pi/4,\pi/4)$ and $(\pi/4,\pi/2)$. <Differentiation> gives $y''+4y=1/\cos(2x)$ wherever the forcing is defined. Although the particular solution has finite one-sided values at the singularities, its <derivative> has a logarithmic divergence, and the equation itself is undefined there. It cannot be promoted to one classical solution across the poles.