Mathematics and the "Fractional" Dimension

You've heard of fractals. Julia, Mandelbrot, Lyapunov... But what are they?

To be honest, I don't fully understand them (in fact I know practically nothing). They are strange and beautiful. With eight lines of code you can create an infinitely complex mathematical object! Anyway, I will do my best to share what I do know about them here, so try to follow along.

Picture the relationship between the dimensions. The first is a line; add another line perpendicularly, and you have a grid, a plane, the second dimension. Now add a third line, and you have a cube, or three-dimensional space. We could get messy and discuss four dimensions, possible an array (set) of spaces (time?), but that can come later.

This system is very orderly. Each dimension is a perfect extension of the previous. Fractals are not so simple. As you will soon see, a "fractal" falls somewhere between, or outside of, the standard, discrete "integer" planes that we know.

Real, Imaginary, & Complex Numbers Review

Here comes the mathematical part. We're going to do a quick review on number types. First off, there are real numbers, all of which can occur in nature. 5, 0, and -1.3 all occur naturally, and thus are called REAL numbers.

There is a second set of numbers called IMAGINARY numbers. How does this happen? Well, it happens where mathematics are undefined. Take the square root of 16 on your calculator; you get 4 (note it could also be -4). That's because 4*4 or (-4)*(-4) equals 16. But -- try to take the square root of (-16). Error. That's because no number multiplied by itself can form a negative number - the negative signs always cancel. Thus, sqrt(-16) does not exist.

In order to deal with this, we invent the magic variable i, which is sqrt(-1). Then we can rewrite sqrt(-16) = sqrt(16*-1) = sqrt(16)*sqrt(-1) = 4*i = 4i.

So 4i is an imaginary number. It does not truly exist.

A COMPLEX number is just the sum of a real number and an imaginary number. Examples are 3+4i, 0-5i, and 37.7 + 3.3i. The generic form is a + bi, where a is the real part and b is the imaginary part.

Squaring the Imaginary Number

Here's the first key to understanding the funkiness of fractals. Take an imaginary number, 5i. Now square it. What you get is 5i*5i, or 25i2. Big deal.

Well, it IS a big deal. We can simplify i2. Pretend that we square a number, k. But pretend that k = sqrt(a). Mathematics defines that k*k = sqrt(a)*sqrt(a) = sqrt(a*a) = sqrt(a2) = a, because the two operations cancel each other. So k*k = a. That means that if a is -1, then k=sqrt(-1)=i. Plug into the derived equation and we get that k (or i) squared is -1. So what happens when you square an imaginary number? You get a negative real number.

So 5i squared is -25. (-3)i squared is -9. You always end up with a negative real number when you square an imaginary number.

Functions Review

You must also understand Functions in order to get the jist of fractals. A function is like a little machine that takes in a value (or multiple values) and spits out a single answer.

Example: f(x) = x + 5

    This function will return 5 more that what it is given. Thus, plugging 9 in for x will yield 14. We write this as f(9)=14.

Example: f(x) = x*x

    This function will return the square of the value you give it. Thus, f(3) will return 9, f(100)=10000, and f(-5)=25.

Example: h(z) = z*z + c

    This function will return the square of z and add some constant number. Unless you know the value of c, you can't get a concrete answer. h(17) = 289 + c. But if you know that c is 4, you can say that h(17) = 293.

Functions of Complex Numbers

What if we define a function not only in real numbers, but in complex numbers? For example, take f(z) = z*z + c, like above. Only, this time, z is a complex number, in the form a + bi. Plug in 5+3i for z. Hopefully you remember the FOIL method from Algebra for squaring binomials. What we have here is (5+3i)*(5+3i), which comes out to 5*5 + 5*3i + 5*3i + 3i*3i = 25 + 15i + 15i + 9i2 = 25 + 30i + 9i2. But remember: 9i2 = -9. So we actually have 25 + 30i - 9, or 16 + 30i, a nice, clean complex number in the same format we started with.

Now you can take your answer and crank it through the function again; you can do it any number of times. But sooner or later, as with many functions, it will either go to infinity or zero.

Picture f(x) = x+3. If you start with x=5, and keep plugging it in over and over, it jumps up by 3 each time and goes to infinity. So your sequence is orderly: 5,8,11,14... forever.

Now picture f(x) = x*1.1. If you start with a number greater than 1, like 3, then you get an eternally increasing sequence: 3, 3.3, 3.63, etc., forever. The sequence is, again, orderly: each "iteration," the value goes up just a little more, forming a curve like the right half of a U.

Now, picture the graph of f(x) = x*x. This curve looks just like the one above (it is mathematically very different, but looks similar). If you plug in 2, you get a very rapidly expanding sequence: 2, 4, 8, 16, 32.... the numbers increase very quickly, but orderly still.

Here's the kicker. Picture f(z) = z*z, this time using complex numbers. Let's start with 1 - 2i. Ignoring the third column until later, watch what happens to the values of a and b as we reiterate f(z):

  a b sqrt(a2+b2)
Iteration #1: 1 -2 2.236
Iteration #2: -3 -4 5
Iteration #3: -7 24 25
Iteration #4: -527 -336 625
Iteration #4: 164833 354144 (huge)

Notice how insane the function becomes. It almost seems random, but it is not. Notice the sudden sign changes in a and b, and the explosion of values. This is some of the most erratic behavior in mathematics. Some very beautiful things can happen here. Like this:

This is the mandelbrot fractal. It's amazing. All of those little tiny cracks and crevasses contain infinitely tiny, infinitely detailed little mandelbrots of their own!


I'll hit you with the full explanation now and then parse through it. This is the key: take a 2D plane. The X axis is the value of a (the real axis), the Y axis is the value of b (the coefficient of i; the imaginary axis). Now, for any (x,y) point, you interpret the speed at which the function goes nuts as the color intensity there.

I use the term "speed" just so you can get a grip on the concept. What it really is that you plot at an (x,y) point is a "number of terms before escape" value. Let's say the color value can range from 1 to 10 (10 bands of color); then, you can interpret the number of iterations the value "survives" being run and re-run through the function, staying below a critical value.

Because we have two values going, a and b, both of which we need to watch for "explosion" to a large value, it is easiest to instead watch a value that is a combination of both. We use the magnitude of a and b. Picture a and b being (x,y) coordinates - then the magnitude of a vector would be the distance from the origin of the point, and would be equal to sqrt(a2+b2 (mapped in the third column above).

The alternative to monitoring this "magnitude", which looks like this:

    mag = sqrt(a*a + b*b);
    if (mag>10) then exit_loop;
would be to monitor a and b independently, like this:

    if ((a>5) or (b>5)) then exit_loop;

The former is more stable and fair to the needs of both values. Look at the table above - notice that, though a and b go crazy, the magnitude increases in a very orderly fashion. (In fact, it keeps squaring itself. This is uncommon; it occurred only because there was no +c in the equation, which will soon be explained.)

Processing a Pixel

Okay, so we have an (x,y) point, and we want a color value for it. What do we do? We'll briefly reiterate (no pun intended).

You say a=x and b=y (you might want to scale them) and begin running them as a single complex number through your function. You watch the number of repititions of the function it takes before the magnitude of the complex number exceeds a certain value. This number of iterations is the color value that you plot there.

The pretty "fractal" produced when you calculate this for a grid of pixels (a whole image) is thanks in part to the strange, iterative way in which we approach plotting the pixels, but the infinite spirals could never be achieved without the use of the magical i. The key mathematical part is that i*i = -1; this keeps the real portion of the complex number (a) from eternally growing; it keeps it in check.

Variations on the common "gradient" fractal

Obviously, there are more equations you can use. One VERY important thing to note is that most are in the form f(z) = z2 + c, where c is a complex number (like j+ki). Every iteration, a and b are not only mutilated by the squaring, but are incremented or decremented by j and k. This adds unbelievable variety to the nature of the fractal generated. With no constants, the squaring equation (called a Julia) yields a circle! This is evident in the charted Julia above - the growth of the magnitude is perfectly exponential, not "fractional" at all - because there are no constants to disturb the equation.

Here's another key to unlocking the meaning of "fractional dimension:" on the first iteration, the constants somewhat disturb the data. On the second, they do it again, but they are building on the previous disturbance & making drastic changes anyway!

Feel free to experiment with the Anti-Aliased ASCII Java Julia Fractal Generator that I've written for this page. It renders a Julia fractal using letters (ASCII text) as "pixels" (the fact that it subrenders these "pixels" is where the "anti-aliased" part comes from). It is written in Java, a web-browser-based programming language, so your computer actually downloads the code & generates the fractal. You can give it the values of c (i1=real part, i2=imag. part) and watch how they change!


    The self-dependent nature of the fractal equation gives it a quality of self-repitition. If you look at a coastline from outer space, then from 20,000 feet, then from atop a palm tree, putting aside the scale, you will notice that they all have very similar characteristics. So does a tree with its branches, as they get smaller & further out; so does a chambered nautilus in the sea, and so do the capillaries in your flesh. If you look at a tree that has been sliced off horizontally, it looks almost identical to a Julia. This concept of recurrence is a favorite quality of mine, due to a personal fascination with phenomenon that repeat themselves at many levels (in real life, not mathematics).

    The point is, if you zoom into a fractal and look around, not only will you find the same characteristics when zoomed in 100x or 1 billion times, you can probably find something that looks identical. The coolest part is that it is eternal; you can zoom in forever. (Processing may slow, but you can do it.)


    Another neat trick is warping - changing the values of the complex constant. As you do so, the fractal neatly spins and swirls, tucking into itself and unfurling, becoming some very beautiful and fantastic designs. If you focus on one part of the fractal and render 100 frames, while the real constant (i1) goes from 0.3...-0.1 and the imaginary one (i2) goes from -0.2 to -0.05, the fractal will warp and twist into itself and make a fascinating show. These ranges are just examples; nearly anything will work well, as long as the constants' absolute values stay below 1.

    Making 3d Images

    For this, there are two approaches. In either one you must write a ray-casting engine, which took me about 2 months to complete. It's not easy. I deserve a cookie, and my friend Vince Scheib too, whose keen mind helped a lot.

    METHOD 1. You can interpret these "color intensities" as altitudes. That way, the central part of the mandelbrot becomes either a desert plateau or a water-filled crater! This is fairly easy to implement once you have the engine.

    METHOD 2. You can really tweak the fractal equation so that it makes a solid, 3D model of a living, volumous fractal. This has more potential than anything I've seen. How to do it? Here's the trick: Take that gradient-colored 2D fractal you have and make it binary (2 colors), like this (notice that the Java Julia linked to above is binary):

    Now treat this as solid volume. Set up your ray-tracing engine: place a camera, set up a grid of pixels, get ready to trace each ray. As you cast a ray through space, inch along at minute intervals and test each point vs. intersection with the volume fractal. If the fractal is "on" at a point, you have a hit, and you go on to calculate shadows and/or reflections. If you were to do this with the above-right image, the "on" part would extrude upward to the sky and you'd see a rigid cookie-slice of this julia!

    ...and on to 3D Warping

    Here comes the amazing part. We now take that cookie-slice, an (x,y) fractal extruded along the Z axis, and we give it a little tweak. As it goes along the Z axis, the constants change! Just as they changed in time in the warping example, based on the z-coordinate of the point in space you are testing against, you test against, effectively, a totally different fractal. But, in 3D space, as long as the constants change slowly over the Z axis it looks smooth, serene, and natural.

    Here is one I made from the Julia set:

    Notice the reflections and shadows... very fun to derive. Here is an earlier one, without shadows or reflection, but with a little bit of Photoshop magic:

    The possibilities here are limitless. These were BOTH generated from the Julia equation, the simplest I know of!

    Finally, here's a movie I made (Quicktime format - .mov) that illustrates the process of turning a 2D fractal into a 3D fractal, and then warping it:

    9D.AVI - 10.3MB (with sound) - 1997

    ( on the image to watch the movie )

    Other Equations

    There are tons of fractal equations you can come up with; just think of a function f(z), and throw in a complex pair instead of a real number. High powers of exponents can get cumbersome, though, unless you know the Pascal's triangle bologna for expanding binomials beyond the second degree. It can get funky. Also, the more complex the equation, the longer the processing time.

    A side note - functions involving sine and cosine can make very biological- looking fractals, like the one above next to the "Why" section.

    Another neat trick for 2D is to distort the constants based on the (x,y) position. This makes a non-symmetrical fractal that shows characteristics of many of its neighbors.


Okay, so hopefully I've shown that fractals have limitles aesthetic promise and mathematical intrigue. I've only hit on a handful of the tweaks you can make to generate cool graphics, though. I'm sure there's plenty more that I haven't even begun to imagine.

I admit that my mathematical understanding of them is somewhat shoddy, but hey, I've made some cool art from them, so cut me a break, all you fractal math gurus out there.

Hopefully now you see why they aren't in a clean "dimension" of their own. I don't even understand it articulately, it's just sort of a "feeling" you can get for it. It's sort of like e=2.71828... and the whole "infinitely compounding interest" battle for understanding. You have to let it all sink in over time.

Another note: if you want to develop this "feeling," you really have to sit down and do some coding. A basic Julia program only takes about 15-20 lines of code to write. Then you can play with the parameters (the constants) and see how it all comes together.

Fractals are now also being used in data compression. From what I've heard, this method had incredible preservative quality ("random" detail is infinite!) and the compression is also quite fine.

I leave you with that. If you have questions or comments, or need help, or have a cool idea to share (+++), e-mail me at .


Back to Realtime

Everything here ©1992-1997 Ryan M. Geiss. Material/content may
not be reproduced without the express written consent of the author.