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


Solution 1:

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.

Solution 2:

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.

Solution 3:

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

Solution 4:

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.