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.

  • $\begingroup$ Hints: The title. Try out 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$ – Michael E2 Jan 6 '15 at 14:45
  • $\begingroup$ I ran the code and got error messages from f1 and f3 but not f2. 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$ – Mr.Wizard Jan 6 '15 at 15:17
  • $\begingroup$ @Mr.Wizard Which version(s) of Mma? I can reproduce it on a completely new session. (My system is a Mac, in case that makes a difference.) $\endgroup$ – Michael E2 Jan 6 '15 at 15:50
  • $\begingroup$ With Mathematica 10.0.2 on a MacBook Pro running OS X Yosemite 10.10.1, I get identical results (Equal and SameQ) for all three plots and no error messages. $\endgroup$ – Bob Hanlon Jan 6 '15 at 16:35
  • $\begingroup$ No errors Mathematica 10.0.2 Windows 7 Enterprise. $\endgroup$ – Zviovich Jan 6 '15 at 18:25

The issue in V10.0.1 is that LogLogPlot uses x = 0 as a test point, instead of a value inside the specified plot domain.

The issue is resolved in V10.0.2.

Confirmed by WRI.

  • 1
    $\begingroup$ I guess I have to wait until tomorrow to accept my own answer. I wonder if resolved bugs Q&A should be closed. Basically I don't like having unanswered questions...perhaps I'll pursue it on meta. $\endgroup$ – Michael E2 Jan 7 '15 at 14:16

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.