0
$\begingroup$

There are many questions about assumptions here. Many of them are problem specific. That is why I want to ask a question in the most general way. Why does Mathematica solves this

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

as

Log[x]

and not

-Log[-x]

?

$\endgroup$
1
  • $\begingroup$ I think you mean Log[-x], not -Log[-x]. $\endgroup$
    – Szabolcs
    Commented Feb 6, 2014 at 20:39

1 Answer 1

1
$\begingroup$

-Log[-x] is not a correct result, but Log[-x] is.

In fact the expressions Log[-x] and Log[x] differ only in a constant I Pi, so both are correct antiderivatives for all $x \in \mathbb{C}$.

While the result given by Mathematica is correct, it is complex valued for x < 0. I think you are looking for a real valued result. I do not think it is possible to ask Integrate to automatically provide one.

For definite integrals this won't be a problem though as that complex constant is cancelled:

Integrate[1/x, {x, a, -1}, Assumptions -> a < -1]

(* ==> -Log[-a] *)
$\endgroup$
4
  • $\begingroup$ Yes, you are right about the minus sign, I forgot to move it under dx. However, I have one more question about the different part of your answer. Here (mathematica.stackexchange.com/a/41112/12223) you said "x > 0 is sufficient and (in Mathematica) implies that x is also real". So, does Mathematica assume x to be real or not? $\endgroup$
    – shalabuda
    Commented Feb 7, 2014 at 13:18
  • $\begingroup$ @shalabuda Yes, x<0 is equivalent to x < 0 && Element[x, Reals]. It doesn't influence the result of the integral though. Log[x] is a correct result for all complex (real or not real) x. $\endgroup$
    – Szabolcs
    Commented Feb 7, 2014 at 15:42
  • $\begingroup$ so, why does this Assuming[x \[Element] Reals, Re[Integrate[1/x, x]]] give Re[Log[x]] instead of Log[-x]? (sorry for asking these follow up questions, I'm trying to get an intuition of how Mathematica works) $\endgroup$
    – shalabuda
    Commented Feb 7, 2014 at 16:13
  • $\begingroup$ Well, Re[Log[x]] is a correct answer to the question, right? If you'd like to simplify Re[Log[x]] to Log[-x] with the assumption that x<0, you can use FullSimplify[ComplexExpand@Re[Log[x]], x < 0]. $\endgroup$
    – Szabolcs
    Commented Feb 7, 2014 at 16:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.