Fractals
- What is a fractal?
- Why do I find them so fascinating
What is a fractal?
1 Well a fractal is a structure which is self similary. That means its pieces look similar to the whole thing, but not alike.
Fractals are used to describe natural phenomena such as clouds, trees and coast lines.
Another quality of fractals are that their mathematically dimension is also fractured. It's often somewhere between a surface and a three dimensional body.
Why do I find them so fascinating?
Well, if you got a program which creates fractal images. You know the answer to this one already.There's always something new to it. If you change the params for the fractal, you got something new, each time.
And if you are a programmer, like myself, it is really fascinating to create pictures almost out of nowhere:-).
A small change in the code and you get a complete new fractal image. There are lots of different fractal types.For example the image above is of an Newton fractal in the complex plane. A Newton fractal is what you get if you iterate the Newton method for finding null points.
The examples below are all about Mandelbrot fractals, which where discovered by B. Mandelbrot on basis of Julia Set's. The latter where discovered by G. Julia and another Belgian mathematic.
These fractals are based on the formular:
Z = Z^2 + C
Z is a complex number which is iterated and C is a constant complex number. If you're now wondering what a complex number is, let's say its something mathematics have
defined to solve problems like the quare root of -1. A complex number consists of a real number and an imaginary part. The latter is called i. i is also defined as the
result of the quare root of -1. This imaginary number and the calculation rules for complex numbers are the roots of fractals like Mandelbrot or Julia Sets.
Calculation rules for complex numbers
Imaginary number iComplex numbersi^1 = + i
i^2 = - 1
i^3 = - i
i^4 = + 1
-------------
i^5 = + iZ = a + ib
Z1 + Z2 = (a1 + a2) + i(b1 + b2)
Z1 - Z2 = (a1 - a2) + i(b1 - b2)
Z1 * Z2 = (a1 * a2 - b1 * b2) + i(a1 * b2 + a2 * b1)
==> Z^2 = (a * a - b*b) + i(a * b + a*b)
==> Z^2 = a^2 - b^2 + i(a * b + a*b)
As you can see you need to know these calculation rules above to understand the formula Z =Z^2 + C. So let's see what we get if we solve the formula using the rules for complex numbers:
Z^2 becomes a1^2 - b1^2 + i(a1 * b1 + a1*b1) and C is a2 + ib2
Z^2 + C becomes {(a1^2 - b1^2) + a2} + i{ i(a1 * b1 + a1*b1) + b2}
If we call now the first part x and the second part y we get two formulas we can use to program the iteration method:
x = x^2 - y^2 + c1;
y = x * y + x*y + c2;
Mandelbrot and Julia fractals are closely related since the base on the same formular.
The Mandelbrot fractal can be used as a map for finding good params for Julia fractals.
For Julia fractals the param C is a constant and Z is the actual pixel. For Mandelbrot Sets each iteration starts with Z=0 while C is a the actual pixel.
Code Example (Java)
Below you can see an example for an iteration method for creating a Mandelbrot fractal.
Its output, the iteration count, can be used to assign different colors to pixels with different interation count.
/**
the complex number Z consists of x and y
@param:
p1: Beginning point on the x
p2: Beginning point on the y
c1,c2 the real and imaginar parts of the number,
which is added to Z:
c1 and c2 also represent the actual pixel
*/
public int mandelbrot(double c1, double c2)
{
double x =0, y = 0; // starting point
double lastX = x, lastY = y;
double x2=x*x, y2=y*y;
int iter=0; // set iteration counter to zero
do
{
y= x*y;
/*
used to spare calculation time
otherwise it would be necessary to
to do this more then once.
Just like this:
lastY = y*x + y*x + c1;
lastX = x*x - y*y + c2;
*/
lastY = y + y + c1;
lastX = x2 - y2 + c2;
x = lastX;
y = lastY;
x2=x*x; y2=y*y;
iter++;
if(iter == maxIteration) return iter;
} while( (x2+y2) < maxIteration) ;
return iter;
}
The while loop stops when the sum of the quadration of x and the quadration of y is equal or greater then the maximal interation count.
Note:This text isn't meant to be an exact scientific overview at this time.
If you speak German, here is a nice
descriptionJust some info for my and hopefully your entertainment.Enjoy!