Is putting absolute values around the argument of a log obtained through integration incorrect?

I've always been taught that when integrating a function of the form $f'(x)/f(x)$ to put an absolute value around the argument of the resulting logarithm. For example:

$$\int\frac1{x}\mathrm dx = \log{|x|} + c$$

The reason provided was that 'logarithms aren't defined for negative numbers', it seems a bit like cheating to me to just throw absolute values around the argument. Furthermore, I thought of a case where this would actually produce the wrong result;

$$\int_{-1}^1\frac1{x}\mathrm dx = \log|1| - \log|-1| = 0$$

However, the correct way should be this:

$$\int_{-1}^1\frac1{x}\mathrm dx = \log(1) - \log(-1) = 0 - i\pi = -i\pi$$

Edit: I may be wrong, but the integral above, ignoring the singularity (sorry couldn't think of a better example to illustrate my point with -1 and changing it now would make people's answers and comments seem off-topic), should be correct due to Euler's identity:

$e^{i\pi} = -1 \implies \log(-1) = i\pi$

Could someone please provide a better explanation?

Thanks


The function $1/x$ is continuous on $(0,+\infty)$; therefore, it has a primitive, which happens to be $\log x+C$. On the other hand, $1/x$ is also continuous on $(-\infty,0)$, and its primitive is $\log(-x)+C=\log|x|+C$. Putting it all together, $\log|x|+C$ is the primitive of $1/x$ on $\mathbb{R}\setminus\{0\}$.

The definite integral $\int_{-1}^1\frac{dx}{x}$ does not exist neither in the Riemann sense nor in the Lebesgue sense. The Cauchy principal value of the integral is defined as $$ \lim_{\epsilon\to0}\int_{-1}^{-\epsilon}+\int_{\epsilon}^1\frac{dx}{x}. $$


The integral doesn't technically even converge, so no dice. However, for integrals over singular values, you can use the Cauchy principal value:

$$ \int_{-1}^{-\epsilon} \frac{1}{x} dx + \int_{\epsilon}^1 \frac{1}{x} dx $$

as $\epsilon\to 0$. Note that these integrals annihilate each other, meaning they cancel each other out, hence we get a Cauchy p.v. of $0$. Moreover, your integral can't possibly come out to $-i\pi$, because the function $1/x$ is always real for real $x$. When can you sum up real numbers and get an imaginary one?

You can see visually that if the graph of $ \log |x|$ has derivative equal to $1/x$ for positive $x$, it must have the negative of $1/x$ for the derivative at $-x$, hence it makes sense when dealing with real numbers to use $\log |x|$ as the antiderivative of $1/x$.

$\hskip 2.3 in$ enter image description here

In complex analysis, when you integrate not over straight intervals on the real line but arbitrary paths or closed contours in the complex plane, singularities change the behavior of the integrals because the function may have different branches (i.e. it becomes multi-valued, much like $\log z = \log |z| + \arg z + 2 n \pi i, n\in\mathbb{N}$ has an infinte number of values). At that point in time it becomes necessary to address your concerns, but this is a bit deeper and more involved than the real-valued case.


Added in response to the edit.

ignoring the singularity

You cannot ignore the singularity. You are trying to add two infinities, $+\infty+(-\infty)$, expecting to get a finite value. For $-1<c<0$ the integral in $[-1,c[$ is negative and for $0<c<1$ the integral in $]c,1]$ is positive. But in $[-1,0[$ or $]0,1]$ neither is finite.

The graph of the integrand function is

enter image description here


The integral $$\int \frac{1}{x}dx=\log \left\vert x\right\vert +C$$ if and only if $x\neq 0$. My explanation: if $x>0$, then $\frac{d}{dx}\log x=\frac{1}{x}$. If $x<0$, then $$\frac{d}{dx}% \log \left( -x\right) =\frac{1}{x}.$$ So, if $x\neq 0$, then $$\frac{d}{dx}% \log \left\vert x\right\vert =\frac{1}{x}.$$

Splitting your integral as

$$\int_{-1}^{1}\frac{1}{x}dx=\int_{-1}^{0}\frac{1}{x}dx+\int_{0}^{1}\frac{1}{x% }dx,$$

we have two improper integrals of the 2nd kind with a singularity at $x=0$. Since both of them are divergent so is $\int_{-1}^{1}\frac{1}{x}dx$. A direct computation shows that

$$\int_{0}^{1}\frac{1}{x}dx=\lim_{a\rightarrow 0^{+}}\int_{a}^{1}\frac{1}{x}% dx=\lim_{a\rightarrow 0^{+}}\left( -\ln a\right) =\infty ,$$

and

$$\int_{-1}^{0}\frac{1}{x}dx=\lim_{b\rightarrow 0^{-}}\int_{-1}^{b}\frac{1}{x}% dx=\lim_{b\rightarrow 0^{-}}\left( \ln b-i\pi \right) =-\infty .$$