# How to set Working Precision/ Accuracy global for the entire notebook in mathematica

F1[r]=((37.3042 - r) (-25.578 + r) (62.8822 + r))/(3000 r)
FindMaximum[F1[r], r]


The output is {0.0345106, {r -> 31.0723}}. Then I defined the quantities

maxr = r /. FindMaximum[F1[r], r][]
maxF1 = FindMaximum[F1[r], r][]


maxr gives the value of r at which F1[r] is a maximum, and maxF1 is the value of that maximum.

Now I take the difference between the two ways of finding the maximum, which should be exactly 0, but I got a nonzero contribution.

maxF1 - F1[maxr] // N


The output I got is 1.38778*10^-17. How do I change the working precision or accuracy to always make this exactly 0. in a given notebook?

• maxr and maxF1 seem to have the same definition; is this intentional? Also, what is maxxf? Mar 10 at 22:30
• Ah, I think I understand, and I've edited your question to match, if that's ok. Mar 10 at 22:57
• yes that is fine now Mar 11 at 12:43

Each function such as FindMaximum has its own settings for precision and accuracy. So, you could for example evaluate

FindMaximum[F1[r], r, WorkingPrecision -> 50]


for example, and this would use 50 digits of precision during that computation, which in this case seems to be enough to get the result to be exactly 0..

Another relevant option is AccuracyGoal, which will change the point that is found slightly, but not the precision with which it's located. So, you'd still need to modify WorkingPrecision, e.g.

FindMaximum[F1[r], r, WorkingPrecision -> 50, AccuracyGoal -> 50]


(Another possibly relevant option is PrecisionGoal, but usually Automatic is good enough.)

But to set these for the entire notebook, instead of in each individual function call, you can evaluate

SetOptions[FindMaximum, {WorkingPrecision -> 50, AccuracyGoal -> 50}]


and now FindMaximum[F1[r], r] will use those options by default. (At least, within that kernel session.)

Hope this helps!