Alan,
The error message occurs because the NIntegrate within ComplicatedF is
complaining about its input. For some reason, the MonteCarlo NIntegrate is
examining the quantity ComplicatedF[x] where x is not numerical. Try
inputting simply ComplicatedF[x] and you will see the same error message.
The way to avoid this situation is to change the function by restricting its
input to only numeric quantities:
Clear[ComplicatedF]
ComplicatedF[x_?NumericQ] := Re [NIntegrate [E^(- (I x+y+I)^2), {y,0,1}] ]
Now try your Monte Carlo integration and you will see no errors.
Carl Woll
Physics Dept
U of Washington
"Alan Lewis" <alanlewis at optioncity.net> wrote in message
news:b1idic$bjv$1 at smc.vnet.net...
> I have a rather complicated function that Mathematica can't seem to handle
> with
> NIntegrate, Method->MonteCarlo.
>
> This is not my function, but it shows the essence of the problem.
> Suppose we have
>
> ComplicatedF[x_] := Re [NIntegrate [E^(- (I x+y+I)^2), {y,0,1}] ]
>
> Then, if you try:
>
> NIntegrate[ComplicatedF[x], {x,0,2}, Method->MonteCarlo]
>
> Mathematica will complain that the integrand is not numerical.
> But of course it is numerical and removing the Method->MonteCarlo option
> will generate an answer.
>
> Now my actual function is quite complicated which is why
> I want to try the MonteCarlo method. Any suggestions?
>
>