2.1.21.3 Maple. Time used: 0.002 (sec). Leaf size: 15
ode:=diff(x(t),t)-x(t)*tan(t) = 4*sin(t); 
dsolve(ode,x(t), singsol=all);
 
\begin{align*} x = \left (-\cos \left (2 t \right )+c_1 \right ) \sec \left (t \right ) \end{align*}

Maple trace

Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
<- 1st order linear successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )-x \left (t \right ) \tan \left (t \right )=4 \sin \left (t \right ) \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d t}x \left (t \right ) \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )=x \left (t \right ) \tan \left (t \right )+4 \sin \left (t \right ) \\ \bullet & {} & \textrm {Group terms with}\hspace {3pt} x \left (t \right )\hspace {3pt}\textrm {on the lhs of the ODE and the rest on the rhs of the ODE}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )-x \left (t \right ) \tan \left (t \right )=4 \sin \left (t \right ) \\ \bullet & {} & \textrm {The ODE is linear; multiply by an integrating factor}\hspace {3pt} \mu \left (t \right ) \\ {} & {} & \mu \left (t \right ) \left (\frac {d}{d t}x \left (t \right )-x \left (t \right ) \tan \left (t \right )\right )=4 \mu \left (t \right ) \sin \left (t \right ) \\ \bullet & {} & \textrm {Assume the lhs of the ODE is the total derivative}\hspace {3pt} \frac {d}{d t}\left (x \left (t \right ) \mu \left (t \right )\right ) \\ {} & {} & \mu \left (t \right ) \left (\frac {d}{d t}x \left (t \right )-x \left (t \right ) \tan \left (t \right )\right )=\left (\frac {d}{d t}x \left (t \right )\right ) \mu \left (t \right )+x \left (t \right ) \left (\frac {d}{d t}\mu \left (t \right )\right ) \\ \bullet & {} & \textrm {Isolate}\hspace {3pt} \frac {d}{d t}\mu \left (t \right ) \\ {} & {} & \frac {d}{d t}\mu \left (t \right )=-\mu \left (t \right ) \tan \left (t \right ) \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (t \right )=\cos \left (t \right ) \\ \bullet & {} & \textrm {Integrate both sides with respect to}\hspace {3pt} t \\ {} & {} & \int \left (\frac {d}{d t}\left (x \left (t \right ) \mu \left (t \right )\right )\right )d t =\int 4 \mu \left (t \right ) \sin \left (t \right )d t +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & x \left (t \right ) \mu \left (t \right )=\int 4 \mu \left (t \right ) \sin \left (t \right )d t +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} x \left (t \right ) \\ {} & {} & x \left (t \right )=\frac {\int 4 \mu \left (t \right ) \sin \left (t \right )d t +\mathit {C1}}{\mu \left (t \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (t \right )=\cos \left (t \right ) \\ {} & {} & x \left (t \right )=\frac {\int 4 \cos \left (t \right ) \sin \left (t \right )d t +\mathit {C1}}{\cos \left (t \right )} \\ \bullet & {} & \textrm {Evaluate the integrals on the rhs}\hspace {3pt} \\ {} & {} & x \left (t \right )=\frac {2 \sin \left (t \right )^{2}+\mathit {C1}}{\cos \left (t \right )} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & x \left (t \right )=\left (2 \sin \left (t \right )^{2}+\mathit {C1} \right ) \sec \left (t \right ) \end {array} \]