Why do the following commands

$Assumptions = {Element[x, Reals], x > 0};
Solve[{x^2 == 1}, {x}]
Solve[{x^2 == -1}, {x}]


(*{{x -> -1}, {x -> 1}}*)
(*{{x -> -I}, {x -> I}}*)

Wouldn't I expect to get only

(*{x -> 1}*)

Furthermore, how can I implement global assumptions that hold for the entire session? I have quite a lot of Simplify[] and they all use the same variables which I want to be real and positive.


closed as off-topic by Bob Hanlon, MarcoB, m_goldberg, Öskå, Michael E2 Aug 12 at 16:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, MarcoB, m_goldberg, Öskå, Michael E2
If this question can be reworded to fit the rules in the help center, please edit the question.


The appropriate command should be :

Solve[x^2 == 1 && x > 0, x, Reals]
Solve[x^2 == -1 && x > 0, x, Reals]

The third argument is the domain specification and the x>0 is an extra constraint you need to specify.

This gives the results {{x -> 1}} and {} respectively.

When Mathematica solves your equation it treats $x$ as a dummy variable and, hence, is ignoring the global assumptions on $x$.

  • $\begingroup$ Thanks! So there is no way to declare x as real and positive for all calculations without having to write it as you wrote it above? $\endgroup$ – xabdax Aug 7 at 21:00
  • 1
    $\begingroup$ @xabdax not while using Solve. You can use global assumptions to simplify other expressions where $x$ is not treated as a dummy variable -- $Assumptions = And[x>0,Element[x,Reals]] should work for those other cases. $\endgroup$ – TheTwistedSector Aug 7 at 21:05
  • 2
    $\begingroup$ x>0 automatically implies x ∈ Reals, so it can be omitted in the assumptions $\endgroup$ – Lukas Lang Aug 7 at 22:12
  • 3
    $\begingroup$ If you evaluate Options[Solve] you will see that the options do not include Assumptions and consequently Solve does not make use of $Assumptions. The assumptions must be included as constraints in the system provided to Solve. Subsequent use of Simplify or FullSimplify would make use of $Assumptions since their options include Assumptions ($Assumptions is the default value for Assumptions). $\endgroup$ – Bob Hanlon Aug 8 at 4:51

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