Differential equation problem I am looking at the differential equation:
$$\frac{dR}{d\theta} + R = e^{-\theta} \sec^2 \theta.$$
I understand how to use $e^{\int 1 d\theta}$ to multiply both sides which gives me:
(looking at left hand side of equation only)
$$e^\theta \frac{dR}{d\theta} + e^\theta R.$$
However I am not sure how to further simplify the left hand side of the equation before integrating.
Can someone please show me the process for doing that?
Thanks kindly for any help.

We have
$$\frac{d R(\theta)}{d \theta} + R(\theta) = \exp(-\theta) \sec^2(\theta)$$
Multiply throughout by $\exp(\theta)$, we get $$\exp(\theta) \frac{dR(\theta)}{d \theta} + \exp(\theta) R(\theta) = \sec^{2}(\theta)$$
Note that $$\frac{d (R(\theta) \exp(\theta))}{d \theta} = R(\theta) \exp(\theta) + \exp(\theta) \frac{d R(\theta)}{d \theta}.$$
Hence, we get that $$\frac{d(R(\theta) \exp(\theta))}{d \theta} = \sec^2(\theta).$$
Integrating it out, we get $$R(\theta) \exp(\theta) = \tan(\theta) + C$$
This gives us that $$R(\theta) = \exp(-\theta) \tan(\theta) + C \exp(-\theta).$$
EDIT I am adding what Henry T. Horton points out in the comments and elaborating it a bit more. The idea behind the integrating factor is to rewrite the left hand side as a derivative. For instance, if we have the differential equation in the form
\begin{align}
\frac{d R(\theta)}{d \theta} + M(\theta) R(\theta) & = N(\theta) & \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(1)
\end{align}
the goal is to find the "integrating factor" $L(\theta)$ such that when we multiply the differential equation by $L(\theta)$, we can rewrite the equation as 
\begin{align}
\frac{d (L(\theta)R(\theta))}{d \theta} & = L(\theta) N(\theta) & \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(2)
\end{align}
The above is the key ingredient in the solving process. So the question is, how to determine the function $L(\theta)$? Since the above two equations are the same, except that the second equation is multiplied by $L(\theta)$, we can expand the second equation and divide by $L(\theta)$ to get the first equation. Expanding the second equation, we get that 
\begin{align}
L(\theta) \frac{d R(\theta)}{d \theta} + \frac{d L(\theta)}{d \theta} R(\theta) & = L(\theta) N(\theta) & (3)
\end{align}
Dividing the third equation by $L(\theta)$, we get that
\begin{align}
\frac{d R(\theta)}{d \theta} + \frac{\frac{d L(\theta)}{d \theta}}{L(\theta)} R(\theta) & =  N(\theta) & \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(4)
\end{align}
Comparing this with the first equation, if we set $$\frac{\frac{d L(\theta)}{d \theta}}{L(\theta)} = M(\theta)$$
then the solution to the first and second equation will be the same. Hence, we need to find $L(\theta)$ such that $$\frac{dL(\theta)}{d \theta} = M(\theta) L(\theta).$$ Note that $\displaystyle L(\theta) = \exp \left(\int_0^{\theta} M(t)dt \right)$ will do the job and this is termed the integrating factor.
Hence, once we the first equation in the form of the second equation, we can then integrate out directly to get $$ L(\theta) R(\theta) = \int_{\theta_0}^{\theta} L(t) N(t) dt + C$$ and thereby conclude that $$R(\theta) = \dfrac{\displaystyle \int_{\theta_0}^{\theta} L(t) N(t) dt}{L(\theta)} + \frac{C}{L(\theta)}$$
where the function $\displaystyle L(\theta) = \exp \left(\int_0^{\theta} M(t)dt \right)$ and $C$ is a constant.
