2
$\begingroup$

I am wondering why I am receiving the message "The integrand ... has evaluated to non-numerical values for all sampling points in the region ..." for a particular calculation I am running. How can I change my code so that this is not an issue? A simple example is copied below.

a = 1/20; b = 1/5;
FF[y_] := Exp[I a y - 1/2 b^2 y^2];
f[x_] := NIntegrate[E^(-I x y) FF[y], {y, 0.0, 100}];
NIntegrate[f[x], {x, -100, 100}]

Thanks...

$\endgroup$

1 Answer 1

5
$\begingroup$
a = 1/20; b = 1/5;
FF[y_?NumericQ] := Exp[I a y - 1/2 b^2 y^2];
f[x_?NumericQ] := NIntegrate[E^(-I x y) FF[y], {y, 0.0, 100}];
NIntegrate[f[x], {x, -100, 100}]

converges slowly ... to Pi

$\endgroup$
3
  • $\begingroup$ That did the trick. I just noticed that FF[y_Real] and f[x_Real] also solves the issue. Shame it slows the code down though... $\endgroup$
    – Freakalien
    Oct 24, 2013 at 2:49
  • $\begingroup$ Would you know where I can find some general information on when such conditions on function parameters should be used? $\endgroup$
    – Freakalien
    Oct 24, 2013 at 2:57
  • $\begingroup$ @Freakalien Take a look at the first two questions here meta.mathematica.stackexchange.com/questions?sort=votes $\endgroup$ Jul 7, 2014 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.