What's so special about the Mandelbrot set? Its boundary exhibits complicated structure at all length scales from about 1 down as far as you wish (or as you computer will take you) to zero. In other words, it is a fractal . You can experiment with this set yourself using the applet (the implementation of a Java code on a web page) on this page. To do so you need to have a Java compatible browser such as a recent version of Netscape,
What is the Mandelbrot set? It's the the set of all complex numbers z for which the sequence defined by the iteration
z(0) = z, z(n+1) = z(n)*z(n) + z, n=0,1,2, ... (1)
remains bounded. This means that there is a number B such that the absolute value of all iterates z(n) never gets larger than B. A bounded sequence may or not have a limit. For example, if z=0 then z(n) = 0 for all n, so that the limit of the (1) is zero. On the other hand, if z=i ( i being the imaginary unit), then the sequence oscillates between i and i-1, so remains bounded but it does not converge to a limit.
You may ask, what's so special about the particular iteration (1), and why do we use complex numbers instead of real ones. In a sense, the formula (1) is the simplest other than a linear formula which would give rise to a much simpler and quite uninteresting picture. (The analog of the Mandelbrot set would be empty or the entire plane.) If we restricted the iteration (1) to the real instead of complex numbers then again we would get an uninteresting picture: the interval from -2 to 0.
Much of the fascination of the Mandelbrot set stems from the fact that an extremely simple formula like (1) gives rise to an object of such great complexity.
One of the most widely read basic introductions to the Mandelbrot set and other fractals is by H.-O.Peitgen and P.H.Richter, The Beauty of Fractals, Springer Verlag, 1986, ISBN 0-387-15851-0. It contains many spectacular pictures.
I got pretty excited about this program because Java enabled me to create beautiful things so easily. However, when I described the program to a very expert colleague his immediate reaction was the innermost loop must be written in assembly. It's a sad fact that displaying the Mandelbrot set requires a great deal of computation (that will be carried out on your computer). You are best off with a fast machine, drawing small pictures. However, unlike the beautiful but static pictures, this program let's you experiment with the Mandelbrot yourself, and as an applet it is about as widely accessible as is possible. And it's not that slow! I'd be interested in hearing about your experiences. If you have any comments, questions, suggestions, or bug reports, send them to me.
While of course the deficiencies of this code are all my own I wouldn't have been able to write this applet at all without essential help at some major obstacles from several people: Nelson Beebe, Silvia Veronese, and, in particular, Elizabeth Odekirk who has written some beautiful applets herself.
Now, I know you already clicked on that applet! But before you start playing with the windows that popped up on your screen please bear with me for just a little while. I want to tell you about what you see and what you can do with it, and I promise to put the most important stuff first, and become more arcane only as we go on. That way you won't miss anything important, but the more of the remainder of this page you read the more you'll benefit!
You should see two windows, and you can activate up to four.
Going clockwise and starting in the upper left corner let's call these windows
Initially you'll only see the control panel and the drawing window The other two windows have auxiliary functions described below.
To start make sure the control panel and the drawing window do not overlap each other. You can resize those windows if necessary. In particular you could make the drawing window larger (to see more ) or smaller (to see more quickly ). You could even have it cover the entire screen.
Notice that your applet says how to stop the action and kill the windows. You can also quit by pushing the QUIT button in the last row of the control panel, or by typing "q " in any window.
To begin with, arrange the control panel and the drawing window conveniently on your screen and click on the green GO button in the upper left corner on the control panel. You'll see rectangles of decreasing size pop up in the drawing window until eventually the picture of the Mandelbrot set appears. The whole process takes just over one minute on my SGI Indigo Extreme. However, the outline of the Mandelbrot set with most of its detail is visible after as little as 10 seconds. To see small details of the Mandelbrot set takes longer, sometimes up to an hour or more on my system.
Clicking on this picture will generate a much larger version that shows a lot more detail and that took about 6 minutes to generate on my system.
The Mandelbrot set is the dark glob in the center of the picture. The color of the pixels outside indicate how many iterations it took for each of those pixels until our criterion (described above) for being outside the Mandelbrot set was satisfied.
Wouldn't you like to explore some part of that complicated looking boundary? To do so you need to zoom in on your chosen part. Think of a rectangle in the drawing area that includes part of the boundary of the Mandelbrot set. Move the cursor to the upper left corner of that rectangle, depress the mouse button, keep it down, move the cursor to the lower right corner of the rectangle, and then let go of the mouse button. As you do this you will see a rectangle outline your chosen region. If you decide that you don't like the starting point move the cursor outside of the drawing area. As you let go of the mouse button your chosen area will be enlarged and drawn. The computation will start immediately. You can repeat the process, and you don't have to wait until the computation is completed.
Closing in on smaller parts of the structures you see here will reveal similar structures, and so on to infinity! At least that's so in principle. In reality, because of the limitations of the computer system (which uses 64 bit floating point numbers), the program won't let you zoom in on a rectangle that has a side less than 10 to the power negative 13. So try zooming for a bit!
You will notice that the drawing is rough at first and then becomes clearer as the computation proceeds. This actually wastes some time, but it does facilitate zooming before the computation is complete. Suppose you have done all your zooming and you have identified a particularly delectable structure that you want to capture in detail. Do this:
A critical parameter is maxit in the middle row at the very right of the control window. The program works by iterating the sequence (1) for a given point z , say, and if the sum of the squares of the real and imaginary parts of the iterates never exceeds 5 during maxit iterations then the program assumes that z is in the Mandelbrot Set. Of course, it could be that maxit +1 iterations would cause our criterion to be satisfied and z be classified as being outside the Mandelbrot set. So we are not really drawing the Mandelbrot set itself, only an approximation to it that is the better the larger maxit is. The default value for maxit is 100 which is OK for drawing the whole set, but is too small for drawing small parts of it. So as you zoom in you should increase maxit. On the limits of resolution you may want to choose it as large as a few thousand. On the other hand, of course the larger you choose it the longer the computation will take. You may want to experiment with the choice of maxit. The larger you make it the better is the resolution of the fine structure of the Mandelbrot set, and the smaller you choose it the faster the program runs. Like so often in life, you have to balance between two good things that you can't have both!
The rest of this page is taken up with a detailed description of the operation and workings of this applet. Interspersed are a few more Mandelbrot pictures that you can use (via the option menu) as a take-off point for your own exploration.
Consider a rectangle in the complex plane. Suppose we have classified each of the four corners as being inside or outside of the Mandelbrot set. For each corner we have the number of iterations it took to classify the corner. For example, suppose maxit = 100 and we used 5, 12, 100, and 67 iterations to classify the four corners, respectively. Then the discrepancy associated with this rectangle is the difference between the maximum and the minimum iterations counts. In this case it is 100-5 = 95. The fact that the discrepancy is so high suggests that the rectangle contains significant structure.
Suppose now we have a number of such rectangles. The algorithm always considers the most recent of all rectangles that share the highest current discrepancy. It breaks that rectangle into four subrectangles. For each it computes the discrepancy, draws the rectangle with a color corresponding to the average of the four iteration counts, and then puts it on top of the stack of rectangles with the same discrepancy. Next it takes the top rectangle from the stack with the highest discrepancies and processes that rectangle. If the size of the current rectangle is below a certain limit (which you can set) then every pixel of that rectangle is classified and drawn. To begin with, of course the original rectangle is put on a stack.
In that way the algorithm always refines a rectangle with the highest currently present discrepancy. Rectangles with low, e.g., zero, discrepancies, for example those in the interior of the Mandelbrot set, are left to the end. That's the reason why the basic outline of things becomes visible so soon.
The algorithm can store up to 5,000 rectangles. If that limit is reached (which does happen when drawing large pictures) rectangles are classified completely and discarded until enough space becomes available to put new rectangles on the stacks.
Note that the first picture on this page contains several of these little Mandelbrot sets.
Note: Since this is an educational page I'll give you a little home-work problem: Is it possible that the small Mandelbrot sets are identical to the Mandelbrot set? Why or why not? What would be a meaningful definition of the term "identical" in this case? If you like send me your answers to these questions.
Most of the remaining lines have text fields which you can use to enter numbers. To do so highlight the existing number (if present) and overwrite it. Then hit return. If your entry is incomprehensible it will be ignored. There may also be limits on those numbers which the program will enforce.
The first two text fields in the fourth row give the horizontal and vertical extent of the drawing area (in pixels). You can change these numbers and cause the drawing window to be resized. You can also resize the drawing area directly, which will result in an appropriate change in the indicated figures.
You can quit (i.e., stop the computation and get rid of then windows) in several ways:
Each number of iterations is associated with a color that you can see in the color map on top of the color editor. That spectrum corresponds to iteration numbers ranging from 0 to maxit-1. Since the high iteration numbers are on the right of the color map you can think of the Mandelbrot set as being on the right of the Color editor. You can design your color scheme without having to draw test pictures. When doing so it is useful to enlarge the color editor so that it is as wide as possible. If the color map appears too rough you can smooth it out by increasing (perhaps only temporarily) the value of maxit.
Colors are determined by their RGB values, each ranging from 0 to 255. There are three colors used in the package:
Distance in this context is indicated by the number of iterations of (1). Points outside the Mandelbrot set are assigned a color that is a combination, usually a convex combination, of the RGB values of the colors C and F.
You can set those colors by editing the text windows in the color editor. You can also use the choice menus provided. (On my system these sometimes seem to disappear. They are still there, though, just click in the area where they should be. I'm working on this little bug.) The swatches provided show you the color you have currently selected.
In addition there are several options on how to blend the colors C and F, as chosen in the uppermost menu.
a F + (1-a) C(*) where a depends linearly on the number of iterations and is 0 when the number of iterations equals the maximum number of iterations encountered on the last drawing, and 1 when the number of iterations equals the minim number of iterations encountered on the last drawing, and 1
Finally there is a text field for a Factor that generates all the spice in the pictures. The RGB values generated as described above are multiplied by this factor. If it is less than 1 basically everything gets darker and slightly changes its hue. But if it is larger than 1 then the RGB values greater than 255 are mapped back into the range from 0 to 255, which makes for interesting effects. Note that the factor may be negative, and it does not have to be integer. Have fun experimenting!
When you click on these links (which point to binary files) you'll probably see something strange on your system. However, you should be able to download the files properly in spite of their appearance.
Mandel is the class that calls all others. To run the software in standalone mode on a Unix system just type java Mandel in the directory that contains your class files. If you want to base an Applet on your files make sure you specify the code base (the directory containing your class files) similarly as in the html code of this page. The code base must be accessible over the net, otherwise you get a security exception and things don't work right. For a reason I don't understand, on my system the program seems to run faster if run as an applet rather than a standalone application. I'd be interested in your experiences, particularly if you run the program on a machine that provides just in time compilation. I'm told that this will speed up the computations by a factor of several hundred.
If you do download the software I invite you to let me know so that I can put you on my mailing list and inform you about future improvements. Of course, also let me know if you have any troubles.
There is no help information built into the program (at least not yet). This page is intended to be the documentation for the program. So you may want to copy the page, print it, or provide a link to it.
Remember that Java is available for free, and that there's at least one Java compatible browser, i.e., Netscape, that at present is also freely available.
I developed the code on a Unix workstation and there it runs dependably as advertised on this page. Unfortunately I don't have an opportunity to develop the code on Macintoshes or IBM PCs. But I have heard from people who use that kind of equipment, and below you'll find reports on the difficulties they have encountered.
If you encounter a bug or a problem please send me as a complete a description as you can. In particular it would be helpful if you could include a transcript of all Java error messages. You can see these by opening the Java Console in the Options Menu of Netscape. If I can I'll fix the problem, perhaps with your help. I'd also appreciate any suggestions regarding the problems below.
Fine print, your comments, more links, Peter Alfeld, PA1UM[10-Aug-1998]