# Two dimensional NIntegration failure - non-numerical values

I've got this function:

E0[x0_, y0_, z_]:=
A/w[z]*Exp[-(x0^2 + y0^2)/(w[z]*w[z])]*Exp[(I*2*Pi*(x0^2 + y0^2))/(λ*2*R[z])]*Exp[I*ϕ[z]];


Where the w[z], R[z] and Phi[z] are given as presented here.

Second function is as follows:

Transmission1[x0_, y0_] := 2*(1 + Cos[((2*Pi)/λ)*x0 - 2*ArcTan[(y0/x0)]]);


I want to perform an two dimensional NIntegration:

f1[x2_, y2_]:=
NIntegrate[E0[x0,y0,z]*Transmission1[x0, y0]*Exp[I*(kx1*x0 + ky1*y0)],
{y0,-0.00001,0.00001},{x0, -0.00001, 0.00001}];


where:

kx1 = ((2*Pi)/(λ*z))*x2;
ky1 = ((2*Pi)/(λ*z))*y2;


For any {x2,y2} values I get an error which states:

NIntegrate::inumr: "The integrand 2\ E^(I\((20000000 π x0 x2)/633+(20000000 π y0 y2)/633))\ (1+Cos[(2000000000\π\x0)/633-2\ ArcTan[Power[<<2>>]\ y0]])
has evaluated to non-numerical values for all sampling points in the region with boundaries {{-0.00001,0.00001},{-0.00001,0.00001}}"


How can I manage to solve this issue?

-

Your problem is in how you define kx1 and ky1. When you call f1[], x2 and y2 are substituted in the expression they are immediately visible. And since kx1 and ky1 don't explicitly depend on z and x2 and y2, these values aren't substituted.

To fix this, you should define kx1 and ky1 as functions:

kx1[z_,x2_] = ((2*Pi)/(λ*z))*x2;
ky1[z_,y2_] = ((2*Pi)/(λ*z))*y2;


and use as functions in f1[].

Also, definition of your f1 lacks additional argument of z, so you should add it too (if you don't set its value somewhere, of course - but I couldn't deduce it from your question):

f1[x2_,y2_,z_]:=...


and supply it too for numerical integration to be possible.

-
Thank you very much! It helped a lot. – Matt Nov 20 '13 at 21:09