In $\int \frac{1\;dt}{t}=\ln|t|+C$, why do we write $|t|$? $$\int \frac{1\;dt}{t}=\ln|t|+C$$
Why do we write $|t|$?
 A: The function $\frac{1}{t}$ is integrable on any bounded interval $I \subset \mathbb{R}\setminus\{0\},$ i.e. also on for example $(-3,-2).$ However, $\ln t$ is not defined for negative $t$ so the right hand side in the following is undefined:
$$\int_{-3}^{-2} \frac{1}{t} dt = \big[\ln t \big]_{-3}^{-2}.$$
What is then a suitable primitive function for negative values of $t$? Assume that $-\infty < a < b < 0.$ Then, making the substitution $t=-s,$ with $s>0,$ we get
$$
\int_a^b \frac{1}{t} dt
= \int_{-a}^{-b} \frac{1}{-s} (-ds)
= \int_{-a}^{-b} \frac{1}{s} ds
= \big[\ln s \big]_{-a}^{-b}
= \big[\ln (-t) \big]_{a}^{b}
.
$$
Thus, for $t>0$ a primitive function to $\frac{1}{t}$ is given by $\ln t$ while for $t<0$ a primitive function is given by $\ln(-t).$ We can write this as
$$
F(t) = \begin{cases}
\ln t & \text{for $t>0$} \\
\ln(-t) & \text{for $t<0$}
\end{cases}
$$
but we can merge these as $\ln|t|.$
A: let $y=\ln(x)$
Notice that y is only defined for positive x.
$e^y = x$
By implicit differentiation
$e^y\cdot \frac{dy}{dx} = 1$
$\frac{dy}{dx} = e^{-y}$
$\frac{dy}{dx} = \frac{1}{x}$
So we know that ln(x) is an anti-derivative for $\frac{1}{x}$ when x>0. What about when x<0. How do we get an anti-derivative for $\frac{1}{x}$ when $x<0$. We know the answer can't be $\ln(x)$ because $\ln(x)$ is undefined for negative x. Also plotting $\frac{1}{x}$, it's clear an anti-derivative exists for $\frac{1}{x}$ when $x<0$. So there should be an answer.
We can define a new function
$y = \ln(-x)$
Notice that this function is only defined for $x<0$
We can use our previous result to take the derivative here
$\frac{dy}{dx} = \left(\frac{1}{-x}\right)(-1)$
$\frac{dy}{dx} = \frac{1}{x}$
So we know that when $x<0$, $\ln(-x)$ is an anti-derivative of $\frac{1}{x}$
So if we define a function like this:
$f(x) = \begin{cases} \ln(-x), &x<0 \\ \ln(x), &x>0 \end{cases}$,
then it's an anti-derivative for $\frac{1}{x}$ everywhere that $\frac{1}{x}$ is defined.
We can rewrite this function as
$f(x) = \ln|x|$, where $x \ne 0$
A: You want the log function to have, as a domain, all non-zero real numbers.  However, for any real $x, e^x$ is never negative.  Therefore, $\log |x|$ is used instead of $\log x$.  This allows logarithms to be defined for negative numbers.
A: One should better write $$\int \frac{dx}{x}=\ln x, x \ne 0~~~(1)$$for the reality of the integral, instead of $$\int \frac{dx}{x}=\ln |x|~~~(2)$$
Note three situations:
$$I_1=\int_{1}^{2} \frac{dx}{x}=\ln 2$$
$$I_2=\int_{-2}^{-1} \frac{dx}{x}=\ln \frac{-1}{-2}=-\ln 2$$
For,
$$I_3=\int_{-1}^{2} \frac{dx}{x}$$
we cannot use (1) as $0\in(-1,2)$, but (2) will give a real value for $I_3=\ln 2$
In fact if one used (1) for $I_3$, one would get $$I_3=\ln 2 +\ln (-1)=\ln 2+i\pi \implies \Re(I_3)=\ln 2,$$ which is more appropriately called principal value..
A: The natural logarithm function represented by $\ln(x)$ is defined as:
$$f(x)=e^{x}$$
$$\ln(x)=f^{-1}(x)$$

What you notice with the exponential function is that if $x\in\mathbb{R},f:x\in\mathbb{R}$, in other words for any real number $x$ that number exponentiated cannot be negative. When we look at inverse functions in a way we are working backwards from the output to the input of the standard function, and since the above statement is true,it does not make sense for the output of the $\ln$ function to exist in the real domain.

As an example of why we can write it like this lets compare two integrals:
$$\int_{-2}^{-1}\frac 1xdx=\left[\ln|x|\right]_{-2}^{-1}=\ln(1)-\ln(2)=-\ln(2)$$
$$\int_1^2\frac1xdx=\left[\ln|x|\right]_1^2=\ln(2)-\ln(1)=\ln(2)$$
so you can see that the area in the negative domain is the same magnitude but opposite sign to that of the positive domain. This makes sense since:
$$g(t)=\frac1t,g(-t)=-g(t)$$
