Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
1  
Have a look at the PlotPoints option –  ssch Oct 31 '13 at 17:40
2  
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
2  
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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.