Solving $\frac{dy}{d\theta} + y \cos \theta = \frac{1}{2} \sin 2\theta$ 
Solve 
  $$\frac{dy}{d\theta} + y \cos \theta = \frac{1}{2} \sin 2\theta$$ with $y(\pi/2) = 4$.

I couldn't think of any useful substitution, so I tried simplifying this DE, but didn't get anywhere. Any ideas on the best way to approach this problem?
 A: $$y'+ y \cos(\theta) = \frac{1}{2} \sin(2\theta)$$
Multiply by integrating factor*** $\mu(\theta)=e^{\sin(\theta)}$
$$y'e^{\sin(\theta)}+ y e^{\sin(\theta)}\cos(\theta) = \frac{1}{2}e^{\sin(\theta)} \sin(2\theta)$$
$$(ye^{\sin(\theta)})' =e^{\sin(\theta)} \sin(\theta)\cos(\theta)$$
Integrate
$$ye^{\sin(\theta)} =\int e^{\sin(\theta)} \sin(\theta)\cos(\theta)d\theta$$
Substitute $u=\sin(\theta)$
$$ye^{\sin(\theta)} =\int e^uudu$$
$$ye^{\sin(\theta)} = e^uu-e^u+K$$
$$y= \sin(\theta)-1+Ke^{-\sin(\theta)} $$
Apply the initial condition

*** there is a formula for the integrating factor for an equation $y′+p(x)y=q(x)$ the integrating factor is   $\mu=e^{\int p(x)dx}$
A: $$y'+y\cos(\theta)=\frac12\sin(2\theta)=\sin(\theta)\cos(\theta) \tag 1$$
HINT : 
Alternative method without talking of integrating factor :
First solve the associated homogeneous equation (which is separable)
$$y_h'+y_hcos(\theta)=0$$`
$$y_h=Ce^{-\sin(\theta)}$$
Then change of function (variation of parameter : replace the constant $C$ by a function)
$$y(\theta)=C(\theta)e^{-\sin(\theta)}$$
$$y'=C'(\theta)e^{-\sin(\theta)}-C\cos(\theta)e^{-\sin(\theta)}$$
Putting them into Eq.$(1)$ leads to a first order linear and separable ODE easy to solve for $C(\theta)$. 
In fact, this is equivalent to the integrating factor method, but without frighten with the search of an integrating factor when one doesn't remember the formula to find it. 
