1
$\begingroup$

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]
$\endgroup$
1
  • $\begingroup$ I changed. Is it clear? $\endgroup$
    – Tharaka
    Oct 21, 2018 at 3:08

1 Answer 1

3
$\begingroup$

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]

enter image description here

which appears to finish in about a minute.

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

$\endgroup$
2
  • 2
    $\begingroup$ 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. $\endgroup$
    – Bill
    Oct 21, 2018 at 4:28
  • $\begingroup$ Thank you very much $\endgroup$
    – Tharaka
    Oct 21, 2018 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.