title: How many iterations of the Mandelbrot set for an accurate picture at a certain zoom?
body: <p>I have implemented the mandelbrot set algorithm in Java which I am using to make an animation of zooming into the set. My problem is that the algorithm is performing very slowly since I have it set such that the maximum number of iterations is high (1000) so that clarity will be preserved when zooming in closely. However, when on a more zoomed-out picture, only around 100 iterations are required to have an accurate picture.</p>
  <p><a href="https://media.giphy.com/media/C9lNldSBctIFpvmGXY/giphy-downsized-large.gif" rel="nofollow noreferrer"><img src="https://media.giphy.com/media/C9lNldSBctIFpvmGXY/giphy-downsized-large.gif" alt="The Mandelbrot set" /></a></p>
  <p>My question is: is there some function <code>f(x)</code> such that for x screen width, clarity will be acceptable? (This only needs to be approximate since the definition of &quot;clear&quot; isn't itself very clear, but the trendline should follow the rate of increase of accuracy which follows the set itself)</p>
  <p>Here is my current implementation of the algorithm:</p>
  <pre class="lang-java prettyprint-override"><code>    private double[] target = {-1.256640565451168862869, -0.382386428889165027247};
  
      // Returns an integer RGB value (0xRRGGBB) representing the colour which should be drawn at a certain position on the screen
      private int getMandleRGB(int x, int y, int w, int h) {
          Complex c = new Complex();
          c.r = lerp(lerp(-2, target[0], 1-zoom), lerp(1, target[0], 1-zoom), x/(double) w);
          c.i = lerp(lerp(-1.5, target[1], 1-zoom), lerp(1.5, target[1], 1-zoom), y/(double) h);
          Complex z = new Complex();
          z.r = c.r;
          z.i = c.i;
  
          int i = 0;
          for (i = 0; i &lt; 1000; i++) {
              z = Complex.add(Complex.multiply(z, z), c);
  
              if (z.i*z.i+z.r*z.r &gt; 4) {
                  double t = Math.log(i)/Math.log(1000d);
                  return (int) lerp((gradient[0] &amp; 0xff0000) &gt;&gt; 16,
                                    (gradient[1] &amp; 0xff0000) &gt;&gt; 16, t)*0x10000
                       + (int) lerp((gradient[0] &amp; 0xff00) &gt;&gt; 8,
                                    (gradient[1] &amp; 0xff00) &gt;&gt; 8, t)*0x100
                       + (int) lerp((gradient[0] &amp; 0xff),
                                    (gradient[1] &amp; 0xff), t);
              }
          }
  
          return 0x000000; // black
      }
  </code></pre>