\[ y'(x)+y(x)^2 \sin (x)-2 \tan (x) \sec (x)=0 \] ✓ Mathematica : cpu = 0.444756 (sec), leaf count = 26
\[\left \{\left \{y(x)\to \frac {\sec (x) \left (c_1-2 \cos ^3(x)\right )}{c_1+\cos ^3(x)}\right \}\right \}\]
✓ Maple : cpu = 0.503 (sec), leaf count = 28
\[ \left \{ y \left ( x \right ) ={\frac {-2\, \left ( \cos \left ( x \right ) \right ) ^{3}{\it \_C1}-2}{ \left ( \left ( \cos \left ( x \right ) \right ) ^{3}{\it \_C1}-2 \right ) \cos \left ( x \right ) }} \right \} \]
\begin {align} y^{\prime }+y^{2}\sin \left ( x\right ) -2\frac {\sin x}{\cos ^{2}x} & =0\nonumber \\ y^{\prime } & =2\frac {\sin x}{\cos ^{2}x}-y^{2}\sin \left ( x\right ) \nonumber \\ & =P\left ( x\right ) +Q\left ( x\right ) y+R\left ( x\right ) y^{2}\tag {1} \end {align}
This is Ricatti first order non-linear ODE. \(P\left ( x\right ) =2\frac {\sin x}{\cos ^{2}x},Q\left ( x\right ) =0,R\left ( x\right ) =-\sin \left ( x\right ) \). A particular solution is \(y_{p}=\frac {1}{\cos x}\), therefore the solution is\begin {align*} y & =y_{p}+\frac {1}{u}\\ y & =\frac {1}{\cos x}+\frac {1}{u} \end {align*}
Hence\[ y^{\prime }=\frac {\sin x}{\cos ^{2}x}-\frac {u^{\prime }}{u^{2}}\] Equating this to RHS of (1) gives\begin {align*} \frac {\sin x}{\cos ^{2}x}-\frac {u^{\prime }}{u^{2}} & =2\frac {\sin x}{\cos ^{2}x}-y^{2}\sin \left ( x\right ) \\ & =2\frac {\sin x}{\cos ^{2}x}-\left ( \frac {1}{\cos x}+\frac {1}{u}\right ) ^{2}\sin \left ( x\right ) \\ & =2\frac {\sin x}{\cos ^{2}x}-\left ( \frac {1}{\cos ^{2}x}+\frac {1}{u^{2}}+\frac {2}{u\cos x}\right ) \sin \left ( x\right ) \end {align*}
Hence\begin {align*} -\frac {u^{\prime }}{u^{2}} & =-\frac {\sin x}{\cos ^{2}x}+2\frac {\sin x}{\cos ^{2}x}-\frac {\sin \left ( x\right ) }{\cos ^{2}x}-\frac {\sin \left ( x\right ) }{u^{2}}-\frac {2\sin \left ( x\right ) }{u\cos x}\\ & =-\frac {\sin \left ( x\right ) }{u^{2}}-\frac {2\sin \left ( x\right ) }{u\cos x} \end {align*}
Or\begin {align*} u^{\prime } & =\sin \left ( x\right ) +\frac {2u\sin \left ( x\right ) }{\cos x}\\ u^{\prime }-2u\tan \left ( x\right ) & =\sin \left ( x\right ) \end {align*}
Integrating factor is \(e^{-2\int \tan xdx}=e^{2\ln \left ( \cos x\right ) }=\cos ^{2}\left ( x\right ) \). Hence the above becomes\[ d\left ( u\cos ^{2}x\right ) =\cos ^{2}\left ( x\right ) \sin \left ( x\right ) \] Integrating both sides\begin {align*} u\cos ^{2}x & =\int \cos ^{2}\left ( x\right ) \sin \left ( x\right ) dx+C\\ & =\frac {-1}{3}\cos ^{3}\left ( x\right ) +C \end {align*}
Hence \[ u=\frac {-1}{3}\cos \left ( x\right ) +\frac {C}{\cos ^{2}x}\] Therefore\begin {align*} y & =y_{p}+\frac {1}{u}\\ & =\frac {1}{\cos x}+\frac {1}{\frac {-1}{3}\cos \left ( x\right ) +\frac {C}{\cos ^{2}x}}\\ & =\frac {1}{\cos x}+\frac {3\cos ^{2}x}{3C-\cos ^{3}\left ( x\right ) } \end {align*}
Let \(3C=C_{1}\)\[ y=\frac {1}{\cos x}+\frac {3\cos ^{2}x}{C_{2}-\cos ^{3}\left ( x\right ) }\] Verification
restart; ode:=diff(y(x),x)+y(x)^2*sin(x)-2*sin(x)/cos(x)^2 = 0; my_sol:=1/cos(x)+ 3*cos(x)^2/(_C1-cos(x)^3); odetest(y(x)=my_sol,ode); 0