#### 2.8   ODE No. 8

$y'(x)+y(x) \tan (x)-\sin (2 x)=0$ Mathematica : cpu = 0.0186674 (sec), leaf count = 17

$\left \{\left \{y(x)\to c_1 \cos (x)-2 \cos ^2(x)\right \}\right \}$ Maple : cpu = 0.007 (sec), leaf count = 13

$\left \{ y \left ( x \right ) =\cos \left ( x \right ) \left ( -2\,\cos \left ( x \right ) +{\it \_C1} \right ) \right \}$

Hand solution

\begin {equation} \frac {dy}{dx}+y\left ( x\right ) \tan \left ( x\right ) =\sin \left ( 2x\right ) \tag {1} \end {equation}

Integrating factor $$\mu =e^{\int \tan dx}=e^{-\ln \left ( \cos \left ( x\right ) \right ) }=\frac {1}{\cos \left ( x\right ) }$$. Hence (1) becomes

$\frac {d}{dx}\left ( y\left ( x\right ) \frac {1}{\cos \left ( x\right ) }\right ) =\frac {1}{\cos \left ( x\right ) }\sin \left ( 2x\right )$

Integrating both sides

\begin {align*} y\left ( x\right ) \frac {1}{\cos \left ( x\right ) } & =\int \frac {1}{\cos \left ( x\right ) }\sin \left ( 2x\right ) dx+C\\ y\left ( x\right ) & =\cos \left ( x\right ) \int \frac {\sin \left ( 2x\right ) }{\cos \left ( x\right ) }dx+C\cos \left ( x\right ) \end {align*}

But $$\sin \left ( 2x\right ) =2\sin \left ( x\right ) \cos \left ( x\right )$$ hence

\begin {align*} y\left ( x\right ) & =\cos \left ( x\right ) \int \frac {2\sin \left ( x\right ) \cos \left ( x\right ) }{\cos \left ( x\right ) }dx+C\cos \left ( x\right ) \\ & =2\cos \left ( x\right ) \int \sin \left ( x\right ) dx+C\cos \left ( x\right ) \\ & =-2\cos ^{2}\left ( x\right ) +C\cos \left ( x\right ) \end {align*}