Julia Set

The Julia set is named after the French mathematician Gaston Julia who investigated their properties circa 1915 and culminated in his famous paper in 1918. While the Julia set is now associated with a simpler polynomial, Julia was interested in the iterative properties of a more general expression, namely z^4 + z^3/(z-1) + z^2/(z^3 + 4 z^2 + 5) + c.

The well known Mandelbrot set forms a kind of index into the Julia set. A Julia set is either connected or disconnected, values of c chosen from within the Mandelbrot set are connected while those from the outside of the Mandelbrot set are disconnected. The disconnected sets are often called "dust", they consist of individual points no matter what resolution they are viewed at.

The basic function, in C++ using OpenGL, to generate this set is:

void renderJulia(void)
{
       int x, y, cnt, maxIter;
       complex z, t, t2;
       maxIter = 256.0;
       imaginaryXJulia = (maxXJulia - minXJulia) / (GLdouble)currScreenWidth;
       imaginaryYJulia = (maxYJulia - minYJulia) / (GLdouble)currScreenHeight;
       for (x = 0, z.x = minXJulia; x < currScreenWidth; x++, z.x += imaginaryXJulia)
       {
             for (y = 0, z.y = minYJulia; y < currScreenHeight; y++, z.y += imaginaryYJulia)
             {
                   t2 = z;
                   cnt = 0;
                   while ((t2.x * t2.x + t2.y * t2.y <= 4) && (cnt < maxIter))
                   {
                         t.x = t2.x * t2.x - t2.y * t2.y;
                         t.y = 2 * t2.x * t2.y;
                         t2 = t;
                         t2.x += julianCoef.x; // x0 is constant
                         t2.y += julianCoef.y; // y0 is constant too
                         cnt++;
                   }
             }
       }
}

The results are quite pretty:








In my program you are able to move coordinate axis with arrow keys, also to zoom in and out with keys Q and A. Also to speed up or slow down zooming with the keys W and S, change colours simply by pressing C.
You can download source, working with Windows and MacOS X prior to 10.9, here: LINK