Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could someone please tell me how I can increase the accuracy of this plot, please? Or is there some other reason the lines are breaking up?

m = 60;
ContourPlot[{Re[Table[BernoulliB[n, (x + I y)], {n, m, m}]], 
Im[Table[BernoulliB[n, (x + I y)], {n, m, m}]]}, {x, -5, 6}, {y, -10, 10}, 
AspectRatio -> Automatic]

enter image description here

share|improve this question
Have a look at the PlotPoints option – ssch Oct 31 '13 at 17:40
In addition to PlotPoints, you can increase MaxRecursion too (carefully, increasing it by 1 at a time, as running time depends exponentially on this parameter). Try MaxRecursion -> 3 without touching PlotPoints. – Szabolcs Oct 31 '13 at 17:43
PlotPoints -> 200 fixes the problem. – bill s Oct 31 '13 at 18:18
Thank you very much for your help on this :-) – martin Nov 1 '13 at 10:54
up vote 5 down vote accepted

As you already know from the comments, increasing MaxRecursion or PlotPoints helps, where I would prefer the first one.

In the case of your function, you can gain some speed by compiling the expression. Then, you can set MaxRecursion to a higher value and the plot is still reasonable fast. The code below runs in about 3 seconds here

m = 60;
With[{cf = (Compile[{{x, _Real, 0}, {y, _Real, 0}},
        #, RuntimeOptions -> "Speed", CompilationTarget -> "C"] & /@

           Flatten[{Re[Table[BernoulliB[n, (x + I y)], {n, m, m}]], 
        Im[Table[BernoulliB[n, (x + I y)], {n, m, m}]]}])},
  (#1[args__?NumericQ] := #2[args]) & @@@ Transpose[{{f1, f2}, cf}]

ContourPlot[{f1[x, y], f2[x, y]}, {x, -5, 6}, {y, -10, 10}, 
 AspectRatio -> Automatic, MaxRecursion -> 3]

Mathematica graphics

share|improve this answer

Simple and fast solution

m = 60;
f = Evaluate@N@BernoulliB[m, #] &;

ContourPlot[{Re@f[x + I y], Im@f[x + I y]}, {x, -5, 6}, {y, -10, 10}, 
 AspectRatio -> Automatic, MaxRecursion -> 3]

enter image description here

It has the same speed as halirutan's solution with Compile. I think it is because of auto-compilation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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