When $x<0, \quad \int \frac{1}{x}\,dx = \ln (-x) + \text{const.}$

Mathematica calculates this

Assuming[x < 0, Integrate[1/x, x]]



(It's understood that Mathematica drops the constant, okay, but the argument for the logarithm should be positive!

Any ideas?

  • 2
    $\begingroup$ What really matters in practical calculations is the integral, not the antiderivative. $\endgroup$
    – yarchik
    Aug 12, 2021 at 23:42
  • 7
    $\begingroup$ This has been asked before, I believe. Log[x] is the complex logarithm (with a certain standard branch cut, namely, the negative real axis) whose derivative is 1/x except technically along the branch cut though one can pick a different branch cut*, Abs[] is the complex absolute value, and Log[Abs[x]] is not complex-differentiable (so it cannot be the antiderivative). *In any case, the different branches differ by a constant; as a general antiderivative therefore, it can be adapted to particular cases. $\endgroup$
    – Michael E2
    Aug 12, 2021 at 23:44
  • 2
    $\begingroup$ also just to address the notion that it should be positive: the argument to the logarithm does not need to be positive, as with $x>0$, $\log(-x) = \log(x) + i\pi$ under Mathematica's chosen branch cut; this can be confusing if you haven't seen the complex logarithm before. but note that if $x,y>0$, and we integrate from $-y$ to $-x$, $\log(-x) - \log(-y) = \log(x) + i\pi - (\log(y) + i\pi) = \log(x) - \log(y)$, so everything works out! $\endgroup$
    – thorimur
    Aug 13, 2021 at 0:09
  • 3
    $\begingroup$ @yarchik, hahaha! The indefinite integral does not matter! Tell that to all the Calculus I teachers out there! $\endgroup$
    – mjw
    Aug 13, 2021 at 1:25
  • $\begingroup$ Okay, so since $\log x = \log(-x)+\text{const}$, Mathematica is returning the correct answer, up to a constant. Thanks to everybody for the explanations! $\endgroup$
    – mjw
    Aug 13, 2021 at 1:35


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.