TITLE: Deciding when to drop the absolute values in differential equation?
QUESTION [6 upvotes]: I am currently solving the following differential equation (link is to another post):
$\dfrac{dr}{d \theta}+r\tan \theta =\frac{1}{\cos \theta}$
The following is in standard form (i.e. $\dfrac{dr}{d\theta}+P(\theta)r=Q(\theta)$). Therefore, I can go and head and solve for the integrating factor:
$\mu(\theta)=e^{\int_{} P(\theta) d\theta}=e^{\int_{} \tan(\theta) d\theta} =e^{-\ln(|\cos(\theta)|)}=|\cos(\theta)|^{-1}$
Multiplying the entire equation by the integration factor allows us to use the "Derivative of a Product" property to yield the following:
$\dfrac{d}{dx}(|\cos(\theta)|^{-1}r)=|\cos(\theta)|^{-1}\sec(\theta)$
Integrating both sides yields a "difficult" integral:
$\int_{} \dfrac{1}{|\cos(\theta)|\cos(\theta)} d\theta$
However, according to solution given here, the absolute value is dropped in the integrating factor (thereby creating an easier problem), meaning $\mu(\theta)=(cos(\theta))^{-1}$. But, why am I allowed to drop the absolute value? Nothing in the problem states the domain of $\theta$ or $r$ and clearly, $|\cos(\theta)|\cos(\theta)\neq \cos^2(\theta)$ for all values of $\theta$.

REPLY [2 votes]: The integrating factor of a differential equation is unique up to a nonzero multiplicative constant.
E.g., the integrating factor of the differential equation $$\dfrac{\mathrm{d}y}{\mathrm{d}x}+g(x)\,y=h(x)$$ is in general $Me^{\int g(x)\,\mathrm{d}x}\,\left(M\neq0\right),$ which attains the solution independently of $M$:
\begin{equation}
\begin{aligned}
\left(Me^{\int g(x)\,\mathrm{d}x}\right)\dfrac{\mathrm{d}y}{\mathrm{d}x}+\left(Me^{\int g(x)\,\mathrm{d}x}\right)g(x)\,y&=\left(Me^{\int g(x)\,\mathrm{d}x}\right)h(x)\\
e^{\int g(x)\,\mathrm{d}x}\dfrac{\mathrm{d}y}{\mathrm{d}x}+e^{\int g(x)\,\mathrm{d}x}g(x)\,y&=e^{\int g(x)\,\mathrm{d}x}h(x)\\
\dfrac{\mathrm{d}}{\mathrm{d}x}\left(e^{\int g(x)\,\mathrm{d}x}\,y\right)&=e^{\int g(x)\,\mathrm{d}x}h(x)\\
y&=\frac1{e^{\int g(x)\,\mathrm{d}x}}\int e^{\int g(x)\,\mathrm{d}x}h(x)\,\mathrm{d}x.
\end{aligned}
\end{equation}
Dropping any external absolute-value symbol (and the constant of integration) from the integrating factor is equivalent to setting $M=1,$ which is the simplest choice of $M$.