Mandelbrot set explorer

This is a demo that I wrote for my students so that they can explore the Mandelbrot set. It offers a couple of nice convenience features and can compute with unlimited precision. (See more below.) The program was created using the Common Lisp compiler from LispWorks. You can download it (as a 32-bit Windows executable) from http://weitz.de/files/Mandelbrot.zip.

You are free to use this software for private or educational purposes. (But you are of course using it at your own risk.) However, redistribution of any kind is not allowed without written permission. If you want to give this program to someone else, point them to the original download location at http://weitz.de/mandelbrot/.

Where you can travel by clicking with your mouse How long you'll have to wait Yours truly The traffic light How much you can trust the program How many things your PC can do at the same time How far away from home you are What you see How to start from scratch How to take notes How to make a photo for your loved ones If you want to go back What to do if the traffic light is yellow How to make everything look smoother What to do if you want more colors The power of your magnifying glass How much work your computer is supposed to do How you can make the program leaner and meaner Screenshot

[CLICK ON THE VARIOUS PARTS OF THE IMAGE ABOVE FOR MORE INFORMATION.]


 

Documentation

[The documentation describes the Windows version of the Mandelbrot set explorer. Some features will be missing in the Linux and OS X versions and some things will be different there.].

  1. Basic usage
  2. Mouse interaction
  3. The 'traffic light' application status indicator and the progress bar
  4. The control panel
  5. Undocking the control panel
  6. Resizing the window
  7. Unlimited precision
  8. Configuration files
  9. Keyboard shortcuts

 

Basic usage

The application will usually start with a square window with width and height 4 and centered on the complex number 0 so that you can initially see the whole Mandelbrot set. The center point's real and imaginary part as well as the width and height are shown in the control panel on the right.

If you click somewhere into the picture, it will be zoomed, i.e. the point where you clicked will become the new center and the width and height of the area shown are divided by the current zoom factor. (The values in the control panel will be updated accordingly.) While your PC is computing the new picture a rectangle will briefly show which part of the 'old' picture it will capture.

If you want to go back to where you've been before, just press the Back button. You can do this repeatedly until you're back at where you started -- or use the Home button as a shortcut for this.

While the Mandelbrot set itself is always depicted in black, there are different ways to color its complement. Try to experiment by selecting different values from the Palette drop-down box or by unchecking the Normalized check box.

Once you've zoomed a couple of times you should increase the number of iterations in order to see a more detailed picture.

If you've come across an image that you'd like to keep, you can press the Save Image button to store it on your hard disk. (This is not implemented for OS X.)

And now for all the dirty details...


 

Mouse interaction

Clicking somewhere into the picture means zooming - see above.

If you right-click instead, a context menu will show the real and imaginary part of the point you clicked on. You can also zoom immediately from this menu. As usual, such a menu can be dismissed by pressing the Esc key.

If you move the mouse while pressing the Ctrl key, a rectangle will show where you would be taken if you zoomed at the mouse position with the current zoom factor. The application will also remember the last rectangle position for the Z key action. (This is not implemented for OS X.)

If you move the mouse while pressing the Shift key, you'll move the image within the application's window, i.e. you kind of pan the 'camera' you're exploring the Mandelbrot set with. This will invalidate the application's status and you'll then have to refresh manually.


 

The 'traffic light' application status indicator and the progress bar

At the bottom of the control panel you'll see a small square which is green on startup. This is the 'traffic light' which can also be yellow or green. If it is red, the application is currently busy and no interaction is possible. If it is yellow, you've panned or resized the image or you've changed the number of iterations - all of which means that the image you see is currently not in sync with what you want to see. You'll have to refresh to change this and get a green light again.

Below the image is a progress bar which'll give you a rough indication on how long you'll have to wait until your computer has finished a lengthy computation (i.e. when the traffic light is red). The progress bar only kicks in if the program thinks the computation will take a while. (This decision depends on heuristics and might be wrong, e.g. if you have a slow PC or if the majority of the region you're exploring consists of black pixels.)

Also, please note that the progress bar only shows the actual computation in the complex plane - it doesn't take into account drawing operations. So, if you have a slow machine and a large screen it might take some time until you see an image even if the progress bar signals that everything's done.


 

The control panel

The part of the application on the right side of the Mandelbrot set picture with all the combo boxes and buttons is called the control panel. The individual components are explained in this section. (See below for how to get rid of the control panel.)

You will probably know that the image you see is only an approximation. (Mathematical footnote: In the Blum-Shub-Smale model of real computation, the Mandelbrot set is not computable. And even if it were, your computer wouldn't know how to deal with irrational numbers...) Your PC computes, for each pixel, a couple of iterations of the Mandelbrot formula. If, during these computations, (the modulus of) one of the intermediate results becomes too big, it can be sure - except for rounding errors - that the point in question doesn't belong to the Mandelbrot set. For many points it can never be sure whether they do belong to the set, though. So it simply has to give up after a certain number of tries and call it a day. You can change this threshold using the Iterations combo box. [Keyboard shortcuts: UpArrow and DownArrow.]

You should increase the number of iterations if you've zoomed in a couple of times. Larger values result in more detailed pictures - especially at the boundary of the Mandelbrot set - but will make the program slower.

The Zoom factor combo box controls by how much the section of the complex plane you're looking at will be enlarged when you zoom. The smallest possible value is (approximately) the square root of 2 and each other value is the previous one multiplied by this root. (Internally, the values used are more precise than what is shown in the combo box.) If you change this factor, the size of the corresponding zoom rectangle will be shown briefly. [Keyboard shortcuts: + and -.]

You can change the way points outside the Mandelbrot set are rendered by selecting different color palettes from the Palettes combo box. The first palette (numbered 0) will color all of these points in white. All other palettes will use different colors depending on how long it takes for a point to 'escape' from (being suspected to be a member of) the Mandelbrot set. The program will at startup select one of the palettes (except for the first one) at random. [Keyboard shortcuts: 0 to 9 and A to E.]

The color palettes were created by Paul Gentieu and are used with his kind permission.

If the Normalized check box is unchecked, the color of a pixel will only depend on the number of iterations it took to decide whether it should be drawn in black or not. If the box is checked, the color is computed in a more elaborate way which takes into account how 'close' the point was to escaping on the penultimate iteration. (The mathematical details are explained here.) This will usually result in smoother color transitions. [Keyboard shortcut: N.]

Because of the extra cost in computational complexity, the normalized rendering of colors is disabled when fixed-point arithmetic is used.

Use the Refresh button to recompute the image in case the traffic light is yellow. This will be necessary if you've panned or resized the image or if you've changed the number of iterations. [Keyboard shortcut: R.]

Use the Back button to go back to where you were the last time you changed your view into the complex plane. The details are as follows: The program always knows which complex number is represented by the image's center point and how large the rectangular area of the complex plane currently shown is. If you pan or zoom or press the Home button, these values will be pushed onto a stack. Pressing Back means that the topmost datum is popped from the stack and the corresponding values are used to redraw the image. [Keyboard shortcut: Backspace.]

Note that resizing will not affect this stack (although it might enlarge the area shown). Likewise, pressing Back will not switch back to previous color palettes or iteration values.

Press the Save Image button to save the current image to your hard disk. You'll have the option to choose between the image file formats PNG, JPEG, TIFF, and BMP. [Keyboard shortcut: S.]

Press the Save Config button to save the current configuration. See the section about configuration files for details. [Keyboard shortcuts: F or G.]

Press the Home button to go back to where you were when the application started. This is usually a rectangle of the complex plane with zero in the center and just enough space around it to show the complex numbers 2, -2, 2i and -2i - but it can be somewhere else if you were using a configuration file. [Keyboard shortcut: H.]

In the area below the Home button, various information is shown and continually updated:

The first four values are the (real and imaginary part of) the image's center and its width and height. You'll see floating point approximations of these values, but internally they are stored as exact fractions.

The Zoom value tells you how much you've zoomed in from the point where you started (or from the last time you pressed Home). Zoom factors are meant relative to point distance, i.e. a zoom value of, say, two means that the area of the image you're looking at is one-fourth of the original area.

The Threads value tells you how many computational threads will run concurrently when an image is refreshed. The program tries to pick a reasonable default value based on the number of processors (cores) your computer has. You can override this with a configuration file, though.

The Precision value shows the precision the program currently used to compute the image. More details can be found in the corresponding section.

The small colored square at the bottom is the 'traffic light'.


 

Undocking the control panel

The control panel can be 'undocked' and thus converted into a 'floating' window by dragging the tab at its top or by pressing the U key. You can also, if you like, close this window completely to get more screen real estate. (You don't really need it as everything can also be done with the mouse and with keyboard shortcuts.)

You can 'redock' the control panel by dragging it back into the main window or by pressing the Space key. (This will also work if the control panel is no longer visible.)


 

Resizing the window

You can resize the main window (and thus the area used for the image) at any time by dragging its corners or edges. This will set the 'traffic light' to yellow which means you'll have to refresh to actually see a larger (or smaller) image.

Note that it's the application's policy to always keep track of the center point and which area of the complex plane around it is shown. Resizing the window will not change the center point but might increase this area. (It will never decrease it.) Also, the scale of the real axis and the imaginary axis will always be equal even if the image is not a square.

If you mix panning and resizing in one step (without a refresh between these actions), the program tries to 'do the right thing'. This might not be what you want, though. Also, if you just pan the image a bit without doing anything else, a refresh will be considerably faster.


 

Unlimited precision

The program will initially use 64-bit floating-point numbers for its computations. If, at high zoom rates, it figures out that this wouldn't be accurate enough anymore, it automatically switches to a home-grown fixed-point arithmetic with a variable bit size. (The current bit size will be shown in the control panel.) In theory, this means that the program is capable of using a precision that is only limited by your computer's memory. In practice, you'll never figure out where the actual limit is as of course everything becomes a lot slower with higher precision.

Because of the significant decrease in speed, a warning will be shown the first time fixed-point arithmetic is used and the precision information will be shown in red. Also, normalized rendering of colors will be disabled until you switch back (by zooming out) to floating-point.


 

Configuration files

The program will at startup check if there's a configuration file called mandelbrot.cfg in the same folder. If it finds such a file, it will try to parse it and use this information to change certain default values. Configuration files must be text files consisting of lines that look like this:

<name>: <value>
where <name> is one of the strings (case doesn't matter) listed below and <value> is (usually) a number. Numbers are either integers written in the usual way or rational numbers written like -22/17. (Numbers with a decimal mark are not allowed.) Empty lines and lines starting with a number sign (#) are ignored.

The allowed name/value pairs are listed below:

You can also at any time save a configuration file so that you can later restart the program in exactly the same state you left it. (Note that you'll always start with a zoom value of one.)

Here's an example configuration that I've used in lectures to explain the Mandelbrot set. It starts without colors and with the minimal number of iterations and from there you can use Shift-UpArrow to see how the shape evolves.

Iterations: 1
Palette: 0
Re: 0
Im: 0
Width: 4
Height: 4


 

Keyboard shortcuts

Everything that can be done with the control panel (and more!) can also be done with the keyboard (so it is safe to get rid of the control panel). Here's a list of all keyboard shortcuts:

All character shortcuts work in both upper and lower case. Note that the input focus needs to be on the pane showing the Mandelbrot set in order for the keyboard shortcuts to work. (This should almost always be the case unless you've undocked the control panel.) Most of the control panel's elements have tooltips associated with them that show their keyboard shortcuts.


 

 

Impressum, Datenschutzerklärung