0
$\begingroup$

I'm trying to do an nested NIntegrate in which there's a function in between; for example:

f[z_?NumericQ] := NIntegrate[Exp[-x^2/2] Cos[x^2 z/10], {x, -Infinity, Infinity}]
NIntegrate[Log[f[z]],{z,0,10}]

Unfortunately, when I try to do this, I get the typical error:

NIntegrate::inumr: The integrand E^(-(x^2/2)) Cos[(x^2 z)/10] has evaluated to non-numerical values for all sampling points in the region with boundaries {{[Infinity],0.}}.

I thought adding NumericQ would make this go away, but it didn't work. Any tips on how to work around this? Apologies if this has been asked before; I wasn't sure how to properly word the question.

$\endgroup$
  • 1
    $\begingroup$ Works for me without any error message. Mathematica 10 on OSX 10.11.5. Try seeing if typing f[3] gives a numerical answer. $\endgroup$ – Erich Mueller Apr 5 '17 at 23:39
  • $\begingroup$ probably you defined f without the ?NumericQ, then redefined it with ?NumericQ but didn't Clear the original def. Either do Clear[f] or restart the kernel $\endgroup$ – george2079 Apr 6 '17 at 2:30
  • $\begingroup$ I also have such a message, if using it without ?NumericQ (Mma 11.1, Win7). That's strange I remember to have done such things without such messages in one of the previous versions. Can anybody explain this? $\endgroup$ – Alexei Boulbitch Apr 6 '17 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.