Is $e^{\int \frac {1}{x}dx}$ equal to $x$ or $|x|$?

Simple answer

The correct expression is $|x|$. The antiderivative of $\frac1x$ is $\log |x|$, which can be verified by computing the derivative of $\log |x|$ in the region $x>0$ and $x<0$ separately.

Correct answer

Neither is correct; the correct answer is $C|x|$, for some $C>0$, because you need to remember the constant! $$ e^{\int \frac1x\,dx}=e^{\log|x|+K}=e^K|x|:= C|x|. $$

Super nitpicky correct answer

Actually, integrating $\frac1x$ requires two constants; one in the $x>0$ region, one in the $x<0$ region. You can verify that for any $K_1,K_2$, the following piecewise function is an antiderivative of $1/x$: $$ f(x)=\begin{cases} \log|x|+K_1 & x>0\\ \log|x|+K_2 & x<0 \end{cases} $$ This is the full answer, because every antiderivative does have this form. Therefore, $$ e^{\int\frac1x\,dx}=\begin{cases} C_1|x| & x>0\\ C_2|x| & x<0 \end{cases} $$ where $C_1,C_2>0$.


The general antiderivative is as described in the answer by Mike Earnest.

But in the context of ODEs, where you're going to multiply both sides of the equation by the integrating factor, you can just multiply by $x$ instead of $|x|$, since if $x<0$ the only thing that would be different is a factor of $-1$ one both sides, which doesn't make any difference as far as the ODE is concernced. (And for the same reason, you don't gain any generality by multiplying by the most general antiderivative $C_{1,2}|x|$.)