Re: Re: Beware of adding 0.0
- To: mathgroup at smc.vnet.net
- Subject: [mg50272] Re: [mg50245] Re: Beware of adding 0.0
- From: DrBob <drbob at bigfoot.com>
- Date: Tue, 24 Aug 2004 06:22:07 -0400 (EDT)
- References: <cg4fcn$cf5$1@smc.vnet.net> <cg97i2$a62$1@smc.vnet.net> <200408231034.GAA14593@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
p and q are not the same number. If you wanted them to be the same, you could have entered them the same. Here are their real digits, remainders mod Pi, and the Tan of that: RealDigits@p N@Mod[p,Pi] Tan@% {{3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3},18} 0. 0. RealDigits@q N@Mod[q,Pi] Tan@% {{3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2},18} 2.29533 -1.12979 All that makes perfect sense, although that answer has very little precision (if any). Precision@Mod[q,Pi] 0.0598148 The answers that DON'T make sense to me are these: N@Tan@q ComplexInfinity Precision@Tan@Mod[q,Pi] Infinity It hardly matters, though, since 314159265358979323. doesn't have enough precision for us to have any idea what its Tan should be. Bobby On Mon, 23 Aug 2004 06:34:06 -0400 (EDT), paul <paul at AOI.com> wrote: > Indeed a nice problem Professor! Thank you for sharing it. Would you mind > helping us understand something, why is it that when we give the following > input: > In[69]:= > p = 314159265358979323 > q = 314159265358979323. > r = 314159265358979323.00000000000000000000; > s = p + 0.00000000000000000000; > {p, q, r, s} > {N[Tan[p]], N[Tan[q]], N[Tan[r]], N[Tan[s]]} > > And get the following output: > > Out[69]= > 314159265358979323 > Out[70]= > \!\(3.14159265358979323`17.497149872694134*^17\) > Out[73]= > \!\({314159265358979323, 3.14159265358979323`17.497149872694134*^17, > 3.14159265358979323`37.49714987269414*^17, 3.141592653589793`*^17}\) > Out[74]= > {1.60125, ComplexInfinity, -1.12979, 1.60125} > > Then, the output for Tan[p] and Tan[q] give two different answers? Even > though they are almost exactly the same numbers (only different in > precision), If it can calculate the Tan[314159265358979323] then why is it > not able to give an approximate value for > Tan[3.14159265358979323`17.497149872694134*^17], Also, if it calculates > Tan[314159265358979323] to be 1.60125, then why does it give > Tan[3.14159265358979323`37.49714987269414*^17] with such a severe variation > (-1.12979)? > > Thanks for your help, > > Regards, > > > "Richard Fateman" <rfateman at sbcglobal.net> wrote in message > news:cg97i2$a62$1 at smc.vnet.net... > >> Paul, since you are copying this from my posting to sci.math.symbolic >> of August 19,2004, (yesterday) perhaps you should give me credit. >> I took the example from my own paper, A Review of Mathematica, >> which appeared in J. Symbolic Computation,(1992) and a version of which >> is online. You might also read Mark Soufroniou's INRIA paper (1999?) >> explaining why this behavior is apparently intentional, even if it is >> hard to explain (shown by the responses you got). >> >> The idea that 0.0 should represent all numbers in [-1,1]* 2^{-precision} >> is generally regarded with skepticism by computational scientists. Some >> of the other consequences of this are discussed by Soufroniou and others. >> RJF >> >> >> >> paul wrote: >> > In Mathematica 5.0, I get a very strange result when I add 0.0 to a > number, >> > why is this? See below: >> > >> > p = SetPrecision[314159265358979323, 25] >> > q = SetPrecision[314159265358979323., 25] >> > r = SetPrecision[314159265358979323.00000000000000000000, 25] >> > s = SetPrecision[p + 0.0, 25] >> > {p == q, q == r, r == s, r == p} >> > {Tan[s], N[Tan[p]], Tan[q], Tan[r]} >> > >> > >> > \!\(3.14159265358979323`25.*^17\) >> > Out[47]= >> > \!\(3.14159265358979323`25.*^17\) >> > Out[48]= >> > \!\(3.14159265358979323`25.*^17\) >> > Out[49]= >> > \!\(3.14159265358979328`25.*^17\) *****NOTICE the 28 instead of 23 at > the >> > end, why does this happen? ******* >> > Out[50]= >> > {True, True, False, True} >> > Out[51]= >> > {1.599808, -1.12979, -1.1297927, -1.1297927} >> > >> > > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- Re: Beware of adding 0.0
- From: "paul" <paul@AOI.com>
- Re: Beware of adding 0.0