Real number MSet

Attributed to Russell Walsmith
Written by Paul Bourke
November 2006


int Eval(double cx,double cy,double cz,int nmax)
{
   int n = 0;
   double x1 = 0,y1 = 0,z1 = 0;
   double x2,y2,z2,zz = 0;

   while (zz < 8 && n < nmax) {
      x2 = x1 * x1 - y1 * y1 - z1 * z1 + cx;
      y2 = 2 * x1 * y1 + cy;
      z2 = 2 * x1 * z1 + cz;
      x1 = x2;
      y1 = y2;
      z1 = z2;
      n++;
      zz = x1 * x1 + y1 * y1 + z1 * z1;
   }

   return(n);
}