Group Abstract Group Abstract

Message Boards Message Boards

0
|
12K Views
|
8 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Display machine precision numbers for more than 5 significant digits?

Posted 9 years ago

If I want to compute the following

In[6]:= 3^Sqrt[2.0]

Out[6]= 4.7288

The result is given to 5 significant digits, which is quite a small number - a pocket calculator do a lot better. I'm sure the CPU's floating point processor can do a lot better than that. I tried indicating that the 2 was know more precisely than one significant digit, by indicating a number of zeros, but again a result with only 5 significant digits is returned.

In[9]:= 3^Sqrt[2.00000000000]

Out[9]= 4.7288

Obviously I can perform the this particular calculation in arbitrary precision,

In[32]:= N[3^Sqrt[2],20] 

Out[32]= 4.7288043878374149479

but that inconvenient, and slower than desirable. Is there any way to force Mathemaitca to display about 12 digits? A standard Intel CPU should be able to handle that in the vast majority of cases.. I realise that rounding errors can be significant for some calculations, so I might have less than 12 digits, but I'm sure printing to 10 or 12 digits would be a vast improvement, and they would probably all be right.

I tried

In[16]:= N[3^Sqrt[2.000000000000000000],20]

Out[16]= 4.72880438783741495

In[17]:=  Precision[%]

Out[17]= 18.2169

which seems to do the trick, but I wonder if there's a way to display machine precision numbers to a bit more than 5 significant digits. A pocket calculator does better than that.

Dave

POSTED BY: David Kirkby
8 Replies
Posted 9 years ago

Thank you everyone.

POSTED BY: David Kirkby

You have to change correspondent options from Menu:

Edit -> Preferences -> Appearance -> Numbers -> Formatting -> Displayed Precision -> 12
Posted 9 years ago

... or just evaluate

  SetOptions[$FrontEnd, PrintPrecision -> n]

where n is the maximum number of digits used for displaying a machine-precision number.

Another alternative is to always show inexact numbers in FullForm:

 SetOptions[$FrontEnd, NumberMarks -> True]
POSTED BY: Alexey Popkov

Are these options saved or only maintained per session if one uses SetOptions on $FrontEnd?

POSTED BY: Sander Huisman
Posted 9 years ago

When we use SetOptions on $FrontEnd the options are saved in the FrontEnd's init.m file. For changing options for current session only we need to apply it on $FrontEndSession.

POSTED BY: Alexey Popkov
POSTED BY: Neil Singer

One should note that providing a precision using a prime mark will trigger arbitrary precision numbers as opposed to machine precision numbers. Which has a lot more implications than showing more digits. This is definitely not the problem of the OP. It is just a display issue (if you can call it that) in this case which can be set in the preferences as said by @Henrik Schachner...

POSTED BY: Sander Huisman

Hi David,

this is just a display issue. Consider this:

3^Sqrt[2.0] // FullForm
    (*  Out:   4.728804387837416`  *)

You can adjust the number of digits displayed e.g. in Edit -> Preferences -> Appearance -> Numbers -> Formatting.

... a pocket calculator do a lot better.

You did not believe that really, did you?

Regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard