21

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?

Oleksandr R.
  • 23,023
  • 4
  • 87
  • 125
renphysics
  • 1,560
  • 1
  • 10
  • 19
  • 1
    Hope this helps, have a look at: http://mathematica.stackexchange.com/questions/6421/global-precision-setting – Kardashev3 Dec 01 '13 at 17:15
  • 6
    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.\16rather than2.` and you will get the effect you are after. – Oleksandr R. Dec 01 '13 at 17:27
  • 2
    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? – renphysics Dec 01 '13 at 19:03

1 Answers1

12

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.

highsciguy
  • 1,700
  • 1
  • 16
  • 23