Re: Zero does not equal Zero
- To: mathgroup at smc.vnet.net
- Subject: [mg31435] Re: Zero does not equal Zero
- From: Leszek Sczaniecki <lsczan at home.com>
- Date: Mon, 5 Nov 2001 03:48:18 -0500 (EST)
- References: <9rlt9k$o10$1@smc.vnet.net> <9s0h9c$n68$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mark Sofroniou wrote: > You can't use Equal or SameQ for you wants because they have a built in > tolerance that is larger than the difference you are seeking. > Hi Mark, Would you please elaborate on these build-in tolerances in the context of the following example? In[1]:= ?$MachineEpsilon $MachineEpsilon gives the smallest machine-precision number which can be added to 1.0 to give a result that is distinguishable from 1.0. In[2]:= a = 1.0; b = 1.0 + $MachineEpsilon; c = 1.0 + 2*$MachineEpsilon; d = 1.0 + 64*$MachineEpsilon; In[6]:= {a === b, b === c , a === c, a === d} Out[6]= {True,True,False,False} In[7]:= {a == b, b == c , a == c, a == d} Out[7]= {True,True,True,True} In[8]:= Map[FullForm, {a, b, c, d}] Out[8]= {1.`,1.0000000000000002`,1.0000000000000004`,1.0000000000000142`} In[9]:= Map[Precision,{a, b, c, d}] Out[9]= {16,16,16,16} In[10]:= Map[Accuracy, {a, b, c, d}] Out[10]= {16,16,16,16} The reason for this inquiry is that a naive user like myself would expect these results. Out[6]= {False,False,False,False} Out[7]= {True,True,False,False} Thank you, Leszek Sczaniecki PS I am using Mathematica 4.1 for Microsoft Windows (November 2, 2000) > > [text deleted] > > Mark Sofroniou > Wolfram Research