I am trying to find the numerical derivative of a function whose argument defines the bounds of a numerical integral.

test[u_?NumericQ] := NIntegrate[x^5, {x, 0, u}]
ND[test[u], u, 2]

When I input this I receive the following error message: "NIntegrate::nlim: x = u is not a valid limit of integration." I figured that the inclusion of ?NumericQ in the function definition would take care of this type of issue. Can someone explain why I am receiving this error message?

  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Jul 15 '15 at 21:53
  • 1
    $\begingroup$ Evaluate ClearAll@test and try again. $\endgroup$ – Karsten 7. Jul 15 '15 at 21:56
  • $\begingroup$ With Mathematica 10.1, I receive no error message, but ND[test[u], u, 2] returns unevaluated. However, if I begin the notebook with the required Needs["NumericalCalculus"], it returns 32`, as it should $\endgroup$ – bbgodfrey Jul 15 '15 at 21:57
  • $\begingroup$ @bbgodfrey OP forgot to mention that one has to load the NumericalCalculus` package to have access to ND. I cannot reproduce the error either on 10.1. I suspect that @Karsten may be right, and it may be a spurious definition problem. $\endgroup$ – MarcoB Jul 15 '15 at 21:59
  • 1
    $\begingroup$ @Karsten7 was right. I just had to evaluate ClearAll@test and then it worked fine. Thank you! $\endgroup$ – scottb66 Jul 16 '15 at 15:08