Mandelbrot BASIC Program

The program below is written in the Turbo BASIC dialect that was introduced by Borland Software but may no longer be supported. It will require a bit of tweaking to run in a contemporary dialect like Microsoft QBASIC. If anyone does this I'd appreciate your letting me know at hedwards@math.uga.edu.


100 ! Program MANDEL
110
120 ! Constructs the portion of the Mandelbrot set
130 ! within the given xy-window of the plane.
140
150 LET XMIN = -2.25
155 LET XMAX = 1.75 !X interval
160 LET YMIN = -1.5
165 LET YMAX = 1.5 !Y interval
170 LET COLS = 640 !640 vertical columns
180 LET ROWS = 480 !480 horizontal rows
190 LET M = 50 !No of iterations
200 LET R = 2 !Escape radius
210
230 SET WINDOW XMIN,XMAX, YMIN,YMAX !Shown on screen
240 LET DX = (XMAX - XMIN)/COLS !640 by 480 grid in
250 LET DY = (YMAX - YMIN)/ROWS !high resolution
260 PLOT LINES: XMIN,YMIN; XMIN,YMAX !Left edge of window
270
280 !Loop columns from left to right,
290 !rows from bottom to top:
300
310 LET X = XMIN - DX/2 !X start
320 FOR J = 1 TO COLS !Jth column
330 LET X = X + DX !Increment X
340 LET Y = YMIN - DY/2 !Y start
350 PLOT POINTS: X,YMIN; X,YMAX !Top and bottom
360 FOR I = 1 TO ROWS !Ith row
370 LET Y = Y + DY !Increment Y
380 LET CR = X
385 LET CI = Y !Fix C = X + iY
390 LET ZI,ZR = 0 !Start at (0,0)
400 LET P = 0 !Iteration count
410
420 DO WHILE (P < M) AND (ZR*ZR + ZI*ZI < R*R)
430 LET P = P + 1
440 LET ZSQR = ZR*ZR - ZI*ZI !Real part of Z*Z
450 LET ZSQI = 2*ZR*ZI !Imaginary part
460 LET ZR = ZSQR + CR
470 LET ZI = ZSQI + CI !Z*Z + C --> Z
480 LOOP
490
500 IF P = M THEN PLOT POINTS: X,Y
505 ! (Point ofMandelbrot set)
510 NEXT I
530 NEXT J
540 PLOT LINES: XMAX,YMIN; XMAX,YMIN !Right edge of window
550
560 ! Press Command-Period to STOP
600 END