# Trying to recreate a solution - ODE

I'm trying to copy the method from this video https://www.youtube.com/watch?v=FTHLz2vgj2I

to solve the following differential equation: $\frac{dr}{d\theta}+r\tan \theta=\frac{1}{\cos \theta}$

Basically what the video uploader did:

He had a differential equation, he brought it to the form $y'+P(x)y=Q(x)$ and the then said:

$$u=e^{\int P(x)dx}, (uy)'=uQ$$

And then he solved for $y$.

I tried to recreate that solution with my question.

$u=e^{\int P(x)dx}=e^{\int \tan \theta d\theta}=e^{-\ln( \cos \theta)}=\frac{1}{\cos \theta}$

$$\frac {d(ur)}{d\theta}=\frac{d(\frac{r}{\cos \theta})}{d\theta}=\frac{r'\cos \theta+r\sin \theta}{\cos^2 \theta}=\frac{1}{\cos ^2 \theta}$$

this implies that $r' \cos \theta+r\sin \theta=1$, which is the exact same ODE that I was asked to solve...So the method in the video did not work here, why?

The method works, you just have to integrate it up. If $$\frac{d(r/\cos\theta)}{d\theta} = \frac{1}{\cos^2\theta}$$
$$\frac{r}{\cos\theta} = \int\frac{d\theta}{\cos^2\theta}$$
Solve the integral (remember to include the integration constant) and you get the solution. This integral is well known, but if you don't know it try to compute $\frac{d\tan\theta}{d\theta}$ and compare. In the end if you do everything correctly you should get an answer on the form $r = A\cos\theta + B\sin\theta$.