Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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...

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
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

share|improve this answer
    
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... –  Freakalien Oct 24 '13 at 2:49
    
Would you know where I can find some general information on when such conditions on function parameters should be used? –  Freakalien Oct 24 '13 at 2:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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