
!MANDELBROT PROGRAM: BOUNDARY SCAN
SET MODE "graphics"
ASK PIXELS hpix,vpix
LET ratio=hpix/vpix
SET WINDOW -2,2,-2/ratio,2/ratio
DIM JK(-301 TO 301,-301 TO 301)
!Creates a big matrix of about 600x600 to store the results of the iteration for the points (j,k) in the c-plane
!By default, all elements of JK are initially zero.
FOR j=-300 to 300
FOR k = -300 to 300
LET x = 0
LET y = 0
FOR n=1 to 200
LET x1 = x*x - y*y + j/150
LET y1 = 2*x*y + k/150
LET rsq = x1*x1 + y1*y1
IF rsq>4 THEN EXIT FOR
LET x = x1
LET y = y1
NEXT n
IF n>200 THEN LET JK(j,k)=1
!NOTE: JK=0 except at the points belonging to the M-set, where JK=1.
NEXT k
NEXT j
FOR j=-300 to 300
FOR k = -300 to 300
IF JK(j,k)=1 AND (JK(j+1,k)=0 OR JK(j-1,k)=0 OR JK(j,k+1)=0 OR JK(j,k-1)=0) THEN PLOT j/150,k/150
!NOTE: Boundary Plot : it only plots those points on the M-set which have at least one neighbor not on the M-set
NEXT k
NEXT j
END