MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: confused about == vs === in this equality

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103825] Re: confused about == vs === in this equality
  • From: "Drago Ganic" <dganic at vodatel.net>
  • Date: Thu, 8 Oct 2009 07:50:29 -0400 (EDT)
  • References: <20091003104738.LCJ3I.416659.imail@eastrmwml34> <200910040935.FAA07794@smc.vnet.net> <hacmoa$sko$1@smc.vnet.net>

Hi Andrzej,
there is one function (Missing) and one symbol (Null) which >>should<< 
behave the same as Indetereminate and ComplexInfinity but unfortunatly does 
not.

In[1]:= Null == Null
Out[1]= True

In[2]:= Missing[] == Missing[]
Out[2]= True

Null is Mathematica legacy which has basically the same meaning as Missing[] 
(or maybe Missing["Nonexistent"]). Missing incorporates Indetereminate via 
Missing["Indeterminate"].
All of those (Indetereminate & ComplexInfinity for numeric data and 
Null/Missing for any kind of data), are so called "null values" in database 
systems and for them the Equal and other logical connectivities (And, Or, 
Not, etc.) are overloaded. Unfortunatly this is not the case in Mathematica.

Greetings from Croatia,
Drago Ganic

"Andrzej Kozlowski" <akoz at mimuw.edu.pl> wrote in message 
news:hacmoa$sko$1 at smc.vnet.net...
>I amy be taking a bit of a risk here, but I would guess that
> ComplexInfinity and Indeterminate are the only symbols in Mathematica
> with this property, that is we get:
>
> a=ComplexInfinity
>
> TrueQ[Unevaluated[x == x] /. x -> a]
>
> False
>
>  a = Indeterminate;
>
> TrueQ[Unevaluated[x == x] /. x -> a]
>
>  False
>
> I believe that there are no other symbols for which this happens (?)
> (If I am right and it is the only one that there is no need to be
> seriously concerned or, as you say, "careful" about this issue.)
>
> Why does and Indeterminate and ComplexInfinity behave in this way? Of
> course this is a matter of design and not (for example) mathematics so
> the question really is, is this a reasonable and useful thing rather
> than if it is right. I guess it is pretty clear that since
> Indeterminate refers to a magnitude that cannot be determined, you
> would not really want to assert that two expressions, both of which
> evaluate to Indeterminate, are in any sense equal. For example it
> would seem very strange if
>
> Infinity - Infinity == Infinity/Infinity
>
> returned True (as would have to be the case if
> Indeterminate==Indeterminate returned True). Similar considerations
> perhaps apply to ComplexInfinity, which refers to a complex quantity
> with infinite magnitude but with an indeterminate argument. (However,
> I am less convinced of that in the case of ComplexInfinty than in the
> case of Indeterminate, because ComplexInfinity has a natural
> interpretation as a unique point on the Riemann sphere).
>
> (Of course === asks quite a different question and there is no doubt
> that when you have identical expressions on both sides of === the
> answer should always be True.)
>
> Andrzej Kozlowski
>
>
>
>
>
>
> On 4 Oct 2009, at 18:35, Nasser Abbasi wrote:
>
>> ?===
>> lhs===rhs yields True if the expression lhs is identical to rhs, and
>> yields
>> False otherwise.
>>
>> ?==
>> lhs==rhs returns True if lhs and rhs are identical.
>>
>> But looking at this example:
>>
>> a = ComplexInfinity;
>> If[a == ComplexInfinity, Print["YES"]]
>>
>> Expecting it would print "YES", but it does not. it just returns the
>> whole
>> thing unevaluated? But
>>
>> If[a === ComplexInfinity, Print["YES"]]
>>
>> does return YES.
>>
>> I guess I am a little confused about the "expression" bit in the
>> definition.
>>
>> So, when using the 3"=", it is looking at the _value_ of the
>> expression, but
>> when using the 2"=", it is looking at the expression _as it is_, i.e.
>> without evaluating it?  Is this the difference?  I've always used
>> the 2"="
>> for equality, now I have to be more careful which to use.
>>
>> --Nasser
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 4478 (20091003) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>
> 



  • Prev by Date: Re: Graphics3D Problem
  • Next by Date: Re: Limiting the number of messages
  • Previous by thread: Re: How to obtain FrameTicks List from an existing Plot?
  • Next by thread: Re: Re: confused about == vs === in this equality