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'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}];


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?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

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):


and supply it too for numerical integration to be possible.

share|improve this answer
Thank you very much! It helped a lot. –  Matt Nov 20 '13 at 21:09
add comment

Your Answer


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.