bugs with N ...

*To*: mathgroup at yoda.ncsa.uiuc.edu*Subject*: bugs with N ...*From*: fateman at ucbarpa.Berkeley.EDU (Richard Fateman)*Date*: Sat, 6 Oct 90 11:04:15 -0700

Telling fortunes by reading N-trails? Mathematica (sun3.68881) 1.2 (November 6, 1989) [With pre-loaded data] (* Change $Post to look at all three attributes on display *) In[1]:= p[x_]:= {x, Accuracy[x], Precision[x]} In[3]:= $Post=p ..... In[7]:= N[Sin[10^16],16,16] Out[7]= {0.779679945161067, 16, 16} In[9]:= N[Sin[10^16],20] (* increasing precision decreases "Accuracy" *) Out[9]= {0.78, 4, 4} In[10]:= N[Sin[10^16],50] Out[10]= {0.7796880066069787502355279540333621, 34, 34} In[11]:= a=10^50 In[13]:= N[Sin[a],16] Out[13]= {0.0937537918202386, 17, 16} (* this answer is not good to 17 places. it is wrong in all places, and even has the wrong sign. *) In[14]:= N[Sin[a],20] Format::imz: Warning: Number with negative accuracy being printed as 0. Out[14]= {0., -30, 0} (* I think this means that Mathematica cannot determine Sin[a] within a range of -10^30 to +10^30. Most people think that for real arguments the sine function is restricted to [-1,1] *) In[16]:= N[Sin[a],49] Out[16]= {0., -1, 0} .. In[19]:= N[Sin[a],52] Out[19]= {-0.8, 2, 2} In[20]:= N[Sin[a],60] Out[20]= {-0.789672493, 10, 10} In[21]:= b=N[a,60] Out[21]= {100000000000000000000000000000000000000000000000000., 10, 60} (* M'ma's policy of making this number "accurate" to 10 places leads to foolishness. Why the location of the decimal place is so important, is hard to understand. Are meters more accurate than millimeters? *) In[22]:= Sin[b] Out[22]= {-0.789672493, 10, 10} In[23]:= N[Sin[b],16] Out[23]= {-0.7896724934295026, 16, 16} In[24]:= N[Sin[b],18] Out[24]= {-0.789672493, 10, 10} ... In[27]:= N[Sin[b],100] Out[27]= {-0.789672493, 10, 10} .... Of course some of these anomalies are easily explained by knowing how Mathematica "works". That does not make them necessarily more comforting. -- Richard Fateman