Deciding when to drop the absolute values in differential equation?

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


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