Understanding Mathematics by Peter Alfeld, Department of Mathematics, University of Utah

The Mandelbrot Set.

Note: All of the Mandelbrot pictures on this page were generated with the applet on this page! You can click on any of them to see a large version, and you can use the applet to generate those very same pictures, or similar pictures all your own!

The first picture ( No1 ) shows a small part of the Mandelbrot set (which is rendered in red).

List of Contents

Sadly, your browser does not support Java. If it did you would not see this message! Get a java compatible browser such as Netscape, of a sufficiently advanced version. In the mean time you can get an idea of what you missed by looking at the still pictures on this page.

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.

Consider this picture ( Title ). The black glob is a small part of the Mandelbrot set. The color of a pixel outside the Mandelbrot set indicates the number n of iterations of (1) that it took until the distance of z(n) from the origin exceeded the square root of 5. It can be shown that when that happens we can be sure the complex number z is not in the Mandelbrot set. You can generate this very same picture (and then modify the color scheme, zoom in, or zoom out) as described below.

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.

Click on this small picture if for some reason what you see is inconsistent with what you read. The large picture you'll see shows what your screen could look like.

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.

This is what you should see. You can generate this picture at any time by selecting the ( defaults ) item in the option menu of the control panel (right next to the QUIT button). The size of the picture will depend on your current settings.

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.

In the end you may come up with pictures like this ( peninsula ) which shows a small detail of the boundary of the Mandelbrot set. Note the small Mandelbrot lookalikes.

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 detail ( mountains ) with lots of interesting areas to zoom in on.

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.

Most Mandelbrot pictures are very colorful and sometimes garish, like some pictures on this page. However, it is also possible to generate pictures of much more subtle beauty. Again, notice the many small Mandel set lookalikes.

The Algorithm

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.

This picture ( little ) show one of the ubiquitous "little Mandelbrot sets". Note that while the Mandelbrot set is usually drawn in black there is no cosmic law that prohibits other colors. It looks quite nice here in blue.

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.

The Control Panel

The first row of the control panel comprises a number of buttons that you can click on to accomplish certain things:

This picture ( coarse ) is the same as the preceding one, except that the value of maxit has been reduced to 100. Clearly this results in major loss of resolution (but perhaps not of beauty).

Text Fields

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 x and y ranges

x and y are the real and imaginary parts of the complex numbers that are being considered. The range text fields give the endpoints of the intervals containing x and y, and dx and dy give their lengths. Note that the upper and lower limits of these intervals may be identical in the text fields, and yet different in their internal representation. Indeed, the program will prevent you from using intervals that have a length less than 10 to the power negative 13. Below that number the coarseness of the number system may interfere with the coarseness of the pixels on your screen.

Drawing Area.

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.

Max. It.

This is the crucial parameter alluded to above. It gives the number maxit of iterations beyond which the starting value of the iteration is considered to be in the Mandelbrot set. The value of Maxit should be the larger the smaller the x and y ranges. It works well to have it range from 100 for the entire Mandelbrot set to as large as several thousands for really small ranges.

The Mouse Position

The two windows in the fifth row of the Control panel indicate the mouse position in the drawing area when the mouse button is depressed. They change as you drag the mouse, and they disappear when you let go of the mouse button and serve as an adjunct to the rubberband rectangle outlining the zoom area.

The swirls in this picture are fascinating to zoom in on. The "rosette" farther down below is one of them. Can you find it?


If the length or width of a current rectangle is below the number indicated in the resolution text field then the rectangle will be rendered completely and finally, rather than broken into four subrectangles. By increasing this number you can reduce the amount of time it takes to generate the final picture, but you also degrade the quality of the intermediate drawings. When drawing final pictures you should set the resolution to a large value to save some time. You can accomplish this by pressing the key "r" while the cursor is in the drawing window, or else you can reset the value manually. To reset the resolution to the minimum value (5) type d in the drawing window.

Status Frequency

This number determines the frequency at which the status window (if present) is updated. A small number means you can see well what's happening, but it's happening somewhat more slowly.

Setting the Aspect Ratio

Clicking on the Aspect button enlarges the x or y range so that the ratio of vertical and horizontal extents of the rectangle in the complex plane equals the corresponding ratio of the drawing area. This ensures that small Mandelbrot lookalikes are not distorted.

Fast or Safe?

This option menu again provides you with a trade-off. The fast option allows your drawings to be drawn about two or three times as fast as the safe option. On the other hand, if you cover up the drawing or close the window containing it the information will be lost. The safe option keeps a second copy of the drawing stored internally and uses it to repaint the drawing whenever your cover or close the drawing window. It is slower and requires more memory. For interactive experimentation the fast option is probably better. Use the safe option to generate a picture while you are doing other things (and perhaps even keep the drawing window closed). You must choose this option before starting a drawing. If you change the option during a drawing the change will become effective only for the next drawing.


The Examples menu lets you choose the values of the parameters as they were used in the generation of the pictures on this page. Close to each picture you should find a statement of which item to choose on the example menu.


You can quit (i.e., stop the computation and get rid of then windows) in several ways:

This picture ( rosette ) illustrates another set of fantastic patterns. The central feature has 17 arms, each of which has several smaller rosettes of the same complexity. The Mandelbrot set itself is rendered in white, and while of course it is present in the picture, only very few pixels are white. Try zooming in on the center or one of the smaller rosettes. You'll see more white pixels but they may be an artifact of maxit being too small!

The Drawing Window.

This is where all the action takes place. While drawing is in process the border of the drawing area is red. When drawing completes the border changes to green. You have the option of a few manipulations:

The Status Panel

This picture was obtained by zooming in on the center of rosette close to the limits of resolution of the computer arithmetic. If rosette was the Milky Way then this picture would cover an area the size of the inner part of the solar system. If the entire Mandelbrot set was the Milky Way the picture would cover an area roughly the size of the Sun. Java does not allow printing floating point numbers to their full accuracy, so I couldn't add the data for this particular image to the program. Future versions may provide an appropriate facility.

The Color Scheme and the Color Editor

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.

Here's another intriguing picture (bay) with lots of interesting parts to explore.

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.

  1. alternating. F and C are assigned depending on whether the number of iterations is even or odd.
  2. adaptive linear. We use a blend of the form
     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
  3. Adaptive Far. The same as in item 2, except that a is replaced by the square of a. This has the effect that the color varies more rapidly far away from the Mandelbrot set.
  4. adaptive close. The same as in item 2, except that a is replaced by the square root of a . This has the effect that the color varies more rapidly close to the Mandelbrot set.
  5. The next three items, linear, far, close, are like the preceding ones, except that a ranges from zero to 1 as the number of iterations ranges from Max. It. to zero.
  6. Psychedelic. assigns a color that is essentially random to each possible number of iterations. The precise assignment depends on your choice of F and C, feel free to play experiment!

Mandelbrot pictures don't have to be colorful, of course. This one of the tip of the Mandelbrot set is rendered in gray scale.

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!

Running Standalone and Downloading

You may download the byte code of this software and incorporate it into your own web pages or run it on your system in a standalone mode. You need the following Java classes:

This picture shows another interesting feature that occurs in many places. The turn in the center of the picture looks like the big picture on a large range of length scales! Try it! Zoom in and out and see what you find. You want to keep the aspect ratio close to 1.

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.

Bugs and Idiosyncrasies

Now that this page has been up for a while I have come to understand that actually Java is not as portable and widespread as the books on it like to claim. Most accesses to this page do not use the applet, and I assume that in most cases this is because the browser is not Java compatible. This situation may of course change in the future (and I hope it will).

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.

Unix systems


The main problem with Macs seems to be that the Mac operating system intercepts the mouse action and tries to interpret it as a command to itself. This has the following effects:

IBM PCs, Windows

Related Links

This section is under construction. Send me suggestions of which links to include.

Fine print, your comments, more links, Peter Alfeld, PA1UM