3
$\begingroup$

I have this simple code:

ep = 1 - 80000000000 (-(199999/200000) + 1/E^(1/200000))

ep // N

-8.27404*10^-8

N[ep, MachinePrecision]

-8.27404*10^-8

Block[{$MaxExtraPrecision = 500}, ep // N]

-8.27404*10^-8

All these results are incorrect, since in fact ep>0; they also seem to contradict the following: Quoting from the Mathematica tutorial ArbitraryPrecisionNumbers:

[...] the Wolfram Language keeps track of which digits in your result could be affected by unknown digits in your input. It sets the precision of your result so that no affected digits are ever included. This procedure ensures that all digits returned by the Wolfram Language are correct, whatever the values of the unknown digits may be.

N[ep, 10]

1.666664583*10^-6

This seems to be correct.


What is wrong in my understanding or in Mathematica's behavior?

$\endgroup$
3
$\begingroup$

MachinePrecision is really the precision of the machine; the machine itself cannot track precision like Mathematica's arbitrary precision numbers that you get with, say, N[#,10]&. The machine performs computations with 2 extra bits or so and rounds afterwards. This is also why raising $MaxExtraPrecision has no effect: With N you call for machine precision. People who do a lot of numerics actually want that because machine precision computations are much faster than arbitrary precision computations.

So, in a nutshell, the snippet that you cited holds only true for arbitrary precision numbers.

$\endgroup$
  • $\begingroup$ Thank you, this clears it for me. $\endgroup$ – Iosif Pinelis Nov 9 '18 at 20:43
  • $\begingroup$ You're welcome. =) $\endgroup$ – Henrik Schumacher Nov 9 '18 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.