The World of Fractals

I've tried getting into fractals-- and I mean the cool ones on the complex plane, not the Menger sponge or L-systems... they're more-or-less trivial. A fractal is an infinitely-complicated picture generated by a mathematical function. I'm starting with the Mandelbrot set because it seems to be the starting point for everything. Also, its much easier to find documentation for Mandelbrot than many other similar fractals... though the "burning ship" is second on the list. Also, I was surprised how, after a little schooling (and I still can't find my Discrete Structures book... think my dad lost it), the stupid notation melted away and everything made sense. Here's a brief tutorial on the Mandelbrot set:

The first part of the formal definition states: Pc : zz2 + c.

It is iterated with z starting at 0. In fact, it might make more sense to think of it as a recurrence relation. But, in the rather silly ways that mathematicians misuse notation, they write the nth iterate of Pc Pnc -- The sheer amount of HTML markup that goes into these things is quickly becoming ludicrous. So, that's not Pc raised to any power... it's an iteration. If you think of it as a function, it's akin to f( f( f( ... 0 ) ) ... ) where the function is nested n times. Also, z is a complex number, so it has a real part and an imaginary part.

The next part says M = { cC : ∃ sR, ∀nN, | Pcn(0) | ≤ s}

Lots of notation, but most if it is just defining the variables. Translated: "M is the set of complex cs such that there exists a real s and for all natural ns, the absolute value of our P function is less than or equal s." It says c is complex and s is real. There's only one s that this mess works for– usually taken to be 2. n is taken to be our iterating variable, so it's naturally a natural number (a counting number– an integer greater than zero).

"Mark! How does this make a cool picture?" you finally ask, throwing your hands up. "We want the cool picture."

Okay! Hang on! So far, I've skirted the point, but the Mandelbrot set is actually a set. We'll make a picture coloring black (traditionally) all the points that are in the set, and ... we'll get to the other colors in a second.

"How are they plotted?"

Well, we're talking complex numbers. Complex numbers have two parts, a real part and an imaginary part. The real part of the number becomes the traditional x-axis and the imaginary part is the y. Wikipedia tells me that the real part ranges from -2.5 to 1 and the imaginary part ranges from -1 to 1. So, for our Pc, we let z start at -2.5 - 1i, and try every value up to 1 + 1i. With each trial, if it falls into the set, we color it black, like I said before. If it's not, well... we're not going to actually try every natural number, since there are an infinite number of them. Instead, after we give up (a thousand iterations or so), we'll see just how far many iterations it takes to leave the value of s– this is why I wanted to save this for now.

When we do our function above, we're going to get a number that's either part of the set, that is |Pcn| ≤ s, or we won't. If it isn't, that is |Pcn| > s, how many iterations did it take for Pcn to escape s? This number can be mapped to a color, usually a simple color-gradient.

And there's more than just the Mandelbrot set... if instead of setting your Pcn to z2 + c, and instead separate c into its real and imaginary parts before squaring, you get the dazzling burning ship fractal. The formal definition for that would be more like Pc : z → ( | ℜ(z) | + |ℑ(z)| ) 2 + c.

The fancy R and I just mean "take the real/imaginary part of the number in parentheses". So, it's more or less the same as before...

Anyway, I'm sharing all this because fractals are a sort of whimsical structures, and math, according to a good lot of people, is "hard" or "boring"... and this proves sort of the opposite. It's the opposite of boring. You've generated a picture of infinite complexity! No matter how close you look, there's something more to see! And it's really not hard. If you look past the cruddy notation and weird symbols and try to see what it's trying to say, it's relatively simple.

I wrote the source code to generate these fractals using Java, but there is no built-in class for complex numbers. The idea is that you can use simple algebra to get through iterating complex numbers by separating each number into its real and imaginary component. Since Mandelbrot's set and the Burning Ship fractal are very similar, the source code is equally similar.


To use the above programs, click and drag boxes to zoom into. You may use the f key to toggle full-screen mode, and s to save a screenshot. Also, , and . (comma and period) rotate the color map.

So, I hope something's been learned here. Complex numbers aren't really complex, despite their name. Programming stuff like this can be fun and rewarding. Now, you can go back home!