# ln|x| vs. ln(x)? When is the ln antiderivative marked as an absolute value?

One of the answers to the problems I'm doing had straight lines: $$\ln|y^2-25|$$

versus another problem's just now: $$\ln(1+e^r)$$

I know this is probably to do with the absolute value. Is the absolute value marking necessary because #1 was the antiderivative of a squared variable expression that could be either positive or negative (and had to be positive because, well, natural log) and the second was positive by default?

Sorry if this is me asking and answering my own question; I'd just love to get confirmation in case I'm wrong.

-
Unless $r$ is complex, $e^r > 0$. –  vonbrand May 7 at 21:56

This is a rather subtle matter.

First thing is that to make sure we are talking sense, we should talk about antiderivatives on a specific interval. For example, we should not just say "$F(x)$ is an antiderivative of $f(x)$", but something like "$F(x)$ is an antiderivative of $f(x)$ for $1<x<2$".

Now if $x$ takes positive values then the derivative of $\ln x$ is $x^{-1}$. So we can say

$\ln x$ is an antiderivative of $x^{-1}$ for $x>0$.

On the other hand, if $x$ takes negative values then the derivative of $\ln(-x)$ is $x^{-1}$: you can check this by differentiation. So we can say

$\ln(-x)$ is an antiderivative of $x^{-1}$ for $x<0$.

Now if $x$ is positive then $x=|x|$, and if $x$ is negative then $-x=|x|$, so both our logarithm expressions above can be written as $\ln|x|$. We can therefore say

$\ln|x|$ is an antiderivative of $x^{-1}$ on any interval consisting of positive or negative $x$ values.

But. . . the matter starts to get seriously dodgy if we try to include both positive and negative $x$ values at the same time: because then to get an interval of $x$ values we would also have to include $x=0$, and neither $\ln|x|$ nor $x^{-1}$ makes sense if $x=0$.

In my view, writing the antiderivative as $\ln|x|$ is a neat way of summarising two results in one, but it carries a serious risk of disguising what is really going on. So my preference, if I have an integral giving $\ln(\hbox{something})$, is to work out whether the "something" is negative or positive, and put in a minus sign, or not, as appropriate.

-
Thanks @JW, interesting link. I was aware of the issue of having different constants each side of $0$. Was also thinking of asking about $\int_{-1}^1 x^{-1}\,dx$. But I felt that both of these could tend to obscure my main point. –  David May 2 at 10:14
Very nice exposition of the situation (+1). I tried to describe this same situation in this answer. –  robjohn May 2 at 21:32
(For example, we should not just say "F(x) is an antiderivative of f(x)", but something like "F(x) is an antiderivative of f(x) for 1<x<2") - This is a very important point that most people ignore it. I used to ignore this too. (+1) –  math.n00b May 9 at 23:09

Yes you are right $1+e^x$ is positive everywhere, so putting an absolute value would be redundant, but $y^2-25$ is negative if $|y|\lt 5$ so we need the absolute value.

-
I wish I could mark two answers and/or upvote this one too. Thank you very much, that succinctly makes sense of the difference between the problems I was working with! –  Calculistening helplessly May 2 at 8:31
No worries, happy to help, btw you can upvote more than one answer I believe. –  ellya May 2 at 8:37
More precisely, $\:y^2-25\:$ is negative if $\: \left|\hspace{.03 in}y\right|<5 \;$. $\;\;\;\;$ –  Ricky Demer May 2 at 9:23
thankyou, that is what I meant, i will edit. –  ellya May 2 at 9:25

logarithm is a function only defined on domain $(0,\infty)$, so it make no sense to input negative value.

-
Well it's defined on $\mathbb C\backslash \{0\}$. –  Ruslan May 2 at 8:23
Well, if complex variable theory is involved, as long as we take care of the branches for logarithm we can input negative number. But I think the author is confused with the real number case. –  Poor Math Guy May 2 at 8:52
@Ruslan: usually a branch cut is also removed so that the function is differentiable on an open domain. –  robjohn May 2 at 21:34
Thanks for your note, but I think the author is confused with the real number case. So I just make the comment based on real logarithm. –  Poor Math Guy May 3 at 3:27

Just to make explicit what some were saying in the comments, you don't need much sophistication with complex numbers to make sense of this without the absolute value sign. You really only need to know the polar form of complex numbers. We can make use of the fact that we can represent a complex number $a+bi$ as $r e^{i\theta}$, by Euler's formula. The exponential gives a natural definition of $\log$: Given $a+bi=r e^{i\theta}$... $$\log(a+bi)=\log(r e^{i \theta})=\log(e^{\log(r)+i\theta})=\log(r)+i\theta$$

To make this a function in the usual sense, we can restrict $r\ge 0$ and $-\pi\le \theta <\pi$.

Then, $\log(x)$ where $x$ is real is defined as $\log x$ when $x>0$, and $\log |x|-\pi i$ when $x<0$. Differentiating with respect to $x$ in both cases leaves zero imaginary component and the expected result, so then you truly do have $\int \frac{1}{x} dx=\log(x)$.

Also note that when you move from an antiderivative to a definite integral, any constants in your function are subtracted away, so you still don't get a complex result.

-
First of all let us assume that you are dealing with real valued functions on real variables. Then logarithm you are using comes with base Eulers constant e.whose value lies between 2 and 3 $loga=b \rightarrow e^{b}=a$ then naturally logarithm is defined in a domain which is set of positive real numbers. Secondly we cannot define inverse function unless the given function is bijective. If you are using complex valued function I think yopu need not put absolute value sign your function (log) will be a multiple valued function