Does $x>0$ imply that $x\in\mathbb{R}$?

15

2

Let’s assume I input

Assuming[x > 0, expression]

Is it assumed by Mathematica that $x$ is a real number? Or that the real part of $x$ is positive? Something else?

A simple Mathematica illustration would be welcome.

max

Posted 2012-03-26T08:43:07.383

Reputation: 1 515

Are you trying to declare that your x inside your function is greater than zero (i.e., $x \in \mathbb{N}$)? – night owl – 2012-03-26T08:57:20.677

That's a general question. If you do not say anything more than $x>0$ to Mathematica, what does it understand? – max – 2012-03-26T09:03:00.180

Answers

21

The most direct way to test this is probably the following:

$Assumptions = x > 0;
Element[x, Reals] // Simplify
(* Out[1]= True *)

$Assumptions = True;
Element[x, Reals] // Simplify
(* Out[4]= x ∈ Reals *)

So $x>0$ seems to imply that $x$ is real.

sebhofer

Posted 2012-03-26T08:43:07.383

Reputation: 2 601

3@max, that's because TrueQ[x > 0] immediately evaluates to False, since x > 0 does not evaluate to True at once. – J. M.'s ennui – 2012-07-05T08:33:55.547

10

The documentation for Simplify states "Quantities that appear algebraically in inequalities are always assumed to be real."

– Andrew – 2012-03-26T12:21:51.120

Ok, so it is obviously true for Simplify. The question is, is it true for everything else? I still think the answer is generally yes, but there might be some exceptions (and bugs) of course... – sebhofer – 2012-03-26T12:37:19.290

1Assuming[x>0,TrueQ[x>0]] does reply False ... I don't understand that. – max – 2012-03-26T22:37:25.527

17

It is assumed that $x$ is a real number. Everything else would mathematically not make sense because on complex numbers there does not exist an ordering relation.

An example would be to take the expression $\sqrt{x^2}$ and to imagine that this is not equal $x$ for $x=-\mathbb{i}$. Therefore the expression is in a general form not simplified

In[37]:= Sqrt[x^2]

(* Out[37]= Sqrt[x^2] *)

If you now say that $x \geq 0$ should hold you get

In[33]:= Assuming[x >= 0, Refine[Sqrt[x^2]]]

(* Out[33]= x *)

Note that if $x \geq 0$ would mean the real part is non-negative, the value $x=-\mathbb{i}$ would still be possible. Therefore, it can be assumed, that using an ordering does automatically force the variable to be real.

halirutan

Posted 2012-03-26T08:43:07.383

Reputation: 109 574

8

In general the situation is much more subtle than the other answers suggest. For example this issue is present in version 8 while not in version 7 :

Integrate[ Exp[-a^2] Sin[2 t] (a^2 + b^2 + b*Cos[t] + a*Sin[t]), {t, 0, 2 Pi}]
$Assumptions = {x > 0};
Integrate[ Exp[-a^2] Sin[2 t] (a^2 + b^2 + b*Cos[t] + a*Sin[t]), {t, 0, 2 Pi}]
0
8/3 Sqrt[a^2 + b^2] E^-a^2

The identical integrand (not depending on x) yields different results if we assume x > 0. This bug may appear in different cases when we deal with complex variables.

One may encounter certain inconsequences working with these examples :

Assuming[ y > 0 && x > 0, 
         Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]                 (* I *)

Assuming[ y > 0 && Element[x, Complexes] && Re[x] > 0, 
          Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]                (* II *)

Assuming[ y > 0 && Element[x, Complexes], 
          Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]                (* III *)

Assuming[ Element[y, Reals] && Element[x, Complexes], 
          Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]                 (* IV *)
2 Log[(x + Sqrt[x^2 + y^2])/y]
2 Log[(x + Sqrt[x^2 + y^2])/y]
ConditionalExpression[2 Log[(x + Sqrt[x^2 + y^2])/y], x > 0]
ConditionalExpression[2 ArcSinh[x/Abs[y]], y != 0 && x >= 0]

For example assuming in (III) weaker conditions we get ConditionalExpression[..., x > 0] while in (II) under a more restrictive condition we get a more general expression.

FunctionExpand[2 ArcSinh[x/Abs[y]], x > 0 && y > 0] // TrigToExp
2 Log[Sqrt[1 + x^2/y^2] + x/y]

Artes

Posted 2012-03-26T08:43:07.383

Reputation: 51 831

In all your examples when have assumed x>0 it is not necessary to assume Element[x,Reals]. In other words, if x>0&&Element[x,Reals] is equivalent to just x>0. This was, I think, the point of the question. – Andrzej Kozlowski – 2012-03-26T10:24:07.337

This should be like you said, but it seems that Mathematica sometimes cannot distinguish differences. I mean it could be nice if Mathematica had returned in the second example that x was implicitly assumed to be real. In that case the difference between the second and the third examples would not be inconvenient. I think it is important to point out when some assumptions are important, becaue that would be really helpful. – Artes – 2012-03-26T10:48:21.033

Your second example is exactly the same as Assuming[y > 0 && Re[x] > 0, Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]. In other words, most of your assumptions are not needed. Your third example is exactly equivalent to Assuming[y > 0, Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]. Again, you have unneeded assumptions. You also seem to be misunderstanding the meaning of Conditional. It means that Mathematica returns an answer which is valid only when the condition is satisfied and may be invalid otherwise. To see the point try Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]. – Andrzej Kozlowski – 2012-03-26T11:08:08.920

I think I missed your point. Sorry. I now think there is actually a bug involved in your second example: Mathematica does assume that x is real even though this assumption is not specified. One can see this by evaluating Assuming[y > 0 && Im[x] != 0, Integrate[1/Sqrt[z^2 + y^2], {z, -x, x}]]. I don't think that in this example Mathematica's behaviour is intentionally misleading. – Andrzej Kozlowski – 2012-03-26T11:20:09.047

@AndrzejKozlowski I find the third example gives a correct result and yes, the assumption Element[y, Reals] is indeed superfluous. I think you really did not understand what I meant. In my third example I have more general assumption but I get more strict result than that in the second one. – Artes – 2012-03-26T12:01:37.537

Yes,I meant the third example. This one, I think, is a bug, not intentional behaviour. – Andrzej Kozlowski – 2012-03-26T12:05:20.767

1@AndrzejKozlowski I could give a more complete explaining of what I meant, but I haven't time right now. I think these examples are good to describe a general statement that M sometimes implicitly assumes variables to be real although we assumed them to be complex. I disagree with that I don't understant ConditionalExpression. – Artes – 2012-03-26T12:12:51.407

4

Mathematica will always assume that all the arguments of an inequality relation are real but there are situations the presence of an inequality will lead to a stronger assumption. This is the case with Reduce. If you evaluate:

Reduce[x^2 + y^2 <= 1, {x, y}]

Mathematica will assume that both x and y are real. If you do not want this assumption you need to tell Reduce explicitly:

Reduce[x^2 + y^2 <= 1, {x, y},Complexes]

Andrzej Kozlowski

Posted 2012-03-26T08:43:07.383

Reputation: 2 684

As you can see in my second example Mathematica implicitly assumes x is real although I assumed x to be complex. I mean it should be ConditionalExpression[2 Log[(x + Sqrt[x^2 + y^2])/y], x > 0] as in the third example. – Artes – 2012-03-26T10:53:12.773

3

The most direct hint that x>0 implies Element[x,Reals] is the following:

Reduce[Element[x, Reals] && x > 0]
(*
==> x > 0
*)

celtschk

Posted 2012-03-26T08:43:07.383

Reputation: 18 543

Really, there is no need for "hints". This is indeed so, full stop. It is to ask people who have programmed these functions and they have already answered such questions in great detail, more then once (on MathGroup). – Andrzej Kozlowski – 2012-03-26T16:45:15.720