Example code:
f[y_] := NIntegrate[x, {x, 0, y}]
Plot[f[y], {y, 0, 1}]
It works in v10.4, but in v11.0, even though Mathematica shows the plot, it also gives (the same) errors:
NIntegrate:x=y is not a valid limit of integration.
NIntegrate:x=y is not a valid limit of integration.
The error is nonsense to me since Plot has attributes HoldAll, and I know I can suppress the errors by adding ?NumericQ to the parameter y, however, the question is
WHY?
Trace[Plot[f[y], {y, 0, 1}], f]? Or better yet, what evaluatingTrace[Plot[f[y], {y, 0, 1}], f, TraceInternal -> True]? An evaluation of the formf[y]should explain why this happen (I don't see any in v10.4, and I do not experience this behaviour) – glS Sep 17 '16 at 10:57NIntegrate[x, {x, 0, 0.0000204286}], both in v11 and 10.4 – luyuwuli Sep 17 '16 at 11:02TraceInternaloption? – glS Sep 17 '16 at 11:03f[val],NIntegrate[x,{x,0,val}]where val is the points between 0 and 1. – luyuwuli Sep 17 '16 at 11:08Plot[f[Echo[y]], {y, 0.01, 1}]shows, the function is evaluated symbolically at one point. As you already stated, one can prevent the symbolic evaluation by using?NumericQ. What precisely is your question? Why there is a symbolic evaluation or why it is different in v11 than in v10? – Karsten7 Sep 17 '16 at 11:16NumericQthere.Plotuses heuristics to try to save you from this mistake but it's not foolproof. – Szabolcs Sep 17 '16 at 11:24Plothold its arguments, the seems no reason forf[y]to be pre-evaluated, i.e.ywill always be a numeric value, so it should be no warnings despite of its low efficiency. – luyuwuli Sep 17 '16 at 11:40HoldAllmeans that the argument is passed into a function without evaluation, so the function can do whatever it wants with it. That includes evaluating it. Plot does evaluate it. Example:SetAttributes[fun, HoldAll]; fun[x_] := x. When you callfun[x],xgets evaluated at some point, just a little later than it would be withoutHoldAll. – Szabolcs Sep 17 '16 at 11:43Ploteven has an undocumentedEvaluatedoption which controls what sorts of evaluations it will attempts internally. I don't fully understand its effect, and setting it toFalsedoesn't fix things here ... Maybe something is wrong with v11. One reason whyPlotwould evaluate the function with a symbolic argument is that it may do symbolic processing to determine theExclusions. – Szabolcs Sep 17 '16 at 11:49Evaluated->False, it dosen't prevent the error (even thougth I didn't post it in the question.) I thought it was the same as theHoldAllattributes. Your comment reminds me that indeed some non-trival part is modified in v11. – luyuwuli Sep 17 '16 at 11:55