We need to do a ContourPlot for the following function $H[x,y,n]$:

f[x_,y_,k_,n_,c_] := 
Gamma[c + (I/2)(x + I*y), k^2*(Pi/n), 
   k^2*Pi n]/(k^2*Pi)^(1/4 + (I/2)*(x + I*y));

g[x_,y_,k_,n_,c_] := f[x,y,k,n,c] + f[-x,-y,k,n,c];

H[x_,y_,n_] := 
 Sum[(3/2)*g[x,y,k,n,5/4] - g[x,y,k,n,9/4], {k, 1, n}];

The command for contour plot is:

n = 6;
ContourPlot[{Re[H[x, y, n]] == 0, 
Im[H[x, y, n]] == 0}, {x,-1,35}, {y,-1,35}, 
AxesLabel -> {"x", "y"}, PlotPoints -> 50]

The problem we are having is that for bigger $n$, like $n=12$, it takes too long (more than 30 min on my laptop (Intel i7 CPU, 16G memory) with Mathematica 11.3) to complete the plot.

Question Is there a way in Mathematica to speed up the evaluation and the plotting of such function?

Thanks a lot!

  • 1
    $\begingroup$ One thing to try is using _?NumericQ in all the definitions, i.e. f[x_?NumericQ, y_?NumericQ, k_?NumericQ, n_?NumericQ, c_?NumericQ] := Gamma[c + (I/2) (x + I*y), k^2*(Pi/n), k^2*Pi n]/(k^2*Pi)^(1/4 + (I/2)*(x + I*y)); etc. With my AMD Ryzen 5 2600 it takes about 8 min for n=12. But ContourPlot is often very slow, Stephen mentioned this in his livestream in a sense that developers have to finally "solve" this old known "feature" and speed up ContourPlot. $\endgroup$ – Alx Sep 27 at 8:53
  • $\begingroup$ @Alx I will try it. Thanks! $\endgroup$ – mike Sep 27 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.