title: How to Improve Accuracy of Iteration?
body: <p>I'm trying to make code, c++, to plot the Mandlebrot Set. However, whenever I run my code, see below, the convergence is poor. How do I fix that? I provided some code below. There's also a screenshot of the Mandelbrot Set, red, and my code's approximation, greyscale. </p>
  
  <pre><code>  #include &lt;GL/glut.h&gt;
  
  void renderscene(void) {
  
    double x=0;
    double y=0;
    double ix=0;
    double iy=0;
    int n=1;
  
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
    for(x=-3;x&lt;3;x=x+0.01){
      for(y=-3;y&lt;3;y=y+0.01){
  
        for(n=1;n&lt;50;n=n+1){
          ix=ix*ix-iy*iy+x;
          iy=2*iy*ix+y;
          if(ix*ix+iy*iy&gt;4){
            break;
          }
        }
  
        ix=0;
        iy=0;
  
        glPointSize(1);
        glColor3f(0.1*n,0.1*n,0.1*n);
        glBegin(GL_POINTS);
        glVertex2f(x*0.4,y*0.4);
        glEnd();
      }
    }
  
    glutSwapBuffers();
  
  }
  
  
  int main(int argc, char **argv) {
  
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowPosition(300,200);
    glutInitWindowSize(500,500);
    glutCreateWindow("Hello");
  
    glutDisplayFunc(renderscene);
  
    glutMainLoop();
  
    return 1;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Ezj71.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ezj71.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/EWfnQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EWfnQ.png" alt="enter image description here"></a></p>