# Complex Integration Optimization

The following code culminates in plots calculated for each value of t as given below.

I have tried compiling one of the functions and adjusting the precision of both the integration and the plotting but the lessened accuracy introduced obvious errors in the plots and the run-time did not decrease profoundly.

I do not have a C compiler installed.

I would like to improve the running time as much as IImproved formatting can.

φprep := Compile[{{x,_Real}, {k,_Real}},
Sum[((E^(I*n*k))*(E^(-4*(x-n)^2))),{n,-500,500}]*(8/Pi)^(1/4)]
φ[x_?NumericQ, k_?NumericQ] := φprep[x, k]

f[k_] := -(1.5*10^15) + ((-0.3*10^15 )Cos[k])
g[k_] := Sqrt[20/Pi]*E^((-20^2/Pi)*(k-Pi/10)^2)

ψ[x_,t_]:= NIntegrate[g[k]*φ[x, k]*E^(-I*f[k]*t), {k, -∞, ∞}]

tValues = {
0.0,
4.0 * 10^-13,
8.0 * 10^-13,
1.2 * 10^-12,
1.6 * 10^-12,
2.0 * 10^-12,
2.4 * 10^-12
};

xMin = -100; xMax = 400; yMin = -0.5; yMax =0.5;

Table[
Plot[{Re[ψ[x, t]], Im[ψ[x, t]]}, {x, xMin, xMax},
PlotRange -> {{xMin, xMax}, {yMin, yMax}},
PlotStyle -> {Thick},
ImageSize -> 500],
{t, tValues}]

-
Isn't your $\phi$ just an approximation for a constant multiple of E^(-4 x^2) EllipticTheta[3, 1/2 (k - 8 I x), 1/E]? It is obtained by extending the summation from $-\infty$ to $\infty$. –  whuber Mar 12 '13 at 3:04
add comment