# Is mathematica integrating $\frac{1}{x}$ correctly?

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?

• What really matters in practical calculations is the integral, not the antiderivative. Aug 12, 2021 at 23:42
• 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. Aug 12, 2021 at 23:44
• 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! Aug 13, 2021 at 0:09
• @yarchik, hahaha! The indefinite integral does not matter! Tell that to all the Calculus I teachers out there!
– mjw
Aug 13, 2021 at 1: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, 2021 at 1:35