# Why $\int \frac{1}{x}$ is $\ln|x| + C$ not $\ln(x) + C$? [duplicate]

I am reading about indefinite integrals and I have a question regarding the use of the modulus in integrating $\frac{1}{x}$.

The book I am reading gives me the following explanation -

The book later gives no further explanation, which has left me confused.

I have found no reasonable explanation online, so I would like to ask why this is the case in integration.

What does the book cite as "difficulties that may arise"?

## marked as duplicate by Jack, Community♦Sep 7 '17 at 13:32

• You can't take the log of a negative number, but $\int_{-2}^{-1} \frac{1}{x} dx = \ln(1)-\ln(2)$ is actually correct. On the other hand even this way of writing it is a bit misleading because it would suggest that $\int_{-1}^2 \frac{1}{x} dx = \ln(2)-\ln(1)$ when in fact this doesn't even exist. – Ian Sep 7 '17 at 13:16
• Well, without the absolute value sign, how would you evaluate $\int_{-2}^{-1}\frac {dx}x$? – lulu Sep 7 '17 at 13:16
• To be entirely correct, you could have a different "constant" for negative and positive $x$. I have never seen an actual textbook require this, though. – Arthur Sep 7 '17 at 13:24
• @Ian understood, many thanks! – vik1245 Sep 7 '17 at 13:44

Hint. The function $1/x$ is integrable on the negative numbers. For example, evaluate $$\int_{-2}^{-1}\frac1x\,\mathrm dx$$
• Your integral is equal to $F(-1)-F(-2)$ for a certain function $F$ but what is it $F$? What does mean $F(-1)$? – Piquito Sep 7 '17 at 13:21
The domain of $\frac1x$ is $\mathbb{R}\setminus\{0\}$. Therefore, the domain of any primitive must also be $\mathbb{R}\setminus\{0\}$. So, the answer could never be $\ln x+C$, since this is definid on $(0,+\infty)$ only.
On the other hand, $$\ln\bigl(|x|\bigr)=\begin{cases}\ln x&\text{ if }x>0\\\ln(-x)&\text{ if }x<0.\end{cases}$$Therefore, if you differentiate it, you get$$\begin{cases}\frac1x&\text{ if }x>0\\\frac{-1}{-x}&\text{ if }x<0\end{cases}=\frac1x.$$