20
$\begingroup$

I want to increase the precision globally to 50 at least, but $MinPrecision does not work.

$MinPrecision = 50;
x = Sin[2.]
(* -> 0.909297 *)

Precision[x]
(* -> MachinePrecision *)

How to set the working precision globally, i.e., make all the calculations in the notebook use the new precision?

$\endgroup$
3
  • 1
    $\begingroup$ Hope this helps, have a look at: mathematica.stackexchange.com/questions/6421/… $\endgroup$
    – Kardashev3
    Dec 1, 2013 at 17:15
  • 6
    $\begingroup$ Precision settings only apply for arbitrary-precision values. When working with machine numbers, there is no tracking or adjustment of precision. So, enter your value as e.g. 2.`16 rather than 2. and you will get the effect you are after. $\endgroup$ Dec 1, 2013 at 17:27
  • 2
    $\begingroup$ My notebook involves machine precision numbers in many places; it would be tedious if I do the change like 2.`16 in every place. Is there a convenient way to set the precision once and for all? $\endgroup$
    – renphysics
    Dec 1, 2013 at 19:03

1 Answer 1

11
$\begingroup$

This looks like a duplicate of my question here Global precision setting . Since I formulated it in a slightly different way, coming from Maple it might however be worth quoting the answer given by Mr. Wizard here. It worked for me in Mathematica 9 if there are no arbitary precision numbers in the notebook (defined as e.g. 2.`16):

$PreRead = (# /. 
 s_String /; 
   StringMatchQ[s, NumberString] && 
    Precision@ToExpression@s == MachinePrecision :> s <> "`50." &);

3/1.5 + Pi/7

Precision[%]

This will act on all later commands before the actual command is executed and set the precision of contained numerical values to 50 digits.

$\endgroup$

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.