Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.2K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to enter high precision numerical constants?

Posted 11 years ago

New to Mathematica (ver 9). Trying to use numerical constants with about 20 decimal places in functions like N, but it keeps converting them to 6 decimal places. I know this has to be an easy thing to do, but cannot find it anywhere in the docs.

POSTED BY: rhutson2
5 Replies
Posted 11 years ago
POSTED BY: rhutson2
POSTED BY: David Reiss
Posted 11 years ago

Here's a simplified example:

N[2*1.23456789, 20]

returns:

2.46914

How do I get it to return more digits?

POSTED BY: rhutson2

Beware of the decimal point! It will kill your high precision.

If you enter

N[E^2,20]

you get 7.3890560989306502272.

But if you enter

N[E^2. ,20] 

You get only 7.38906.

If you need to use fractional amounts rationalize them fiirst

If you want a high precision estimate for 2^2.125. enter

N[2^Rationalize[2.125, 0], 20]

instead of

N[2^2.125, 20]

.The 0 in Rationalize[] makes sure the decimal is rationalized completely, not just substituted by an approximation.

Perhaps an example of what you are doing would help. The default display form for machine precision numbers is 6 places, but the remaining digits are still there. If you are doing a computation with both high precision numbers and machine precision numbers then the result will generally be machine precision unless there are in fact no machine precision numbers... and even then, depending on the calculation, the resulting precision may be less than that of the input numbers. E.g. (note the use of FullForm to show how many digints are actually there.

In[4]:= N[Pi, 30] + N[Pi] // FullForm

Out[4]//FullForm=6.283185307179586`

In spite of using a 30 digit precisin, when combined with a machine precision number the result is Machine precision

Without the FullForm only 6 digits are shown

In[5]:= N[Pi, 30] + N[Pi]

Out[5]= 6.28319
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard