1

I have this function:

$$E_p(x_0,y_0,t)=E_0e^{-i\omega t}\int^{\frac{a}2}_{\frac{-a}2}\int^{\frac{b}2}_{\frac{-b}2}\frac{e^{ik\sqrt{(x-x_0)^2+(y-y_0)^2+z^2}}}{\sqrt{(x-x_0)^2+(y-y_0)^2+z^2}}dxdy$$

Where $E_0,\omega,a,b,z$ are known constants.

Now I want to plot a new function defined as:

$$I_p(x_0,y_0)=c\epsilon_0\langle E_pE_p^*\rangle$$ Where $c,\epsilon_0$ are given constants and $\langle \rangle$ is the time average. So the term $e^{i\omega t}$ cancels and we can write the function as:

$$I_p(x_0,y_0)=c\epsilon_0E_0^2\int^{\frac{a}2}_{\frac{-a}2}\int^{\frac{b}2}_{\frac{-b}2}\frac{1}{[(x-x_0)^2+(y-y_0)^2+z^2]}dxdy$$

In an attempt to plot this function I wrote the following code in Mathematica:

z=10;
r[x0_,y0_,x_,y_]:=Sqrt[(x-x0)^2 + (y-y0)^2 + z^2];
E0=1; k=1.15*10^7;
a=10^-3; b=10^-3;
c=10^8; e0=10^-12;
Ip[x0_, y0_] := c*e0*E0^2*Integrate[1/(r[x0,y0,x,y])^2,{x,-a/2,a/2},{y,-b/2,b/2}];

But when I add the following line to get the value of $I_p$ in $(0,0)$

Ip[0,0]

I get an unsolved integral of x. I think also because of this the ContourPlot or Plot3D commands don't work properly too.

Alireza
  • 167
  • 5
  • 1
  • in your definition of r you missed a _ after y0; 2) use NIntegrate rather than Integrate for the numerical integral inIp`.
  • – MarcoB Jun 18 '18 at 22:39
  • @MarcoB the first mistake just happened here. When using symbols from the basic math assistant how can I indicate NIntegrate? – Alireza Jun 18 '18 at 22:46
  • 1
    I am not sure that you can from the palettes. It is best to enter it manually. – MarcoB Jun 18 '18 at 22:48