I want to solve the following integral numerically with Mathematica:
$\int_{0}^{L_x}\int_{0}^{L_y}\int_{0}^{L_z}d^3x'\frac{\sin^2(\frac{x'\pi}{L_x})\sin^2(\frac{y'\pi}{L_y})\sin^2(\frac{z'\pi}{L_z})}{|x-x'|}e^{i\omega |x-x'|}$
But I am not getting the result which I expect. Therefore I have the feeling that Mathematica cannot deal with the singularity of the integrand ($x\in [0,L_x]\times[0,L_y]\times[0,L_z]$). By the way: Does anyone know how to prove if the integral is finite?
I already tried different Methods/MinRecursion/MaxRecursion/MaxPoints in NIntegrate which more or less all yield the same result.
Here is my code:
Lx = 0.09;
Ly = 0.03;
Lz = 0.4;
f = 10*10^9;
c = 3*10^8;
omega = 2*Pi*f/c;
x = 0.045
y = 0.015
z = 0.15
B0 = Sin[Pi*xs/Lx]^2*Sin[Pi*ys/Ly]^2*Sin[Pi*zs/Lz]^2;
Integrand = B0/((x-xs)^2+(y-ys)^2+(z-zs)^2)^(1/2)*Exp[I*omega*((x-xs)^2 +(y-ys)^2 +(z-zs)^2)^(1/2)];
NIntegrate[Integrand, {xs, 0, Lx}, {ys, 0, Ly}, {zs, 0, Lz}];
The thing which worries me a little is that when I use Lx=0.09, Ly=0.03, Lz=0.4 and evaluate the integral at (x=(0.045,0.015,0.15)m) I get -0.00508-i 0.000606. But when I evaluate it at (x=(0.044,0.014,0.15)) I get -0.00024+0.000198. So there seems to be a discontinuity at (x=(0.045,0.015,0.15)m). All other points ($x\in [0,L_x]\times[0,L_y]\times[0,L_z]$) yield a much smaller results than the point at (x=(0.045,0.015,0.15)m). When I plot the results in the xy plane I have to exclude this point such that one can see the structure...
All comments are welcomed.
Many thanks in advance.
xyz
is not defined. $\endgroup$x = x'
,Sin[0]/0
converges whileCos[0]/0
does not. Try rationalizing all your numbers, increasing yourWorkingPrecision
and play withSin[omega ...]
instead ofExp[I*omega ...]
. When I do that I get closer numbers for the two data sets than you. $\endgroup$