Show solutionHide solution
This is a first-order linear differential equation. Write it in the form \(\frac{dy}{dx}+P(x)y=Q(x)\), where \(P(x)=\cot x\) and \(Q(x)=4x\cosec x\). Since \(x=\frac{\pi}{2}\) lies in \((0,\pi)\), we have \(\sin x>0\) there. Hence an integrating factor is
\[ \mu(x)=e^{\int \cot x\,dx}=e^{\ln(\sin x)}=\sin x. \]Multiplying the differential equation by \(\sin x\),
\[ \sin x\,\frac{dy}{dx}+y\cos x=4x. \]The left side is the derivative of \(y\sin x\), so
\[ \frac{d}{dx}(y\sin x)=4x. \]Integrating,
\[ y\sin x=2x^2+C. \]Using the initial condition \(y=0\) when \(x=\frac{\pi}{2}\):
\[ 0=2\left(\frac{\pi}{2}\right)^2+C=\frac{\pi^2}{2}+C, \]so
\[ C=-\frac{\pi^2}{2}. \]Therefore
\[ y\sin x=2x^2-\frac{\pi^2}{2}, \]and hence
\[ y=\frac{2x^2-\frac{\pi^2}{2}}{\sin x} =\frac{4x^2-\pi^2}{2\sin x}. \]This solution is valid on the interval containing \(\frac{\pi}{2}\) where \(\sin x\ne0\), for example \((0,\pi)\). The expression is undefined at \(x=n\pi\) for \(n\in\mathbb{Z}\), including \(x=0\) and the other zeros of \(\sin x\).