# NIntegrate with parameters in Block: Avoid error messages?

Posted 1 year ago
1167 Views
|
3 Replies
|
1 Total Likes
|
 Hi!Could anybody explain me, how to avoid the error message "NIntegrate::inumr" in the sample below? In[1]:= f[x_, y_] := NIntegrate[E^(-x y z), {z, 0, 1}] In[2]:= Block[{y = 1}, NIntegrate[f[x, y], {x, 0, y}]] During evaluation of In[2]:= NIntegrate::inumr: The integrand E^(-x z) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1}}. >> Out[2]= 0.7966 
Answer
3 Replies
Sort By:
 This error message comes from symbolic pre-evaluation performed by the outer NIntegrate and has nothing related to Block. The best is to combine the two NIntegrate into one: y = 1; NIntegrate[E^(-x y z), {x, 0, 1}, {z, 0, 1}] (* => 0.7965995998164899 *) If the latter isn't possible, a workaround is to disable symbolic preprocessing by turning the inner integral into a black-box function (but it can considerably slow down integration): Clear[f] f[x_Real, y_] := NIntegrate[E^(-x y z), {z, 0, 1}] Block[{y = 1}, NIntegrate[f[x, y], {x, 0, y}]] (* => 0.7965995992970549 *) 
Answer
Posted 1 year ago
 This is unrelated to Block. Everything is explained here: http://support.wolfram.com/kb/12502
Answer
Posted 1 year ago
 Alexey Popkov and Szabolcs Horvát, thanks for answers.In fact, I do not need a symbolic pre-evaluations of the integral, so this method works well for me.
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments