Re: Weird division
- To: mathgroup at smc.vnet.net
- Subject: [mg22763] Re: Weird division
- From: Martin Harborth <Martin.Harborth at vt.siemens.de>
- Date: Fri, 24 Mar 2000 03:28:16 -0500 (EST)
- Organization: Siemens AG, ATD TD IT MV 1
- References: <8b9lp6$941@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
PaulDj schrieb: > > Hallo, > do you know why > > N[2^25/38,i]=883011. when i<=16 > > and only with i>16 the decimal digits come out? Hello, see the answers to my similar question some days ago: 1)-------------------------------------------------------------------- Hi Martin. I also have been unable to make Mathematica PRINT a result with arbitrary precision, namely as you do. Your machine precision is probably 16 just as mine (Run the command $MachinePrecision to find out) which explains that behavior, if you ask precision>17 you put Mathematica out of it defaut, but if you ask less than 17 it works on it default setting, computes numbers to 16 digits (even if you ask for less!) and prints 6. However, it knows more digits than it prints: Try this: In[1]:= N[Sin[1.0],10] Out[1]= 0.841471 Prints six digits, but knows more! In[2]:=N[%-0.841471,10] Out[2]=-1.51921 10^(-8) Not zero! I don't know how to change the printing options, I am sure it is possible. But it's usually sufficient that Mathematica knows those extra digits, not that it prints it. Otto Linsuain. 2)---------------------------------------------------------------------------- Martin, In Version 4, N does not affect the number of digits displayed. The default is to always display 6 places of precision, except for trailing zeros. N[1.0/3, 10] 0.333333 The number is actually a machine precision number and I don't think the 10 actually did anything in the above statement. To display just 10 places you can use the number formatting command NumberForm: NumberForm[1.0/3, 10] 0.3333333333 If you regularly want to see 10 places, instead of the default 6 places, you can change the PrintPrecision setting in the Option Inspector. Follow the path Formatting Options -> Expression Formatting -> Display Options -> PrintPrecision. Edit the PrintPrecision value from 6 to 10 and Enter. Finally, if you wish to maintain control on the precision of your calculations, check out Section 3.1 Numbers, and especially Section 3.1.4 Numerical Precision in the Mathematica Book. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ 3)-------------------------------------------------------------------------------- Hello, Thank you for the email. You should use SetPrecision[number,n] to specify the precision of a result, not N[]. The following will show the behavior of N compared to SetPrecision. In[1]:= N[Pi,10] Out[1]= 3.14159 In[2]:= a = SetPrecision[Pi,10] Out[2]= 3.141592654 In[3]:= b = SetPrecision[Pi,13] Out[3]= 3.141592653590 In[4]:= a + b Out[4]= 6.283185307 Sincerely, David Arcoleo Technical Support Wolfram Research, Inc. support at wolfram.com Bye, Martin. --------------------------------------------- Dr. Martin Harborth Siemens AG, Transportation Systems, VT 1 E 11 Ackerstr. 22, D-38126 Braunschweig, Germany phone +49 531 226 5338, fax +49 531 2277 5338