Jamaica 10 ch14 Introduction to Simple Fractals
From C64 Diskmag Wiki
introduction to simple fractals....tchad ---------------------------------------- yes, here is a small summary of the theories and the practical details about how to make a special form of fractals known as julia-sets and the mandelbrot- set. COMPLEX NUMBERS at first, you have to be familiar to so called complex numbers... complex numbers are based upon the factor sqr(-1), which is stated as I! an arbitrary complex number is stated as A + BI where a and b can be any real coefficient. EX. 2 + 3i 7 + 0.5i -1 - 2i or 0.65734 - 0.48786i A is called the REAL part of the complex number while B is called the IMAGINARY part. HOW TO DRAW COMPLEX GRAPHS to visualize complex numbers in an easy way, matematicians have invented a so called complex plane... that means that you use the a-coefficient as the x-coordinate and the b-coefficient as the y-coordinate and then draw a point at the corresponding place on the complex plane. the x-axis turns into real-axis and the y-axis turns into an imaginary-axis. EX. i i i i x (2 + 3i) (-5 + 2i) x i i ----------i---------- i x (6 - i) i (-3 - 3i) x i i i i THE THEORY BEHIND THE FRACTALS in the beginning of this century, some french matematicians called GASTON JULIA & PIERRE FATOU experimented with this kind of complex numbers. their special interest was caught by a simple iteration-formula like this : z = z^2 + c where both z and c can be complex numbers. they came to the conclusion that the iteration developed in different ways depending on the constant c. sometimes, z seemed to approach infinity and some- times it seemed to vary in a chaotic way and never exceed a special value! they started to make maps in the complex plane over the points whose complex value resulted in a chaotic behaviour of the iteration. the process was executed like this : 1. set c to any complex number. 2. examine each point in the complex plane and set z to its value in the beginning of the iteration. 3. repeat the iteration z = z^2 + c until the absolute value of z exceeds the value 2. if it never exceeds 2, then the point is within this actual julia-set and must be marked in the complex plane. 4. repeat this (from *2) for each of the points in the plane. THE ITERATION IN DETAIL & THE ABSOLUTE VALUE OF Z! to fully understand the iteration, you have to divide it into smaller pieces and represent the variables with complex expressions. z = z^2 + c like this: x+yi = (x+yi)^2 + a+bi x+yi = x^2+2xyi-y^2 + a+bi identify the real and the imaginary part of z : x = x^2-y^2+a y = 2xy+b this is the general formula, used while programming computers. but what is the absolute value of z?? well, you can say it's the distance from origo to z's place in the plane. this can be expressed as SQR (X_<9e>2 + Y_<9e>2) (according to old pythagoras) hence, each point that never shows any sign of developing z to exceed 2 is a part of the actual julia-set. DIFFERENT JULIA-SETS & THEIR CONNECTIONS there is a unique julia-set for each c-value and there are only some small connections between them. the simpliest julia-set is the one that has the c-constant = 0 + 0i. this julia-set is shaped like a perfect circle. even some small changes in the c-constant, changes the julia-set radically. it slowly meta- morphosizes into more and more complicated shapes. for instance, the julia-set for c = 0 + i looks like a crack in the ground or whatever your fantasy can come up with. at a certain limit, the julia sets changes from being fully connected to disconnected "islands". this limit is different, depending on the angle from origo to z. in fact, this limit is extremely complicated. THE MANDELBROT-SET ofcourse, this limit can be visualized in the complex plane. then it's more known under "the mandelbrot-set" the main-process for the mandelbrot-set is almost the same as for the julia-sets. z = z^2 + c the difference is that you don't keep c for constant anymore. instead you follow the complex plane with c, in the same way you did with z when generating julia-sets. the start-value for z is now equal to 0. some time, i might include a small routine for generating both mandelbrot- and julia-sets. VISUAL EFFECTS you don't have to mark just the points that belongs to the real set. in fact, this is very unusual. to receive the best effect, you usually choose to colour the point according to how fast they are attracted by infinity. for example, you can let the colour of a point depend on which iteration it showed the first sign of being attracted by infinity. if the point never does this, the iteration stops at a pre- defined amount (known as "max.iterations") and it's coloured black. this kind of technique is what you usually see the result of in demos and such. ... to be continued