I encountered this expression quite a lot of times as a part of the integrating factor while solving linear differential equations.

$$e^{\int \frac {1}{x}dx}$$

For sometime, I wrote it as $x$, and was satisfied as even the answer given in my textbook had $x$ instead of $|x|$. But after realising the possibility to be $|x|$, I am confused.

What should be the answer, and why?

Edit: (My reasoning)

$\int \frac {1}{X} dx = log |x|$ and $e^{logt} = t$ if I'm not wrong. So in this case, $t = |x|$ so the answer should be $|x|$.

What is wrong with this reasoning? And could you please provide a mathematical proof if the answer should be $x$?

Edit 2:

Wolfram Alpha evaluates e^(∫(1/x)dx) to $x$

  • $\begingroup$ Where is $x$ (or, more precisely, the antiderivative in the integrand) defined? $\endgroup$
    – anomaly
    Mar 15, 2019 at 0:58
  • $\begingroup$ How do you define $\log$? $\endgroup$ Mar 15, 2019 at 0:59
  • $\begingroup$ @anomaly There were questions of the type $\frac {dy}{dx} + \frac yx = 1$. So $x$ wasn't defined explicitly. $\endgroup$
    – Eagle
    Mar 15, 2019 at 1:04
  • 2
    $\begingroup$ Short answer: $1/x$ blows up at $0$, so $\int_a^b dx/x$ is undefined if $a < 0 < b$. Similarly, $1/x$ doesn't have antiderivative everywhere on $\mathbb{R}$; it has two on $(\infty, 0)$ and $(0, \infty)$, and they can't be patched together across $0$ to give a single continuous function. The function $f(x) = \log x$ does not satisfy $f'(x) = 1/x$ on $x < 0$; it's not even defined (as a real function) there. $\endgroup$
    – anomaly
    Mar 15, 2019 at 1:16
  • 1
    $\begingroup$ The correct expression as pointed out by everyone is indeed $\mid x\mid$. But since you're using it to evaluate linear differential equations, so to simplify things up you may use $\text{I.F.}=x$. $\endgroup$ Mar 15, 2019 at 8:55

2 Answers 2


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$.

  • $\begingroup$ Why exactly do you need two different constants? $\endgroup$
    – clathratus
    Mar 15, 2019 at 1:14
  • $\begingroup$ Thank you for the answer. I understood it, but please look at my new edit because I don't know why but Wolfram Alpha gives the answer as $x$. $\endgroup$
    – Eagle
    Mar 15, 2019 at 1:16
  • $\begingroup$ @clathratus $\int f(x)\,dx$ is defined as the set of functions $F$ for which $F'=f$. When the domain of $f$ has two connected pieces, you can shift $F$ by any constant amount in each and still have $F'=f$. To get all $F$ for which $F'=f$, you therefore need two constants. $\endgroup$ Mar 15, 2019 at 1:23
  • $\begingroup$ @Natasha WA is wrong. WA also says ∫(1/x)dx = log x, but you that that is wrong, right? The problem is that WA assumes log is a complex logarithm and that you are integrating in the complex plane. $\endgroup$ Mar 15, 2019 at 1:26
  • $\begingroup$ Oh okay. Thanks a lot! So I think my book also has the same error in giving the answer as $x$ instead of $|x|$. $\endgroup$
    – Eagle
    Mar 15, 2019 at 1:43

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|$.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .