MathGroup Archive 2006

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

Search the Archive

Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64173] Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 3 Feb 2006 01:58:20 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <200601251345.IAA25867@smc.vnet.net> <dra3g3$m55$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <dra3g3$m55$1 at smc.vnet.net>,
 Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:

> A partial explanation is given in the documentation for Equal:
> 
> "Approximate numbers are considered equal if they differ in at most  
> their last eight binary digits (roughly their last two decimal digits)."

There is a subtlety here: clearly

  RealDigits[1.101`2, 2]

and

  RealDigits[1`2, 2]

do differ in their "last eight" binary digits (actually, in both cases 
there are only seven binary digits). The sublety is that all following 
(suppressed) binary digits are 0.

> The workaround is never to set anything to have so few digits of  
> precision; there is no reason at all to do so. Mathematica's  
> "significance" arithmetic is an approximation to true interval  
> arithmetic that works well only at high precision.

But if the application is fixed precision arithmetic then one could use 
RealDigits (in base 2 or 10). For example,

  RealDigits[1.101`2, 2] == RealDigits[1`2, 2]

  RealDigits[1.101`2] == RealDigits[1`2]

> If you only wanted to reduce the number of digits displayed you  
> should use
> 
> NumberForm[1.101, 2]

Or set the PrintPrecision options using the Option Inspector.

Cheers,
Paul

_______________________________________________________________________
Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Package for calling IMSL and/or NAG Fortran routines
  • Next by Date: Re: Recommended learning exercises for beginners?
  • Previous by thread: Re: Package for calling IMSL and/or NAG Fortran routines
  • Next by thread: Re: Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?