MathGroup Archive 2005

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

Search the Archive

Re: inconsistency with Inequality testing and Floor

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59936] Re: [mg59927] inconsistency with Inequality testing and Floor
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 26 Aug 2005 04:53:25 -0400 (EDT)
  • References: <200508251034.GAA10208@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


On Aug 25, 2005, at 6:34 AM, Brett Patterson wrote:

>
> I have observed the following strange behaviour:
>
> ----------------------
> In[1]:=   x = 1.0 - 10^-($MachinePrecision)
>
> Out[1]=   1.
>
> In[2]:=   x >= 1
>
> Out[2]=   True
>
> In[3]:=   Floor[x]
>
> Out[3]=   0
> ----------------------
>
> It seems that the inequality test and Floor use different numerical
> methods.
> I think this behaviour is inconsistent.
> If the test "x >= 1" evaluates to True, then Floor[x] should evaluate
> to 1.
>
> Can anyone shed any light on this?

I think the key is this

In[12]:=
x==1
Out[12]=
True

and the following statement in the explanation of ==:

=E2=97=BC Approximate numbers are considered equal if they differ in at most 
their last eight binary digits (roughly their last two decimal digits).

It seems == converts the exact numeral 1 to a machine approximation 
and compares the binary digits with x.  Looking at the behavior of 
MantissaExponent and RealDigits with respect to x and the exact 
numeral 1:

In[15]:=
RealDigits[x,2,16]
Out[15]=
{{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},1}
In[17]:=
MantissaExponent[x,2]
Out[17]=
{1\/2, 1}
In[18]:=
MantissaExponent[1,2]
Out[18]=
{1\/2, 1}

It looks they are indistinguishable to Mathematica which may explain 
why x==1 evaluates to True.

That's my best guess,

Ssezi



  • Prev by Date: Re: The updated version of Notations Package
  • Next by Date: Re: How to solve this type of equation in Mathematica?
  • Previous by thread: Re: inconsistency with Inequality testing and Floor
  • Next by thread: Re: inconsistency with Inequality testing and Floor