! MANDELBROT PROGRAM:

!ITERATE in the complex plane : Zn+1 = Zn^2 + C,

!where Zn = Xn + i*Yn and is a complex variable, and

!C = Creal + i *Cimag is a constant for each iteration case,

! like "a" for the logistic equation: Xn+1 = a*Xn*(1-Xn).\

!Xn+1 = (Xn*Xn - Yn*Yn) + Creal,

!is the real part of Zn+1

!Yn+1 = 2*Xn*Yn + Cimag,

!is the imaginary part of Zn+1.

!Start always at Xo=0, Yo=0, and color black those points (C = Creal !+ i *Cimag) that DO NOT go to infinity.

!It can be shown that once Zn reaches a value outside a circle of radius 2

! it will surely go to infinity as you keep iterating,

!which makes the job of calculating the M-set a lot more friendly...

!

SET MODE "graphics"

ASK PIXELS hpix,vpix

LET ratio=hpix/vpix

SET WINDOW -2*ratio,2*ratio,-2,2

BOX CIRCLE -2,2,-2,2

BOX CIRCLE -.01,.01,-.01,.01

FOR j= -2 to 2 step .005

FOR k = -2 to 0 step .005

LET x = 0

LET y = 0

LET n = 0

DO

LET x1 = x*x - y*y + j

LET y1 = 2*x*y + k

LET r = x1*x1 + y1*y1

LET x = x1

LET y = y1

LET n = n+1

LOOP until r>4 or n>50

IF r<4 THEN PLOT j,k

IF r<4 THEN PLOT j,-k

NEXT k

NEXT j

END