It's because FindRoot
evaluates psiwmax[g0]
first with symbolic g0
and analyzes the result. This causes the error message. Then FindRoot
evaluates psiwmax[g0]
with numeric values substituted for g0
, and everything works fine after that.
The standard way to prevent the error message is to define numerical functions using NumericQ
to prevent evaluation on nonnumeric arguments. Wolfram has a Knowledgebase article on this.
Example coding paradigm:
ClearAll[psiwmax];
psiwmax[g0_?NumericQ] := ....