2.4.6.3 Maple. Time used: 0.002 (sec). Leaf size: 15
ode:=diff(y(x),x)+cos(x)*y(x) = 1/2*sin(2*x); 
dsolve(ode,y(x), singsol=all);
 
\begin{align*} y = \sin \left (x \right )-1+{\mathrm e}^{-\sin \left (x \right )} c_1 \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 x}y \left (x \right )+y \left (x \right ) \cos \left (x \right )=\frac {\sin \left (2 x \right )}{2} \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d x}y \left (x \right ) \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=-y \left (x \right ) \cos \left (x \right )+\frac {\sin \left (2 x \right )}{2} \\ \bullet & {} & \textrm {Group terms with}\hspace {3pt} y \left (x \right )\hspace {3pt}\textrm {on the lhs of the ODE and the rest on the rhs of the ODE}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )+y \left (x \right ) \cos \left (x \right )=\frac {\sin \left (2 x \right )}{2} \\ \bullet & {} & \textrm {The ODE is linear; multiply by an integrating factor}\hspace {3pt} \mu \left (x \right ) \\ {} & {} & \mu \left (x \right ) \left (\frac {d}{d x}y \left (x \right )+y \left (x \right ) \cos \left (x \right )\right )=\frac {\mu \left (x \right ) \sin \left (2 x \right )}{2} \\ \bullet & {} & \textrm {Assume the lhs of the ODE is the total derivative}\hspace {3pt} \frac {d}{d x}\left (y \left (x \right ) \mu \left (x \right )\right ) \\ {} & {} & \mu \left (x \right ) \left (\frac {d}{d x}y \left (x \right )+y \left (x \right ) \cos \left (x \right )\right )=\left (\frac {d}{d x}y \left (x \right )\right ) \mu \left (x \right )+y \left (x \right ) \left (\frac {d}{d x}\mu \left (x \right )\right ) \\ \bullet & {} & \textrm {Isolate}\hspace {3pt} \frac {d}{d x}\mu \left (x \right ) \\ {} & {} & \frac {d}{d x}\mu \left (x \right )=\mu \left (x \right ) \cos \left (x \right ) \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (x \right )={\mathrm e}^{\sin \left (x \right )} \\ \bullet & {} & \textrm {Integrate both sides with respect to}\hspace {3pt} x \\ {} & {} & \int \left (\frac {d}{d x}\left (y \left (x \right ) \mu \left (x \right )\right )\right )d x =\int \frac {\mu \left (x \right ) \sin \left (2 x \right )}{2}d x +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & y \left (x \right ) \mu \left (x \right )=\int \frac {\mu \left (x \right ) \sin \left (2 x \right )}{2}d x +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} y \left (x \right ) \\ {} & {} & y \left (x \right )=\frac {\int \frac {\mu \left (x \right ) \sin \left (2 x \right )}{2}d x +\mathit {C1}}{\mu \left (x \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (x \right )={\mathrm e}^{\sin \left (x \right )} \\ {} & {} & y \left (x \right )=\frac {\int \frac {{\mathrm e}^{\sin \left (x \right )} \sin \left (2 x \right )}{2}d x +\mathit {C1}}{{\mathrm e}^{\sin \left (x \right )}} \\ \bullet & {} & \textrm {Evaluate the integrals on the rhs}\hspace {3pt} \\ {} & {} & y \left (x \right )=\frac {{\mathrm e}^{\sin \left (x \right )} \sin \left (x \right )-{\mathrm e}^{\sin \left (x \right )}+\mathit {C1}}{{\mathrm e}^{\sin \left (x \right )}} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & y \left (x \right )=\sin \left (x \right )-1+{\mathrm e}^{-\sin \left (x \right )} \mathit {C1} \end {array} \]