2.8   ODE No. 8

\[ y'(x)+y(x) \tan (x)-\sin (2 x)=0 \]

Mathematica : cpu = 0.0246997 (sec), leaf count = 17

DSolve[-Sin[2*x] + Tan[x]*y[x] + Derivative[1][y][x] == 0,y[x],x]
 
\[\left \{\left \{y(x)\to -2 \cos ^2(x)+c_1 \cos (x)\right \}\right \}\]

Maple : cpu = 0.013 (sec), leaf count = 13

dsolve(diff(y(x),x)+y(x)*tan(x)-sin(2*x) = 0,y(x))
 
\[y \left (x \right ) = \left (-2 \cos \left (x \right )+c_{1} \right ) \cos \left (x \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*}