 # Fractals

Fractals

Fractals are defined as self-similar figures. That means that they appear exactly the same no matter how what the zoom. The word Fractal comes from frangere, to break, and fractus which means irregular and fragmented. Most fractals also have an infinite perimeter and a finite area. This is simply demonstrated by a Koch Snowflake. It is easy to see that the perimeter is infinitely long by the area never exceeds that of the circle in which the base triangle was inscribed. Mandelbrot Set (M-Set)

The M-Set is formed by using the equation z=z^2+c. The equation is looped and z is calculated until one of two things happen: z goes to infinity the point (c) is not in the M-Set, and is plotted white or colored (which I will talk about later), or, after looping a certain amount of times and z is still finite that point (c) is in the M-Set and is colored to show that (usually black). Now for the math. Both z and c are complex numbers, which are defined as a (real) + bi (imaginary), where i is the square root of -1. The variable c is any point in the complex plane, where the point is defied as (a,b), so the point (2,3) would be written in complex number form as 2+3i. The variable z starts off as 0+0i or 0. Dealing with these complex numbers is easier then it looks. Written in Cartesian coordinates the equation would look like:

(zx =real part of z; zy=imaginary part of z; cx =real part of c; cy=imaginary part of c)

zx = zx^2 - zy^2 + cx
zy = 2 * zx * zy + cy

A little more complicated than it looks, right, no it's very simple. Write z in the form a+bi.

(b+ai)

Square it.

(a+bi)^2 or (a+bi)*(a+bi)

Use the distributive property.

a^2 + a*bi + a*bi +bi^2

a^2 + 2*a*bi + bi^2

Now (hard part) because 2*a*bi is 2*a*b*i that term is imaginary thus

zy (imaginary part of z) = 2*a*bi

Then because the square-root of -1 squared is -1 (and real) b becomes negative and real, so

zx (real part of z) = a^2 - b^2

Substitute zx for a and zy for b.

zx = zx^2 - zy^2
zy = 2 * zx * zy

Then just add cx (real) to the equation for zx (real) and cy (imaginary)to the equation for zy (imaginary), which gives you the equation:

zx = zx^2 - zy^2 + cx
zy = 2 * zx * zy + cy

Not too bad, but then again I like math. The point c is changed after every loop to the next point in the complex plane and the process continues, but the M-Set has no points outside the circle formed with the origin (0,0) as it's center and a radius of 2.

Julia Set(s)

Here's a nice short one. It is calculated using the same equation in the same manor, but uses the variables in a different way. The variable c is set as a point in the complex plane and the variable z is the changing point as c was for the M-Set. *

Color

Coloring equation fractals (yes, there are other kinds) is very simple. Set a number to a color, like 1 for red, 2 for orange, and so on with the spectrum until you reach 7 for violet. When a point goes to infinity count the number of times it takes and make that point the color corresponding to that count. Obviously, since the number of counts will eventually get over 7 or whatever number of colors you are using just say something like:

If Count > (# of colors) then
DO
Count=Count-(# of colors)
LOOP until Count<((# of colors)+1)
end if

OR (check if your language has MOD, it makes things faster)

Count=(Count MOD (# of colors))+1

So if Count = 9 the point's color would be orange if you used 1-7.

Pictures