Login Ross Plays with the Mandelbrot Set September 09, 2010 09:19 AM (PDT)





 

Ross Plays with the Mandelbrot Set

by ross
 

Ryan had urged me to read the book Chaos by James Gleick. This book gives a great description of the Mandelbrot set. After Ryan read it, he wrote a program in C to compute the Mandelbrot set and output files for POVRAY. When a potential employer asked if I had a more complex code sample, I decided to write my own version of the Mandelbrot computation.

I wrote the program in C++. The program outputs an image file in ppm (portable pixmap) format. This image format is very easy to create, but not space efficient. The images you see in this bit have been converted from ppm to gif using the ppmtogif program.

In Figure 1, you can see a full view of the Mandelbrot set. The black areas are the Mandelbrot set. Points outside the set range from red to white, depending on the amount of calculation needed to determine whether the point is in the set or not. The more calculation required, the "redder" the point. See the top nodule of the set? Looks like part of a snowman? Figure 2 is a zoom on this nodule. You can see that there is another snowman-like nodule on top of this one. If we zoom in again on this new top nodule (Figure 3), we see the same thing. We could keep zooming and zooming and still see the same thing for infinity.

Now look at Figure 2 again. See where the nodule meets the main part of the set? What is going on there? I zoomed in on the left part of this area in Figure 4. It is another representation of infinity - you keep zooming and it looks the same. So it appears to me that the nodule is not really touching the main blob, but it is infinitely close. Lastly, take a look at Figure 2 again. See that little "island" in the upper left? It kind of looks like a tiny Mandelbrot set. In figure 5, I have zoomed in on that island. It looks like a slightly rotated version of Figure 1.

Fascinating, isn't it? Especially considering that the computation of the set is actually very simple. A series of straight-forward, iterative mathematical operations produces the amazing complexity you see in these pictures. If I get the urge, I might play with the color scheme to try to create some really dazzling images.

Fig. 1 - A full view of the Mandelbrot set.
default program parameters


Fig. 2 - Zoomed in on the top nodule.
./mandelbrot -maxr .18 -minr -.4 -mini .6 -maxi 1.1 -s 0.0008 -m 250


Fig. 3 - The second zoom is very similar to the first.
./mandelbrot -maxr -.01 -minr -.2 -mini .8 -maxi .93 -s 0.0003 -m 300


Fig. 4 - The left side of top nodule's "connection" to the main blob.
./mandelbrot -maxr -.127 -minr -.15 -mini .648 -maxi .653 -s 0.00003 -m 700


Fig. 5 - The "island" looks remarkably like the Mandelbrot set.
./mandelbrot -maxr -.14 -minr -.18 -mini 1.02 -maxi 1.05 -s 0.00008 -m 250