What is $e^{-\int \tan(t)dt}$? I know that $-\int \tan(t)dt$ = $\ln |\cos t|$ (letting $C=0$). So I would think that $e^{-\int \tan(t)dt}$ would be equal to $e^{\ln |\cos t|} = |\cos t|$. However, my math textbook and Wolfram Alpha both say that $e^{-\int \tan(t)dt}=e^{\ln (\cos t)} = \cos t$. Why can the absolute value be ignored when taking the indefinite integral in this case?
Context: Finding an integrating factor for $x' = x\tan(t) + \sin(t)$. But Wolfram Alpha also gave me this answer without any differential equations context.
 A: This is very subtle!!!!
To see what's actually going on, you need to consider first, something you may not have noticed about indefinite integrals. What this arises from is a rather base mistake that seems to be perpetuated in a lot of textbooks, in particular, that ...
$$\int \frac{1}{x} dx = \ln |x| + C$$
or more generally, that
$$\int f(x) dx = F(x) + C$$
This is NOT true, or more accurately, it is not general enough. It is only valid when $f$ is defined and continuous on a connected domain . Otherwise, if the domain is disconnected, that is, it is, say, a union $\mathrm{dom}(f) = I_1 \cup I_2 \cup \cdots \cup I_n$ of pairwise disjoint open intervals $I_n$, then the function has "separate individual pieces" and you can translate those individually by their own constants $C_j$ and you will still have an antiderivative on the full, disconnected domain: the trick is that adding a constant doesn't change the derivative, but adding two separate constants on two intervals for a connected domain will make it non-differentiable at a point if it introduces a break , but if there  is a disconnected domain there is already a "break" in a sense and we can add different constants with no harm and no foul. In particular, if $\mathrm{dom}(f)$ has connected components $K_1, K_2, \cdots, K_n$ then
$$\int f(x) dx = F(x) + S(x)$$
where $S(x)$ is a piecewise-constant function defined on each piece of the domain:
$$S(x) = \begin{cases} C_1,\ x \in K_1\\
C_2,\ x \in K_2\\
\cdots\\
C_n,\ x \in K_n
\end{cases}$$
Thus for $\int \frac{1}{x} dx$ we should really have
$$\int \frac{1}{x} dx = \ln |x| + \begin{cases}C_1,\ x \in (-\infty, 0)\\
C_2,\ x \in (0, \infty)\end{cases}$$
because the standard domain $\mathrm{dom}\left(x \mapsto \frac{1}{x}\right) = (-\infty, 0) \cup (0, \infty)$, with two connected components $(-\infty, 0)$ and $(0, \infty)$.
So with that in mind, let's think about $\tan(x)$. The function $\tan(x)$ has a domain that excludes every odd integer multiple of $\frac{\pi}{2}$: that is, $\mathrm{dom}(\tan) = \mathbb{R} \setminus \left\{ \left(n+\frac{1}{2}\right)\pi, n \in \mathbb{Z} \right\}$. This domain can also be written as
$$\mathrm{dom}(\tan) = \bigcup_{n=-\infty}^{\infty} \left(\left(n-\frac{1}{2}\right)\pi, \left(n+\frac{1}{2}\right)\pi\right)$$
thus having infinitely many connected components, namely the intervals $K_n = \left(\left(n-\frac{1}{2}\right)\pi,\left(n+\frac{1}{2}\right)\pi\right)$ for every integer $n$. Thus we can associate an independent constant $C_n$ to each such interval for every such integer.
So what's up with $\ln \cos t$ and $\ln |\cos t|$? Well, the final piece of the answer involves complex numbers. It turns out you can take a logarithm of a negative number, thus you don't strictly need the absolute value signs; rather, your logarithm will simply be a complex number. In particular, for any real number $x < 0$, we have
$$\ln x = \ln(-x) + (2k+1)\pi i,\ k \in \mathbb{Z}$$
which as we see is ambiguous -- $\ln$ when extended this way is a "multi-valued function" (misnomer) or better "multi-valued association", much like the inverse trig, square root ($\pm$ square roots), etc. . (In fact, its multivaluedness is directly connected to that of the inverse trig "functions" by Euler's formula.) Of course now, just as how with those we have conventional "defaults" for what value to use, there is also a conventional "default" for this too and that is to take $k = 0$, giving
$$\ln x = \ln(-x) + i \pi = \ln |x| + i \pi$$.
called the "principal value" or "principal branch". Thus $\ln \cos x$ is a function which is real-valued when $\cos x$ is positive, and complex valued when $\cos x$ is negative, and undefined when $\cos x$ is 0. Furthermore, when it is complex valued, it is a constant shift of the absolute value function. That is, taking $\ln \cos x$ as antiderivative is equivalent to taking $\ln |\cos x|$ but with the function $S(x)$ such that it equals 0 on each interval where $\cos x$ is positive, and equals $i \pi$ on each interval where $\cos x$ is negative. If we take that $S(x)$, then we do indeed get $\ln \cos x$ as a valid antiderivative everywhere, AND furthermore we get the much nicer to work with integrating factor
$$e^{\ln \cos x} = \cos x$$.
Sweet :)
A: (integrating factor : $ \mu (t)$)
Then 
$\ln \left | \mu (t) \right | = -  \int \tan(t)dt = \ln \left | \cos t \right |$
so $|\mu (t)| =|\cos t|$
It means $\mu (t) =\pm \cos t$
But $ \mu (t)$  should be differentiable. (When $\cos t \neq  0$) 
so 
Case 1: $\mu (t) = \cos t $ $(t \in R)$
or
Case2: $\mu (t) = - \cos t$ $(t \in R)$
A solution is $x = \frac{\int \mu (t) \sin (t) dt}{\mu (t)} + \frac{C}{\mu (t)}  = \mathbf{\frac{-\cos 2t +4C}{4\cos t}}$ ($C$ is constant) in both cases.
So, It is not important if $\mu (t) = \cos t $  or $\mu (t) = - \cos t$ 
A: Your question is "Why can the absolute value be ignored?"
We have
\begin{eqnarray} e^{-\int\tan t\,dt}&=&e^{\ln\vert\cos(t)\vert+c_1}\\
&=&e^{c_1}\vert\cos(t)\vert
\end{eqnarray}
But $e^{c_1}>0$ for all values of $c_1$ and $\vert\cos(t)\vert\ge0$ when in fact solutions such as $-\cos(t)$ also exist. But the formulation $y=e^{c_1}\vert\cos(t)\vert$ excludes those solutions.
We can solve the dilemma by getting rid of the absolute value sign and replacing the positive constant $e^{c_1}$ by a constant $C$ which can take on values less than or equal to $0$. So we write
$$  y=C\cdot\cos(t)$$
Keep in mind that Wolfram also assumes that complex solutions are allowed.
