Why do some integrals and derivatives have absolute values? I have noticed that some integrals and derivatives have absolute  value. For example: $$\int\frac 1 x \, dx=\ln|x|+c$$ for $x$ is not equal to zero.
So, the point is why is there the absolute value of $x$?
 A: Simply because taking the derivative of those functions with absolute values will yield the original integrand. 
A: Suppose we know that $\dfrac d {dx}\ln x = \dfrac 1 x,$ and that that of course presupposes that $x$ is positive.
Now suppose we want an antiderivative of $1/x$ on the interval $(-\infty,0)$, i.e. all negative values of $x.$
$$
f'(x) = \frac 1 x, \quad x<0.
$$
For $a<b<0$ we have
$$
\int_a^b \frac 1 x \, dx = f(b) - f(a).
$$
Let $u = -x$, so $du = -dx$. As $x$ goes from $a$ (which is negative) to $b$ (which is negative), then $u$ goes from $-a$ (which is positive) to $-b$ (which is positive), and we have
$$
\int_a^b \frac 1 x \, dx = \int_{-a}^{-b} \frac 1 {(-u)}\, (-du) = \int_{-a}^{-b} \frac 1 u \, du = \ln(-b) - \ln(-a) = \ln|b| - \ln|a|.
$$
Differentiating with respect to $b$ yields
$$
\frac d {db} (\ln |b| - \ln |a|) = \frac d {db} \int_a^b \frac 1 x \, dx = \frac 1 b. 
$$
And this is with $b<0$.
A: Because if $x < 0$, $\log x$ is not defined, so certainly it's derivative it's not equal to $\frac 1x$; on the other hand $\log -x$ works just fine (check it!)
So one should write $\int \frac 1x$ equal to $\log x $ if $x > 0$ and equal to $\log -x$ if $x<0$. We summarize this by putting the absolute value of logarithm, even though in $0$ the function is not defined and not differentiable
A: The antiderivative of $f(x)$ is a function $F(x)$ such that $F'(x)=f(x)$ for all $x$ in the domain of $f$. 
Thus $\ln|x|$ is an antiderivative of $\frac{1}{x}$ because


*

*if $x>0$, $\frac{d}{dx}(\ln|x|)=\frac{d}{dx}(\ln(x))=\frac{1}{x}$

*if $x<0$, $\frac{d}{dx}(\ln|x|)=\frac{d}{dx}(\ln(-x))=\frac{1}{-x} \cdot \frac{d}{dx}(-x)=\frac{1}{-x}\cdot (-1)=\frac{1}{x}.$


It would be wrong to say that $\ln(x)$ is an antiderivative for $\frac{1}{x}$, because it is not defined when $x<0$. Hence $\frac{d}{dx}\ln(x)$ is not defined when $x<0$, so it cannot be equal to $\frac{1}{x}$ (which is defined for $x<0$).
A: Another way to see this is by looking at the graph of $f(x) = \frac 1 x$ which has two, not connected parts, as 0 is not part of the domain. 
The same way but more obviously, the function (with the same domain) and definition:
$ F(x) = lnx + c $ (when x>0), $ ln(-x) + c $ (when x<0)
has two, non connected parts. But we can rewrite it more compactly as $ F(x) = ln |x| + c $.
