Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: with machine-precision input
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Bill Rowe

Posts: 1,647
Registered: 3/14/08
Re: with machine-precision input
Posted: Oct 16, 2012 3:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 10/14/12 at 11:40 PM, fateman@cs.berkeley.edu (Richard Fateman)
wrote:

>try this on Mathematica 8:

>q = 429515858585961022071539/6922263581864661506963;

>Note that q was chosen so that
>Rationalize[N[q,45],0] == q.


Not here:

In[1]:= q = 429515858585961022071539/6922263581864661506963;
Rationalize[N[q, 45], 0] == q

Out[2]= False

but

In[4]:= Rationalize[N[q, 45]] == q

Out[4]= True

>Peculiarly, then SetPrecision[N[q,45],100]-N[q,100] is not zero but
>about -3.9E-59


Why would you expect this to be zero? Per the documentation:

SetPrecision will first expose any hidden extra digits in the
internal binary representation of a number, and, only after
these are exhausted, add trailing zeros.

So unless q can be exactly expressed with 45 digits there will
be a non-zero difference. Here:

In[4]:= SetPrecision[N[q, 45], 100] - N[q, 100]

Out[4]= 3.3475286706596422492*10^-78

but note:

In[5]:= SetPrecision[N[q, 45], 100] - N[q, 45]

Out[5]= 0.*10^-44

as it should.

And here is:

In[6]:= $Version

Out[6]= 8.0 for Mac OS X x86 (64-bit) (October 5, 2011)





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.