Last edited Mar 19, 2003 by pompe@uiuc.edu
Find this document at http://www.ncsa.uiuc.edu/Classes/MATH198/pompe

Alex Pompe: Math 198 Hypergraphics at the University of Illinois in Urbana-Champaign.


Hip-Pocket Program


The Mandelbrot Set:

GLUT Example of Fractal Nature.


All images on this site were generated using my pocket program.



- The famous complexity and shape of the Mandelbrot set visualized using the graphics capabilities of a computer is commonly used to impress the lay person and demonstrate the ability of mathematics to contain such impressive and amazing beauty. Also the fractal is a perfect example of hip-pocket graphics program as defined by Professor George Francis. The relative ease and brevity of code make this remarkable and entertaining piece of mathematics a good measuring stick for the rendering capabilities of a machine. The code used to create the images on this page is less than one page long, yet is able to contain the coloring and manipulation of the fractal. Check the link to the source code at the bottom of the page for reference while reading the explanation.


Explanation of Creation


The fractal is an image created on the complex plane. The computer monitor's pixels's correspond to points on this plane, with the x coordinates being real numbers and the y coordinates being imaginary numbers. Now, to create the image, we basically just test every point in our viewing window, aka the screen of the computer. This test will determine if the point is part of the Mandelbrot Set, and if it is not what color it will be drawn as. I guess this is a good time to mention that the black points are actually part of the Mandelbrot Set and are more special than their colorful neighbors. So at this point we know that to draw our image, we must test each pixel or point on the screen and this test will tell us what color to make the pixel, so lets move on to the test.

To determine the color of a point, we start with its coordinates on the complex plane. For this explanation we will use the form A + Bi, where A is the real portion (x-axis) and B is the complex (y-axis.) Now before we start our test we should line up the tools that will help us through the process. First we must count how many times we iterate each point, easily done with a device such as a computer that is so very good at counting. Our second tool is a device that we will call each time we want to iterate our point. This function contains the counter described above and more importantly has the mathematical function we apply to the given input point. Specifically, the function starts with two complex numbers, one being the number 0+0i named Z, and the other being the point that we are testing, C. The function simply does the following, it gives Z a new value each time it is called. The value is Z squared plus C. Now Z has a new value, and after this change if Z squared plus C squared is less than four, we will perform the function on Z again (keeping in mind it is not 0+0i anymore.) If that was hard to follow, it can be thought of more geometricly as follows. The point 0+0i is the origin. After the first test, Z become the point we are testing, C. After repeated testing, Z has a few choices on what it will do. It can move farther than 2 units away from the origin, and after it does this it will continue running away from the origin, never to return. It can also stay within 2 units from the origin until the end of time, but since computers can't run till then and still show us a pretty picture, we will test a maximum of 100 times. If Z stays within 2 units during this many tests, we will say that it is in the Mandelbrot Set and will be colored black. But what of the frisky points that tend to run away, do they not deserve some coloration? Of course my friend, we will give them color according to how long they stayed inside the 2 unit boundary. So a point that stayed in the above ground pool of radius 2 for 15 iterations will be a different color than his friend who stayed in the pool for 87 iterations. Remember though that this is not an ideal pool, and after 100 iterations, it is time for adult swim, and only the Mandelbrot Set points are allowed to swim without a life guard. At 100, the computer life guard stops counting the time, and moves on to the next point.


Now that the test has been described, all that remains to be done is to perform the test on every point on the viewing window. Simple modifications of the test and also the method of assigning colors can create the spectacular images that adorn this page. Trigonometry and other mathematical goodies can be used within the math function to modify the shape of the fractal. These same tools can be used to make the colorations more spectacular by simply putting them into the assigning of red, green and blue values for each pixel. All this together creates a shape with self-repeating symnetry all along its surface. Also, a computer can create this with only a page or so of code and thankfully it can do so, as doing this all by hand is basically impossible. However the combination of math and counting needed, plays to the strengths of a computer system and the end result is one of the most complex shapes in the realm of mathematics.



- Here are some various images created with my pocket program. The different colorations are created by taging each point on the complex plane in the viewing area by the number of iterations needed on that point. The different shapes are created by manipulating the function used to iterate each point, mainly with trigonometric functions.
-Rotated Standard Set
-Standard Set with Red Highlighting at High Iteration Values
-Function Modified by a Power of 3 and a Cosine Function
-Zoomed in Version of Previous
-Modified with a Sine and a Cosine Function
-Modified with a Tangent Function

Follow the White Rabbit.