Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Relational operators on intervals: bug?
Replies: 21   Last Post: Nov 17, 2012 3:51 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andrzej Kozlowski

Posts: 226
Registered: 1/29/05
Re: Relational operators on intervals: bug?
Posted: Nov 16, 2012 2:14 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


On 15 Nov 2012, at 17:14, Murray Eisenberg <murray@math.umass.edu> wrote:

> On Nov 15, 2012, at 4:45 AM, Andrzej Kozlowski <akozlowski@gmail.com> wrote:
>>
>> On 15 Nov 2012, at 09:57, Andrzej Kozlowski <akozlowski@gmail.com> wrote:

>>>
>>> On 14 Nov 2012, at 22:01, Murray Eisenberg <murray@math.umass.edu> wrote:
>>>

>>>> On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozlowski@gmail.com> wrote:
>>>>

>>>>>
>>>>> On 14 Nov 2012, at 07:28, Richard Fateman <fateman@cs.berkeley.edu> wrote:
>>>>>

>>>>>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>>>>>

>>>>>>>
>>>>>>> Here is the empty interval in Mathematica:
>>>>>>>
>>>>>>> Interval[{1, 0}]
>>>>>>>
>>>>>>> Indeed:
>>>>>>>
>>>>>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>>>>>> False
>>>>>>>

>>>>>> Apparently this doesn't mean what you think it does. It gives the same
>>>>>> answer for Interval[{0,1}].

>>>>>
>>>>> Of course that is because
>>>>>
>>>>> IntervalMemberQ[Interval[{0, 1}], x]
>>>>>
>>>>> False

>>>>
>>>> What remains surprising to me is:
>>>>
>>>> Resolve[Exists[x, x \[Element] Reals, IntervalMemberQ[Interval[{0, 1}], x]]]
>>>> False
>>>>

>>>
>>> I don't find it surprising.
>>> All you are doing is, evaluating Exists[x,Element[x,Reals],False] which is False and then Resolve[False] which is also False.The fact that IntervalMemberQ[Interval[{0, 1}], x] immediately evaluates to False (unlike, for example, 0<x<1, which evaluates to itself) is responsible for this and shows that IntervalMemberQ is not intended to be used in symbolic expressions. Compare this with
>>>
>>> Resolve[Exists[x, x \[Element] Reals, 0 < x < 1]]
>>>
>>> True
>>>

>> Maybe the following example will make my point clearer.
>>
>> Compare:
>>
>> Resolve[Exists[x, Element[x, Primes]]]
>>
>> True
>>
>> with
>>
>> Resolve[Exists[x, PrimeQ[x]]]
>>
>> False
>>
>> Mathematica `predicates (functions ending with Q) always evaluate immediately to True or False and thus are generally unsuitable for use

in symbolic expressions of the above kind.
>
> OK, that provides an explanation of sorts. In fact, the documentation of PrimeQ makes the distinction in saying, "Simplify[expr\[Element]Primes] can be used to try to determine whether a symbolic expression is mathematically a prime."
>
> But the documentation for IntervalMemberQ does not say any such thing. Moreover, one might be misled into thinking
>
> Simplify[0.5 \[Element] Interval[{0, 1}]]
>
> should return True, but it returns 0.5 \[Element] Interval[{0, 1}] instead.
>
> Is the general rule about functions whose names end with Q documented somewhere?
>
> ---
> Murray Eisenberg murray@math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2838 (W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305
>


I don't know if this principle is stated in the documentation in full generality but note that all the predicates (functions whose names end in Q) are defined by using the expression:

=85 gives True if =85. and False otherwise.

Also, there is no reason at all to try to use ELement to test for interval membership. The language of Mathematica is a formal language and however intuitive it may seem (it does seem so to me) the basic principle of such a language is "everything is forbidden unless explicitly allowed" rather than the opposite. There is nothing in the documentation for Element stating that you can use it with anything but domains and Interval[=85] is certainly not a domain.

Andrzej Kozlowski











Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.