Mandelbrot Set Program November, 1987 John Futhey 516 Maria Dr. Petaluma CA 94952 (707) 763-9252 There are three files: Mandel.exe, Mandel.scn, and Mandel.doc. Mandel.exe is the program and is called by just typing "Mandel". Mandel.scn is a data file of the full Mandelbrot set (this loads automatically), and Mandel.doc is the documentation which you are reading. This program requires EGA to run. IMPORTANT -- Adjust the brightness and contrast of your monitor for high color quality. For a mathematical description of the Mandelbrot Set, see the appendix at the end of this documentation. Some comments about the program and how to use it: 1. The program is very user friendly (really!). The function key assignments and directions are on view at all times so you need not memorize strange key combinations. For certain critical commands, there is an "undo" function so you may retreat if you change your mind or get somewhere by mistake. 2. The full Mandelbrot set is automatically loaded when you start the program and is in memory at all times. Just a keystroke will bring it to view. A specially selected palette provides excellent color blending. 3. In general, one goes hunting for the hidden, intricate, and beautiful detail contained in the set. The most fruitful areas to search will usually be in or around the complex borders of the black areas (see appendix). Like a microscope, you are going to zoom in on a small portion of the full set and then enlarge it to see what wonders it may reveal. This program provides two ways to do this. a. If you know the x and y coordinates and width of a region, you can manually input these numbers and the program will start its gruesome calculations. For instance, an interesting area is at xcenter=-.1364953, ycenter=1.0049645 and has width=.0019288 (try it). b. A more intuitive way is by using a graphical box. Turn the box on, (F3), then move it around the screen with the direction keys, shrink it or expand it (coarse or fine increments) until it encompasses the region of your inter- est, then just hit F10 (begin plotting), and the computer does the rest. (As you move the box, its position and size will be shown at the bottom of your screen.) 4. Once you have found a region you like and there it is in all its glory, you may save it to a screen file (I prefer *.scn for these, but use what you like). Then later, you can call it up from your disk. (It takes much less time to call up a saved file than the time for the original plotting, so this makes sense.) 5. You always have the full Mandelbrot Set in memory, and can view it by using F1, the screen toggle key. If you have either plotted a second screen, or called one up from a file, you can toggle between this one and the full set. (They are big, so you only have two of them, the full set always, and your most recent other one.) 6. Color, color, color! That's why you got your EGA and here is a chance to show it off. F9 is the color key and it brings up a separate menu. You may choose from 5 special palettes of blended shades. You may even mix any two of them for more fun. In addition, you have the defalt palette. (If your eyes can stand it, try the electric palette!) You don't have to learn the intricacies of EGA palettes, just pick a letter. Finally, you may step through colors and watch the figures on your screen move and twist. Mikey likes it. 7. As you may know (see appendix again -- sorry), the Mandelbrot Set is determined by a recursion procedure which tests for a con- dition. For great accuracy of detail, one needs to have a very large recursion limit -- at the expense of the time it takes to generate a full screen. If the recursion limit provides detail that is finer than the resolution of the screen, it is wasted effort, yet when you really zoom in, if the limit is too small, you lose the richness you're looking for. This program utilizes an auto recursion limit, i.e., it sets the recursion limit as a function of the amount of zoom you're using. One result you buy into with this scheme is that the further you zoom, the longer it takes for the program to run. (This can amount to several hours for an older 4.77 Mhz machine.) 8. If you are plotting an area and the results are disappoint- ing, you don't have to wait for the screen to complete. Just hit any key to stop the procedure. But perhaps there is an interest- ing region within the small portion that you did plot; well, just turn on your zoom box, go to it, and start again. In other words, you can zoom from a zoom! One note: there is a limit to your zooming -- eventually the computer just can't deal with it. As a rule of thumb, if the width of your box (or manual input) is less than .00002 or so, you may start to run into trouble, or even crash the program. 9. Time for the commercial now. This is shareware, and I encourage you to provide it free to your friends (or enemies), upload it to your favorite bulletin board, etc., but you may not sell it. Furthermore, if you appreciate it enough, please send me some money for my effort. If you send $20, I will send you a diskette (5.25" only) with 5 excellent screen files that I have captured in my wandering through the Mandelbrot jungle. Then you only have to load them instead of search for and generate them yourself. (Time is money) Please send to: John Futhey 516 Maria Dr. Petaluma CA 94952 Thanks Appendix The Mandelbrot Set was discovered by -- and named after -- Benoit Mandelbrot, and is a special case of a broad study called fractal geometry. There is a facinating account, with lovely color pho- tos, of this rich curiosity in the July 1985 Scientific American. The Mandelbrot set is the set of complex numbers that meet a certain condition. Recall that a complex number has a real and imaginary part and we may express it as: c0=a0+b0i where a0 is the real part and b0i the imaginary part, with i being equal to the square root of -1. Consider another complex number: c1=a1+b1i where c1=c0+c0^2 (^ stands for exponentiation) Now imagine an infinite recursion of this series such that: c2=c0+c1^2 c3=c0+c2^2 c4=c0+c3^2 . . cN=c0+c(N-1)^2 . . where also, cN being a complex number, cN=aN+bNi. It has been proven that as N goes to infinity, if aN^2+bN^2<=4, then the original number c0 is a member of the Mandelbrot set. Unfortu- nately, infinity is a rather large number, so to be practical, we assign N to be some reasonable finite number, and if after N recursions the test holds, we assign c0 to the set. So, where do the pretty pictures come from? If the test fails before the number of recursions gets to N, we assign a color according to what step it failed at. We then assign a pixel on the screen with its x value equal to the real part of c0, and its y value equal to the imaginary part, and give it that color. (Consider that there are over 130,000 pixels in our viewport, and each one of them must be tested by this lengthy recursion process!) How is N chosen? If it is too small, borderline detail will be lost, but if it is too large, the program takes too long to run. I have chosen N as a function to the amount of zoom being used, because there is no sense in providing more detail that the resolution can handle. Therefore, the bigger the zoom, the larger N is, and consequently, the program runs more slowly for large zooms. So that Murphy's law is not violated, it should be noted that in general, the most interesting regions require the largest zoom, and hence they test your patience. Happy hunting.