Solution (source code)

= Solution

Since $1+\cos2y=2\cos^2y$, separation gives
$$
\sec^2y\,dy=\frac{2}{x^2}\,dx,
\qquad
\tan y=C-\frac2x.
$$
The limiting condition gives $C=1$. Taking $\tan^{-1}$ with range $(-\pi/2,\pi/2)$ and selecting the branch approaching $9\pi/4$ yields
$$
y(x)=2\pi+\tan^{-1}\left(1-\frac2x\right)
$$
for $x>0$.