Back to my home page
About complex fractals, and how to play with my applet
Welcome to my nice little project about complex fractals. First of all some simple definitions- a fractal is something that infinitely repeats it self, or is infinitely self-similar. A complex fractal is a fractal that is generated on an inductive (or recursive) formula on Complex numbers, or numbers that have a real part and an imaginary part. The classic example is the Mandelbrot Set, which is the fractal that the applet starts out with if you don't mess around with it. This quadratic mandelbrot set is a good example of a complex fractal. Here's the inductive formula associated with this relatively well-known fractal. First of all, you might have read the word quadratic and said that doesn't look like a parabola, and you'd be right, but graphing a quadratic function is different from an inductive quadratic formula. Here's basically how it works. Take some arbitrary complex number (I'll call it c). c represents a point on the graph on the right, where the x axis is the real 'number line' and the y axis is the imaginary numbers, so while I say x and y in those those settings at the top, don't be fooled, those are really real and imaginary bounds. Now for the inductive definition. If you create a number z0=0. Now, you start calculating z1, z2, etc by the following definition:
So you might be wondering what the heck that simple-looking function has to do with the crazy fractal picture. Well, if you do this over and over again, as n=>infinity, one of two things happens- it either diverges to infinity or it doesn't. The values of c for which zn does not diverge are considered to be inside the Mandelbrot Set, and are represented in the dark black inside the cool pattern. Strange how it makes such an interesting shape, isn't it? Also, remember that z and c are complex numbers, and complex numbers do some interesting things when you square them (or just multiply them or do anything to them in general). Now since I said there's only two things a number can do with that formula, why are there tons of colors? Well, to make it interesting, I count how many values of z I can do before it's clear that it's diverging, and color or shade the pixel according to that count. How do I know it will diverge? Well, a little playing with the function will show you that if zn gets further from 0 than about 2, it's well on its way to infinity, so I defined the breakout formula on this program to be where |z|>2, where |z| is the distance of z from the origin.
Playing with the Mandelbrot set on my applet
There's a few things that one can do with my applet in order to really appreciate the complexity and beauty of the mandelbrot set. The most basic way is to zoom in on parts of it. My applet makes this pretty easy, although I'd precaution you to pick areas as square as possible, or else the image will be stretched, which isn't a bad thing, but it won't look as natural as it really is. All you have to do is click on the image and drag the mouse button. You'll see a rectangle form between where you originally pressed the button and where you drag it to. Get the rectangle (hopefully more of a square) right where you want to zoom in, and then hit the "Zoom in" button on the top right (under "redraw"). Notice that the black parts take longer to calculate. That's because I tried a large number of values for z before I decided that it just wasn't going to diverge (you can adjust how many values of z I calculate before I give up and call it black by changing the number in "# of iterations". Fewer iterations is faster, but may not give as accurate of a picture, especially if you're zoomed in really close to the edge of the black. Due to the lack of accuracy, you'll see the little fractal edges of the shapes won't look as interesting with lower numbers of iterations.
Another thing you can do to play with it is change the color scheme on it- My applet gives you full control over the color scheme, and while I like the defaults, they're not the only way to do it. Basically, you pick (in "red start", "blue start", and "green start") what color 0 is, and then pick (in "inc red by", "inc green by", and "inc blue by", inc means increment) how much the color changes for each count. Each of the three numbers (red, green and blue values) are numbers from 0-255 defined as black*(count*inc+start)%256, where black is 0 if count is greater than the number defined in "# of iterations", otherwise it's 1. If you put all the start values the same and all the inc values the same, the picture will be greyscale. If the inc and start for one color are both 0, that color won't be in there (if "blue start" and "inc blue by" are 0, for instance, only green red and yellow (the mix of green and red) shades will be present).
A third way to play with it is to find a cool part, zoom in on it, and then use the "Draw 3D" checkbox and hit the Redraw button. You'll see an angled view of the same section of the fractal where the 'height' of the pixel is also based on the count (as well as the color). The topography of the Mandelbrot set can be almost as interesting as the coloring.
Yet another way to play with it is to acknowledge that the mandelbrot set doesn't HAVE to be quadratic. It can be raised to any power! Change the number at "power-Real" to 3 and hit Redraw (if you're zoomed in, it's better to zoom back out first by hitting the "Show full set" button before you hit "Redraw"). A completely different fractal! Then try changing it to 4 and 5 and so on. After awhile, they get to be similar images with more points coming out of them. If you think of the Mandelbrot set as an infinite set of cardiods and ellipses (I know of a graduate student who attempted to prove that somehow), the quadratic has one ellipse on each segment recursively (I don't know how to really describe that better), and the cubic has 2 and the quartic has 3 and the 5th power has 4, etc. So the question is, if you raise it to the 2.5 power, do you have 1.5 ellipses on every segment? Put 2.5 into "power-Real" and change the box in the top right (the one that should say "Integer Power") so that it says "Real Power", and hit "Redraw". This one will take a little longer to calculate (what can I say, the math is a little more complicated). This one looks like you twisted the quadratic mandelbrot set around about 135 degrees counterclockwise and then tried to tear it appart with your hands. Now try every power from 2 to 3 in smaller divisions, every .1 or so if you have somewhere to go in the next 20 minutes, or every .05 if you have a little time. It rotates and changes somewhat drastically within .1, really. You'll notice that some of these have some smooth, cut-off looking edges, which I said usually means your breakout isn't right, but in this case, it probably is right. You'll notice that using 2.1 as the power makes it look alot more similar to the quadratic mandelbrot set, where 2.9 looks like an angled and slightly twisted cubic mandelbrot set, and in between, it twists and turns every which-way.
Of course, Mandelbrot sets don't HAVE to use real number, the exponent can also be imaginary or complex. As it turns out, imaginary exponents on the mandelbrot set are incredibly un-exciting, and complex exponents (they obviously take a little more time to calculate than real ones) are only worth looking at if the imaginary component of the power is significantly smaller than the real component of the power (like 1/10 maybe). Just a few tips. The more 'imaginary' the exponent is, the more likely the graph is to look like a big black circle. Remember, if it's taking longer than you think it should, you can hit the cancel button, and it will still display as much of the set as it's calculated so far.
Finally, another quite interesting way to play with mandelbrot sets is to use them to draw julia sets. What's a julia set, you might wonder? Well, some would say that the mandelbrot set is the set of all julia sets, which is just a bunch of technical mathematical nonsense. I don't think that the mandelbrot set should be defined by julia sets, but that it should be the other way around- I consider julia sets to be cross-sections of the mandelbrot set. That probably doesn't make that much sense at first, either. Let's try an example. When you click on the images of mandelbrot sets (I'd recommend you go back to the quadratic one for now, use Integer Power and change "power-Real" to 2), the coordinates you clicked on get put up in the "C-real" and "C-imaginary" fields. You need a constant 'c' to make a julia set. Then change the second choice-box on the right from "Mandelbrot" to "Julia" and hit "Redraw". Since I already hinted that julia sets and mandelbrot sets are closely related, can you guess what the inductive formula for quadratic julia sets is? It's zn+1=zn2+c. So why does it look different? Well, this time, we take c to be some constant (the one you pick by clicking on the Mandelbrot set). and z0 is the point on the graph. Julia sets on integer powers are radially symmetrical. For quadratic sets, they have 2 arms, cubics have 3, etc. The point of the mandelbrot set that you chose is the same color as the origin ((0, 0) or 0+0i) on the julia set. By that, you'll see that julia sets on points inside the mandelbrot set are connected, because they're black in the middle (and they never just leave an island in the middle). If you pick a point that's not inside the mandelbrot set, the set is disconnected or may not have any black at all. The most interesting julia sets are usually just barely inside the mandelbrot set. (A guy I know who's a graduate student in Computer Science said that the scientific definition of an 'interesting fractal' is one that looks cool). Since the Mandelbrot is symmetrical along the real axis, you'll find that if you change "C-imaginary"'s sign, you'll just get the mirror image of the previous julia set. Some recommended values for c are .3+.5i, .11+.62i (a few similarly shaped and interesting-looking fractals), .255+0i (this one is fun in 3D, especially if you zoom in on the little curly 'towers' and increase the "# of iterations" and it looks sort of like a 'tower of babel'), -2+0i (this one looks like an infinite set of sine waves, getting half as big each color), 0+1i (this one looks like lightning), 0+.6i (kind of a furry black blob), and .4+.4i (a good example of a detached set). I'm sure you could find hundreds of interesting julia sets based on just the quadratic mandelbrot/julia formula and thousands more on other integer powers, non-integer powers, and complex powers, but I'll leave that to your exploration and experimentation.
How mathematically similar are other complex fractals to the mandelbrot and julia set fractals?
How similar complex fractals are to Mandelbrot/Julia sets really depends on the fractal. Two things can pretty much be laid down- first of all, they all use at least one complex number, and second of all, they're all defined inductively- the value of z is based on the value of the previous z (and it's also conventional to use the letter 'z' to denote this inductively defined complex number). It's also a convention to define any other number involved as c, but not all complex fractals have a c value, while some have multiple 'c' values. Almost all (probably about 95%, and all but one of the types that I demonstrate) complex fractals are colored according to how long it takes them to diverge, or go to infinity. Depending on the base function, the definition of divergence could be 2 away from the origin, e2 away from the origin, or 2*PI away from the origin. The way you know you have a valid breakout formula is if the part that doesn't diverge is about the same shape with the breakout value you're using as it is with an outstandingly large number, say 100. Most of the time, if something looks cut off, your breakout value is too small. Alot of times it just takes a little logic and some trial and error. Of course, some don't diverge, some diverge to 0 or some other number, and you have to decide how close it has to be to that number before it's good enough to say it's converging. Quite a few common complex fractals have mandelbrot and julia versions of them, but in many cases the mandelbrot versions are downright ugly and only really used as an index to finding cool-looking julia sets.
The Phoenix set- another 'interesting fractal'
The "Phoenix curve" was discovered by Shigehiro Ushiki in 1988. To see the exact curve he discovered, put 0.56667 and -0.5 in as C-real and C-imaginary and change the second choice box to "Phoenix". Kind of cool, eh? It's a little harder to find interesting-looking Phoenix sets than it is to find good julia sets, because the mandelbrot version of phoenix sets isn't as helpful. Still, I put it in, that's the one I called "Ph-index". The center pixel of phoenix sets is still the same color as the pixel it's drawn from on the index set, but the difference is that even when the origin is black, the set might be disconnected, which is different from Julia sets. Several look like wings, (like the one I showed you above), and several look sort of like swords. The formula sort of stretches the rules a bit, because it seperates the real and imaginary parts of c, and uses them both as real scalars, which is probably the reason that the index is asymmetrical and the phoenix is symmetrical on the real axis rather than being radially symmetrical. In other words, c isn't really a complex number at all in this case, which may be why it doesn't have the symmetry that most complex fractals do. I guess you could say that The quadratic formula looks like this:
It also requires me to store not just the previous value of z, but also the value of z from 2 iterations ago.
Newton-Raphson sets- one reason to remember calculus
There were several things that I spent long periods of time getting right in this applet, and even getting something that resembled what looked like the Newton-Raphson sets I saw pictures of on the internet was among those things. Just for kicks, keep the function type on "Integer Power" and the "power-Real" on 2 and choose "Newton-Raph." for the fractal type. I say just for kicks because you'll look at a straight line with some circles getting bigger and bigger and you'll be like "I'm not amused". Apparently (I don't remember learning this in any math class, but it works) the Newton-Raphson method is a fairly effective way of finding the roots to an equation. It works to find the zeros in polynomials with complex numbers, too, and alot of polynomials with real coefficients have complex or imaginary roots anyways. When using complex numbers in the Newton-Raphson method, there's two things that are fractal about it (and my applet only shows one of them). Here I show the amount of time it takes to find a root of the polynomial, which forms an interesting repeating pattern on higher powers (ok, change "power-Real" to 3 and hit "Redraw" again and see what I mean). The other thing that's fractal about Newton-Raphson sets (I might make a seperate applet for Newton-Raphson sets for just this reason) is which root you'll converge to. You'll notice that it goes out infinitely in all directions. The number of 'chains' going out depends on the power. The angles are always equidistant (assuming integer powers), but are rotated depending on what you use for c. The reason the Newton Raphson sets go out infinitely is because the color here is based on how long it takes to converge, rather than diverge. The reason the Newton-Raphson method is useful in mathematics is because the places the function converges to are the roots of the system. The more boring centers of the circles are those roots. So now for the function. It's quite unique from others, you won't see any 'black areas', nothing is 'inside' the Newton-Raphson set unless the method doesn't work for that kind of function at all (i.e.- funcion types that never have zeros like ex). The idea is you can find a zero from any polynomial (and some other) function by iterating this formula until it seems to converge:
Yes, that f'(zn) does mean the derivitive of f(zn). The breakout formula is way different now. Basically, the way I have it, I test if I'm within .2 of a root, or that f(zn is within .2 of 0. So what exactly is f(z)? In the case of the first boring fractal I showed you earlier, z2+c. Looks pretty familiar, eh? And for any power you put in there, the function used by my applet is zpower+c. Newton Raphson sets could be made from quite a few more complicated polynomials, I just chose not to go to the effort of supporting more complicated ones. So, lets use the cubic one. The function f(z) is z3+c. f'(z), therefore, is 3*z2, so our consequent iterative formula is:
Division is an interesting operation when you're using complex numbers. (Skip this part if you don't care about the arithmetic involved here). You can't divide a number by a complex number par se, but what you can do is you can multiply the top and the bottom by the conjugate of the bottom. Let's call the numerator a+bi and the denominator c+di. The object is to get i out of the denominator of (a+bi)/(c+di). Well, the conjugate of c+di is c-di. When you multiply (c+di)*(c-di), you would get c2-cdi+cdi-(di)2 =c2-d2i2, and since i2 is -1, that's the same as c2+d2. What I'm showing by this is we start with (a+bi)/(c+di), we multiply that by (c-di)/(c-di) (1) and we get (a+bi)(c-di)/(c2+d2). So that, in a nutshell, is how to divide by a complex number, and it's possibly the most complicated mathematical funcion I can fully derive like that (just to improve the speed of my applet on some fractals, I learned to partially simplify several functions, but without fully understanding the basics involved).
Newton Raphson sets on non-integer powers
The main reason I added non-integer and complex exponents in this applet is because they make really cool Newton-Raphson sets. In fact, with the amount of research, math, and tweaking that it took to do complex powers, I would have never done it and also never known whether I had it right if it wasn't for the fact that I knew that complex powers made for really cool Newton-Raphson sets. When taking the derivative of a function with a complex exponent, you still just subtract one, you don't do anything to the imaginary component of the exponent, but of course, you still multiply the derivative by the whole complex number. First of all, though, let's change the function type from "Integer power" to "Real power" and type in a number for "power-Real" that's not an integer, say 3.5. Remember that there's 3 chains coming out if the power is 3, and there's 4 chains if the power is 4. Strangely enough, while there's really no such thing as a 'half' chain, this Newton-Raphson set is about how I'd imagine 3.5 fractal chains. Notice, however, that the chains still go in straigt directions outward. Now change the function type from "Real power" to "Complex power" and pick an imaginary number to go with it. You'll notice now that the chains twist around, and your eyes aren't deceiving you, there's sort of a funny cut-off thing going directly down the negative imaginary axis. I thought it was cool, if not worth all the effort associated with getting complex powers to work, let alone getting Newton-Raphson sets to work at all.
The Quartet set- one common way to screw up a Mandelbrot set
The Quartet set is a mandelbrot-type set with a much simpler formula-
z0is actually the point on the graph, but z-1 (which is relevent if you're calculating z1) is 0. The way I have the julia form set up is you choose z0 and z-1 is the point on the graph. As you could probably imagine, it would be easy to accidentally get this while trying to get the standard mandelbrot set. Luckily, you'd know if you got it, because it looks nothing like the mandelbrot set, but looks more like a six-pointed starfish. When you raise the power, you'll see that it adds more points to it. One thing that's interesting to look at on these is the little specks just off the edges. You won't get anything overly exciting from julia sets off these specs, just an archipelago of little islands. You'll find that some of the islands, however, are very similar in shape to the speck it was drawn from. Julia sets (if you haven't figured it out yet, I called the julia equivalent of the quartet set the "Quartet Julia") from the middle starfish are more interesting, and the closer you are to the center, the more it looks like its mandelbrot cousin. Using non-integer real powers for the quartet set can be entertaining, always getting a differently folded and twisted version of the image. Quartet sets with imaginary powers aren't that great unless you use smaller values (like .5), in which case it's probably not accurate, because alot of what appears to diverge actually may not (notice the cut-off look). Complex powers of Quartet sets swirl the image around, but to a lesser degree than Newton-Raphson sets, and still have the cut-off line going down the negative imaginary axis. Large imaginary values usually don't work as well, neither do negative imaginary values. Your best bet is between 0 and i. Julia-type quartet sets are similarly twisted and curved in an interesting shape.
My bonus fractals
You probably noticed in between all of them, there is 4 fractals called "My Fractal 1", "Index 1", "My Fractal 2", and "Index 2". These are all complex fractals I came up with in an effort to figure out the Phoenix set fractal, so you'll notice the formula is similar (for both of them) to that of the Phoenix set:
The difference between this and the Phoenix set is that this time, c is still divided, but the imaginary component of c is actually treated as imaginary when I multiply it with zn-1. The next question is what's the difference between "My Fractal 1" and "My Fractal 2"? Why do their mandelbrot-type sets ("Index 1" and "Index 2") look the same? The difference is actually a coding difference more than anything. Since I need zn and zn-1 to calculate zn+1, It's relevent to have two base values. Basically, in "My Fractal 2", z-1=0 and z0 is 0 for the mandelbrot-type and the pixel value for the julia-type set. For "My Fractal 1", z0 is 0 and z1 is zn+1=p2+c.real, where p is the pixel for the julia-type set and 0 for the mandelbrot-type set. In other words, z1 is the same as it would be in "My Fractal 2", but z0 is different. It's a very subtle difference, and the fractals come out looking extremely similar. In fact, the same values for c that make good Fractal 1's make good Fractal 2's as well. In fact, you can just switch back and forth, and you'll see that they look pretty much the same, except that "My Fractal 2" is strangely assymetrical, while "My Fractal 1" appears to be radially symmetrical. You can imagine this was frustrating for me trying to draw a Phoenix set, which is symmetrical along the real axis. Some examples on the symmetry and asymmetry of the two- try putting in .2+.8i for c nd do a "My Fractal 1". You get a bunch of blobs with two big blobs. Now keep the same numbers and do "My Fractal 2", and you'll notice that the bottom blob looks kind of gimpy now, it's not as big as the top one. You get a similar but different-looking result with .3+.5i for c. Usually if you draw either "My Fractal" using a point inside (black) the index sets, you just get formless blobs, but even in that case, the "My Fractal 1" is radially symmetrical and the "My Fractal 2" isn't symmetrical. For an example of that, put in -.35-.5i for c and draw a "My Fractal 1" and a "My Fractal 2" from it. The "My Fractal 1" is a symmetrical black globule, and then the "My Fractal 2" starts to look similar and then looks like a completely random black globule. Also, try -.38+.5i, it's quite interesting, too.
One thing you get alot of with the "My Fractal" sets is spiral patterns, especially with higher powers of "My Fractals". Let's try a 4th-power one. Change "power-Real" to 4 and set c to .65+.32i and draw a "My Fractal 1". Just 4 little things going around in a circle. Now make a "My Fractal 2" from the same numbers. Now the top-right thingy is really big, the top-left one is a little smaller, and the two on the bottom are just tiny.
Non-polynomial functions in Fractals
By now you've certainly noticed that "Integer Power", "Real Power", "Imaginary Power", and "Complex Power" aren't the only function types I have listed. I also included sine, cosine, tangent, natural logarithms, and ex (or really, ez. All these do is use these functions on z rather than the powers of z. One of the main reasons I added these was for Mandelbrot/Julia sets and Newton-Raphson sets, of course they were hardest to implement into Newton-Raphson sets (because I had to figure out what some of the derivatives I forgot were). Some of the math behind trigonometric functions on Complex numbers make no real sense to me, to tell you the truth, the most complex thing I did relating to them was reduce the definitions to a few lines of code for the sake of speed (I think I spent an entire day reducing the tangent function from just sin/cos to something much smaller). So anyways, let's try some of this out. Switch the function type to "Sine" and the fractal type to "Mandelbrot". You'll actually have to zoom out to see the whole thing in this case, because the breakout distance I used this time was 2*pi (seemed more appropriate for trig functions, and with 2, it cut off that entire area to the right and a little more). Now pick a point to make a julia set from! The rules for finding interesting ones are the same as with regular Julia sets, except that this is your mandelbrot set, give or take. You'll notice that the sine Mandelbrot set is finite, it doesn't repeat. The sine Julia set goes out to the left and right infinitely, but it gets smaller and smaller as you go out further. If you weren't sure, the function used for these two fractals is zn+1=sin(zn)+c.