Deciding when to drop the absolute values in differential equation? 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$.
 A: $|\cos(\theta)|^{-1}$, or for that matter $\int \frac{d\theta}{|\cos\theta|\cos \theta}$, diverges to infinity for $\theta\to\pm\pi/2$ -- so if you're interested only in the connected component of the solution that contains $\theta=0$, it will only be defined on the open interval $(-\pi/2,\pi/2)$ anyway. In this interval $\cos(\theta)$ is always positive, and therefore $|\cos(\theta)|=\cos(\theta)$.
A: \begin{align}&\dfrac{\mathrm{d}y}{\mathrm{d}x}+g(x)\,y=h(x)\tag1\\
\iff{}& 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)\\
\iff{}& \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)\\
\iff{}& y=\frac1{e^{\int g(x)\,\mathrm{d}x}}\int e^{\int g(x)\,\mathrm{d}x}h(x)\,\mathrm{d}x
\end{align}
for $\displaystyle\int g(x)\,\mathrm dx=\ln|f(x)|+C:\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad(2)$
\begin{align}
\iff{}& y=\frac1{e^C|f(x)|}\int e^C|f(x)|h(x)\,\mathrm{d}x\\
\iff{}& y=\begin{cases}\frac1{-f(x)}\int -f(x)h(x)\,\mathrm{d}x, &&x<0; \\
  \frac1{f(x)}\int f(x)h(x)\,\mathrm{d}x,  &&x\ge0 \end{cases} \\
\iff{}& y=\frac1{f(x)}\int f(x)h(x)\,\mathrm{d}x.
\end{align}
Hence, the solution of the ODE (1) is not affected by dropping the absolute-value symbol from (2) inside its integrating factor.
A: The absolute values originate from logarithmic integrals such as 
$$\int\frac{dx}x=\log|x|+C,$$
and often the antilogarithm is taken, giving
$$e^{\log|x|+C}=C'|x|.$$
But $x=0$ corresponds to a singularity and shouldn't be crossed (otherwise the integral is improper). So all $x$'s should have the same sign, so that the correct expressions should be
$$\log x\text{ or }\log(-x)$$
and
$$C'x$$ respectively, where $C'$ can be positive or negative.
And if differentiabiliy is not required at $x=0$, you can have two distinct pieces, 
$$\begin{cases}x<0\to C_-x,\\x>0\to C_+x.\end{cases}$$
