[Date Index]
[Thread Index]
[Author Index]
Re: Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg64182] Re: [mg64173] Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?
*From*: Pratik Desai <pdesai1 at umbc.edu>
*Date*: Sat, 4 Feb 2006 04:13:35 -0500 (EST)
*References*: <200601251345.IAA25867@smc.vnet.net> <dra3g3$m55$1@smc.vnet.net> <200602030658.BAA17085@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Paul Abbott wrote:
>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.
>
>
>
One can check this out using, NumericalMath`ComputerArithmetic`
In[10]:=
<<NumericalMath`ComputerArithmetic`
ComputerNumber[1.101`2]
ComputerNumber[1.2`2]
Out[11]=
0
Out[12]=
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: t-test question**
Next by Date:
**Re: Problem to evaluate a function inside a function**
Previous by thread:
**Re: SetPrecision causes logical comparisons to fail in Mathematica 5.1 on Mac OS X?**
Next by thread:
**question**
| |