A89: Re: i need math and programming help!!


[Prev][Next][Index][Thread]

A89: Re: i need math and programming help!!




Hi!

> alright, below is a segment of code from a mandelbrot generator.
> can anyone explain to me how this code segment relates to the 
> mandelbrot fractal equation
> z = z^2 + c

This is not the correct equation. The mandelbrot set tries an
itterative process

z[k+1]=z[k]^2+c

where z[0]=x+y*i, i is an imaginary unit, and c is some selected complex
constant. (x,y) are coordinates of a pixel. Then, this sequence is tested
for a convergence, trying to determine the behaviour of z[k] when k tends
to an infinity (in the given program, it iterates this recurency equation
maxiter times, and if z[k] is going to be very large the conclusion is
that the sequence diverges. If the sequence converges, the pixel (x,y) is
left blank, but if it diverges, it is turned to on (on computers with 
colors, the color of the pixel need to be lighter if the sequence
diverges faster, which can be measured by counting the number of
iterations before reaching some critical large value).

Now, introduce the following replacement:

z[k]=x[k]+i*y[k],    c=cx+i*cy

where x[0]=x and y[0]=y obviously. Now the equation z[k+1]=z[k]^2+c
becomes

x[k+1]+i*y[k+1]=(x[k]+i*y[k])^2+(cx+i*cy)

After separating real and imaginary parts, you will get:

x[k+1]=x[k]^2-y[k]^2+cx
y[k+1]=2*x[k]*y[k]+cy

You can see that these iterative equations are the just ones
implemented in the program.

Cheers,

Zeljko Juric