From the definitions, the key property is that if the absolute value of the complex number, |z|, is larger than 2, then the sequence will diverge. Thus, every member of the Mandelbrot set has to be confined within a disk of radius 2 centered at the origin. Therefore, we can limit ourselves to this region of the complex plane as other values need not to be considered. If we consider the Julia set of quadratic polynomials, then the subset of complex numbers c which converge under iterations will form the Mandelbrot set.

The code for the Julia set can be found here here . To run it, save it as "julia" and then run it in root.

The Julia set code is mostly recycled code from the Mandelbrot set code, the only changes are in the definition of the iterated function and adding a nonzero complex number c as an additional initial condition. To change the output of the Julia set code, simply change the value of c to some arbitraty complex number. However, to get some intresting fractal structure, the value of c needs to be a member of the Mandelbrotset. There are a lot of nice looking graphs emerging from different values of c in the Julia set. As the behaviour is chaotic, small changes in this initial condition alters the global structure completely.

The code is already commented with the most relevant information to what the code does, however brief. The first thing one notices when looking at such fractal patterns is the colors of the graph. I have arranged it in such a way that for each pixel, the color of said pixel is related to how fast the that point diverges to infinity. If the function for a given pixel (complex number c), stays within the bounded region after a threshold number of iterations(100), then it is given a color value of 0. In root graphics this is white. A white region of the plane means that the complex number at that region is a member of the Mandelbrot set. The dark blue regions corresponds to subsets of the complex plane where the iterated points diverge rapidly. An overview of how fast points diverge is included in the Mandelbrot graph.

For the paramaters I set the width and height of the canvas to 1000x1000 and the number of iterations to 100. These parameters are of course chosen arbitratily, but they give a good resolution and the runtime is not that long (under a minute). The spatial resolution is good enough such that you can see the fractal pattern clearly. A higher resolution would not be useful as the marginal effect on the picture would not outweigh the runtime. The choice of coloring is also arbitrary, but useful as it is an easy way to get a nice image. One can change this however one likes depending on what sort of colored graph is desired. For example you can simply change the points which are in the set by returning a value other than zero.

In my code I include the "complex" class which makes life easier essentially. It knows complex numbers so that you don't have to write z out as a real plus an imaginary number. This simplifies calculations in a few places as for example you can just write abs(z) instead of the square root of a*a + b*b for z=a+bi.

To open the ppm formated pictures in Windows you need to install a program which can actually open the format. I used IrfanView 64 for this part. It is quick to download and does the job. I you only want the ppm generated pictures, I found an easy way was to just have the code in C++ and then just removing the root parts of the code. If you then just change from mandelbrot() /julia() to main(), it should do the job. Doing it this way, you can generate a lot of pictures in a short time.

The last two rows of pictures cleary do not cover the same regions in the plane. I did it this way as in my opinion this illustrates the point of fractal geometry and fractal structures. As fractals are self-similar under scale translations one cannot say which of these two images is the "largest" one, that is, covers the largest region of the plane. For all you know, the right pictures may be zoomed in or out a million times relative to the left pictures.

The left columns of pictures, those generated with TCanvas serve as an analytical way of measuring divergences. It adds a much more qualitiative ascept to the complex dynamics going on as it has numbers describing it and statistical quantities. The pictures in the right column are artistic. They look more elegant, as they sacrifice information for beauty essentially. You still get the same fractal pattern, and for illustrative purposes they are in my opinion preferred.