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.

  • $\begingroup$ Hint: $e^x$ is positive everywhere so the absolute value cannot be cancelled by any means. Also, the only reason the absolute value is used is to restrict it to the real number line. Technically ln(-1) exists. It's just some complex number. Probably i. I'm not sure. So... all wolfram did was solve it for complex numbers. $\endgroup$ – The Great Duck Jun 3 '17 at 6:42
  • $\begingroup$ $\ln(-1) = i\pi$ for the principal value. $\endgroup$ – The_Sympathizer Jun 3 '17 at 12:09
  • $\begingroup$ How do you know that $-\int \tan(t)dt$ = $\ln |\cos t|$? Everywhere I look shows it without the absolute value. $\endgroup$ – Cye Waldman Jun 4 '17 at 20:44

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 :)

  • $\begingroup$ "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 dom(f)=I1∪I2∪⋯∪In of pairwise disjoint intervals In, then the function has "separate individual pieces" and you can translate those individually by their own constants Cj" I am only going to make one small point. Honestly, seeing an answer like this is quite nice for once. The antiderivative should be continuous if possible.... $\endgroup$ – The Great Duck Jun 3 '17 at 6:14
  • $\begingroup$ If it is not possible due to divergence then I suppose that is unnecessary. Also, that whole statement jogged my memory of an older question of mine relevant to the context. Mind taking a look? math.stackexchange.com/questions/2293819/… $\endgroup$ – The Great Duck Jun 3 '17 at 6:16
  • 1
    $\begingroup$ @TheGreatDuck: The antiderivative is continuous in these cases as the domain is disconnected and it is continuous on each connected component. (This is another subtlety: it does not make sense to talk of, say, $f(x) = \frac{1}{x}$ having domain $\mathbb{R}$ (unless the codomain were something like the projective line), because by definition a function must assign exactly one, thus at least one , member of its codomain to every member of the domain. Such a 'function' would assign nothing to $0$.).) $\endgroup$ – The_Sympathizer Jun 3 '17 at 6:34
  • 2
    $\begingroup$ @TheGreatDuck : Nope, not if you want to be consistent with topological usage, which you should be, imo, otherwise you spoil the unity of math. $\endgroup$ – The_Sympathizer Jun 3 '17 at 6:37
  • 1
    $\begingroup$ @TheGreatDuck: See, e.g. here: books.google.com/… A topology textbook. Pg. 118. It defines continuity between two spaces, no mention of connectedness or anything else like that as a requirement. $\endgroup$ – The_Sympathizer Jun 3 '17 at 6:43

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.


(integrating factor : $ \mu (t)$)


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


Case 1: $\mu (t) = \cos t $ $(t \in R)$


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$

  • 3
    $\begingroup$ $|a|=|b|$ does not imply $a=b$ $\endgroup$ – user5954246 Jun 3 '17 at 4:59
  • $\begingroup$ The only differentiable function $f$ with $|f(x)|=|\cos x|$ is $\cos$. $\endgroup$ – Professor Vector Jun 3 '17 at 5:33
  • 1
    $\begingroup$ $f(x) = -\cos x $ is also differentiable $\endgroup$ – G.H.lee Jun 3 '17 at 5:46
  • $\begingroup$ This may explain in the context of differential equation; but it does not explain why you can take the expression $e^{-\int \tan(x) dx}$ itself to be equal to $\cos x$ as Wolfram does. $\endgroup$ – The_Sympathizer Jun 3 '17 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.