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 *)

(* 21. *)

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

(* {x -> 0.18000000000000000000} *)

(* {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.

  • $\begingroup$ I think Plot is testing the function by plugging in a machine precision value (like -9.99959142857143` , but also the exact integer 10). $\endgroup$ – Michael E2 Dec 20 '16 at 16:48
  • $\begingroup$ Even if I lower the working precision to 9 or even to 1, the error appears... $\endgroup$ – Remo Dec 20 '16 at 16:55
  • $\begingroup$ 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. $\endgroup$ – Michael E2 Dec 20 '16 at 17:00
  • $\begingroup$ 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. $\endgroup$ – Remo Dec 20 '16 at 17:10
  • 1
    $\begingroup$ 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. $\endgroup$ – Michael E2 Dec 20 '16 at 17:16


I reported this issue to Wolfram tech support and received a reply. I quote the relevant portions thereof.

I have confirmed the issue you are experiencing with the FindRoot::precw and FindRoot::nlnum errors being printed when they shouldn't be. I spent a fair amount of time digging into this, and it seems the underlying reason is that the precision of [the variable] is sometimes not being set.

For some reason, Precision is kept at MachinePrecision for certain values of [the variable]. This is what is triggering the error message. I have not been able to isolate why this is occurring.

I am marking the question with the tag .


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.