# Taking long time to give output

Following code does not give any output. I kept it running for nearly 6 hours does but it does not give the output. What is the wrong with that?

a = 40.397;
b = 0.525;
c = 0.015000098827516313;
d = 0.000000001;
δ = 0.0095;
σ = 0.020

g2 = Plot[Convolve[Re[Erfc[(δ + I*x)/(Sqrt[2]*σ)]/ E^((x - I*δ)^2/(2*σ^2))],
a*UnitStep[x - b]*c* Sqrt[x - b]*
((Pi*(Sqrt[d]/Sqrt[x - b])*Exp[Pi*(Sqrt[d]/Sqrt[x - b])])/
Sinh[Pi*(Sqrt[d]/Sqrt[x - b])]) +
a*d*Sum[((4*Pi)/n^3)*DiracDelta[x - b + d/n^2], {n, 1, 1}],  x, y],
{y, 0, 1.4}, PlotStyle -> {Black}, PlotRange -> All]

• I changed. Is it clear? Oct 21, 2018 at 3:08

Try this

a = 40.397;
b = 0.525;
c = 0.015000098827516313;
d = 0.000000001;
δ = 0.0095;
σ = 0.020;
f = Convolve[Re[Erfc[(δ + I*x)/(Sqrt[2]*σ)]/E^((x - I*δ)^2/(2*σ^2))],
a*UnitStep[x - b]*c*Sqrt[x - b]*((Pi*(Sqrt[d]/Sqrt[x - b])*
Exp[Pi*(Sqrt[d]/Sqrt[x - b])])/Sinh[Pi*(Sqrt[d]/Sqrt[x - b])]) +
a*d*Sum[((4*Pi)/n^3)*DiracDelta[x - b + d/n^2], {n, 1, 1}], x, y];
g2 = Plot[f, {y, 0, 1.4}, PlotRange -> All]


which appears to finish in about a minute.

Please check this very carefully to make certain that it is correct.

• You could also wrap Evaluate[] around your Convolve[...] and get about the same speedup. Either precomputing f or using Evaluate will do most of the calculation once and then let Plot use that result, instead of having Plot repeat most or all of the Convolve calculation again and again for every one of hundreds or thousands of points.
– Bill
Oct 21, 2018 at 4:28
• Thank you very much Oct 21, 2018 at 4:29