Bug introduced in 10.0 and fixed in 10.0.2
In testing the answers to Plot result of non analytical-integral in V10.0.1, I came across this behavior of LogLogPlot
. All three version give the correct plot, but the first two give error messages.
ClearAll[f1, f2, f3, x];
k = 1/x;
kfn[x_?NumericQ] := 1/x;
f1[x_?NumericQ] := NIntegrate[k*y, {y, 0, 1}]; (* kludgy *)
f2[x_?NumericQ] := NIntegrate[kfn[x]*y, {y, 0, 1}]; (* correct way, but gives errors *)
f3[x_?Positive] := NIntegrate[k*y, {y, 0, 1}]; (* also correct and no errors *)
LogLogPlot[f1[x], {x, 1, 10}]
LogLogPlot[f2[x], {x, 1, 10}]
LogLogPlot[f3[x], {x, 1, 10}]
The first two give the message (twice):
NIntegrate::inumr: The integrand y/x has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1}}. >>
The second gives an additional message (twice):
Power::infy: Infinite expression 1/0 encountered. >>
Why does this happen? Is this a bug?
Notes: (1) It does not happen on V9. I seem to recall this coming up before (years ago). If folks have earlier versions, please test the code above. (2) Reported to WRI. (3) WRI confirmed it in 10.0.1 and stated it was resolved in 10.0.2.
f[x_?NumericQ] := (Print[x]; NIntegrate[kfn[x]*y, {y, 0, 1}])
. (I dislike posting such questions, when I know the answer. But as it relates to a question on the site, I also thought I ought to. Feel free to answer first.) $\endgroup$f1
andf3
but notf2
. I restarted the kernel and ran it again and got no messages at all. Additional restarts also produced no messages. Since I now cannot seem to reproduce the problem I'm not sure what to make of it. $\endgroup$Equal
andSameQ
) for all three plots and no error messages. $\endgroup$