The Absolute Value in the Integral of $1/x$

For $x$ positive: $ \frac{d}{dx}\ln{x}=\frac{1}{x} $

For $x$ negative: $ \frac{d}{dx}\ln{(-x)}=\frac{-1}{-x}=\frac{1}{x} $

So when you're integrating $\frac{1}{x}$, if $x$ is positive you'll get $\ln{x}+C$, and if $x$ is negative you'll get $\ln{(-x)}+C$. To summarize $\ln{|x|} + C$.

And if you want to know $\int\frac{1}{x}dx$ is not exactly equal to $\ln|x|+C$. The constants could be different for positive or negative $x$.

$$ \int\frac{1}{x}dx = \begin{cases} \ln{x} + C_1 \qquad \text{for $x$ positive} \\ \ln{(-x)} + C_2 \qquad \text{for $x$ negative} \end{cases} $$


$\int_{-2}^{-1}\frac{1}{x}dx$ has a value, however $\ln(-1)$ and $\ln(-2)$ will be more complicated to evaluate since $\ln(x)$ is only defined on $\mathbb{R}$ for positive numbers... Actually since $\frac{1}{x} = -\frac{1}{-x}$ for every $x$, we have $$\ln(|-1|)-\ln(|-2|)=\int_{-2}^{-1}\frac{1}{x}dx=\int_2^1\frac{1}{x}dx = \ln(1)-\ln(2) = \ln\left(\frac{1}{2}\right)<0.$$


Your range of integration can't include zero, or the integral will be undefined by most of the standard ways of defining integrals. So we have to think of a range of integration which is strictly positive, or strictly negative.

What you wrote is perfectly valid for strictly positive x, so let's think about strictly negative x. We have

$\int_{-a}^{-b}\frac{1}{x}d x$

where $a>0$ and $b>0$, so the range of integration is strictly negative. Do a change of variables, $y=-x$. Then

$\int_{a}^{b}\frac{1}{y}d y$.

(There is a negative from the $y$ in the denominator, and $d x=-d y$, so the two negatives cancel.) We have converted the integral of $1/x$ over a strictly negative range to an integral of $1/y$ over a strictly positive range. The answer is $\ln b-\ln a$. Since the $y$ is just a variable of integration, we can replace it with $x$ if we like, and

$\int_{-a}^{-b}\frac{1}{x}d x=\int_{a}^{b}\frac{1}{x}d x$.

That's the definite integral; the analogous result for the indefinite integral is

$\int^{-x}\frac{1}{x}d x=\int^{x}\frac{1}{x}d x$ (to within a constant of integration).