# Precision of computations done by Plot

I get a nice plot, but also a FindRoot::precw: error when I try to plot the results of a function that invokes FindRoot. I assume the problem originates in how Plot passes the arguments to the function. Here is a simple notebook that shows this behavior:

eqn = 5*x + 0.1000000000000000000000 + s == 0
(* 0.100000000000000000000 + s + 5 x == 0 *)

Precision[eqn]
(* 21. *)

g[b_] :=
FindRoot[{eqn /. s -> b}, {{x, -13000}},
MaxIterations -> 1000,  WorkingPrecision -> 20]

g[-1]
(* {x -> 0.18000000000000000000} *)

g[100]
(* {x -> -20.020000000000000000} *)

Plot[x /. g[s], {s, -10, 10}, WorkingPrecision -> 20]


FindRoot::precw: The precision of the argument function ({-9.89959+5 x==0}) is less than WorkingPrecision (20.). >>

I tried with and without the WorkingPrecision option in the plot, and also by wrapping the ranges with a set precision like:

Plot[x/. g[s], {s, SetPrecision[-10, 20], SetPrecision[-10, 20}}]


which looks strange and does not work as well...

To be clear, the generated plot looks nice, but the errors are still annoying.

• I think Plot is testing the function by plugging in a machine precision value (like -9.99959142857143 , but also the exact integer 10). – Michael E2 Dec 20 '16 at 16:48
• Even if I lower the working precision to 9 or even to 1, the error appears... – Remo Dec 20 '16 at 16:55
• That's because MachinePrecision is considered less than any arbitrary precision by FindRoot. You could use Quiet to ignore the warning. (It's not an error.) Or you could use SetPrecision inside g, but I would be less happy with that in some situations. – Michael E2 Dec 20 '16 at 17:00
• I think I can live with the Quiet solution, even though I think it is somewhat inconvenient. But I'm relieved that I should not worry too much about this warning. – Remo Dec 20 '16 at 17:10
• One can see why they analyze/test the function with machine numbers, because they're faster. If there is an option to turn this off, it's bound to be more work than Quiet@Plot[..] or even Quiet[Plot[..], FindRoot::precw], which would let real numerical errors be reported. – Michael E2 Dec 20 '16 at 17:16