Solution (source code)

= Solution

Where $\sin x\ne0$, divide by it to obtain $y'+2\cot x\,y=\csc x$. The <integrating factor> is $\sin^2x$, and the <product rule> gives
$$
(y\sin^2x)'=\sin x,\qquad y\sin^2x=-\cos x+C.
$$
The <initial condition> gives $C=1$. Hence
$$
y=\frac{1-\cos x}{\sin^2x}=\boxed{\frac1{1+\cos x}}.
$$
The simplified expression has a differentiable extension through $x=0$, with $y(0)=1/2$. Direct substitution verifies the original undivided <differential equation> there as well: its left side is $2y(0)=1$. Thus the maximal <interval> containing $\pi/2$ on which this solution is finite is $\boxed{-\pi<x<\pi}$; the apparent exclusion of $0$ arose only from division by $\sin x$. This is <continuation through a zero of the leading ODE coefficient>.