# 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$.

• You can format trig functions like $\cos(\theta)$ or $\tan(\theta)$ or most trig functions, by including immediately before it, a backslash. E.g., \cos(\theta) and \tan(\theta). Similarly, instead of $ln(x)$ we can use a backslash immediately prior to ln, by writing \ln(x). – amWhy Aug 27 '18 at 19:55

$|\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)$.

• +1 Makholm for pointing this out... – LostInSpace Aug 27 '18 at 21:15

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}$$