0

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

Mathematica calculates this

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

as

Log[x]

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

Any ideas?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
mjw
  • 2,146
  • 5
  • 13
  • 2
    What really matters in practical calculations is the integral, not the antiderivative. – yarchik Aug 12 '21 at 23:42
  • 7
    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. – Michael E2 Aug 12 '21 at 23:44
  • 2
    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! – thorimur Aug 13 '21 at 00:09
  • 3
    @yarchik, hahaha! The indefinite integral does not matter! Tell that to all the Calculus I teachers out there! – mjw Aug 13 '21 at 01:25
  • 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! – mjw Aug 13 '21 at 01:35
  • Possible duplicates: (51863), (158849) – Michael E2 Aug 13 '21 at 04:01
  • @mjw If you want the constant, you should do: Assuming[x < 0, Integrate[1/x, x, GeneratedParameters -> C]] – flinty Aug 13 '21 at 13:58
  • @flinty, Thank you! – mjw Aug 13 '21 at 15:57
  • What if we want to take another branch cut of the logarithm. How do we do that? – mjw Aug 13 '21 at 15:58
  • "another branch cut" - this answer shows one possibility. – J. M.'s missing motivation Dec 20 '21 at 09:08
  • @J.M., Thank you! – mjw Dec 23 '21 at 17:55

0 Answers0