The Mandelbrot Set

See all articles from CATS v3 n7
Author(s): Roald Schrack
Publication: CATS Newsletter
Pub Details: CATS v3 n7 (Volume 3, Issue 7)
Date: October 1985
Pages: 11

Computer Recreations

By A. K. Dewdney. Excerpted from: August 1985 Scientific American

The Mandelbrot set broods in silent complexity at the center of a vast two-dimensional sheet of numbers called the complex plane. When a certain operation is applied repeatedly to the numbers, the ones outside the set flee away to infinity. The numbers inside remain to drift or dance about. Close to the boundary minutely choreographed wanderings mark the onset of the instability. Here is an infinite regress of detail that astonishes us with its variety, its complexity and its strange beauty.

The set is named for Benoit B. Mandelbrot, a research fellow at the IBM Thomas J. Watson Research Center in Yorktown Heights, NY. From his work with geometric forms Mandelbrot has developed the field he calls fractal geometry, the mathematical study of forms having a fractional dimension. In particular, the boundary of the Mandelbrot set is a fractal, but it is also much more.

With the aid of a relatively simple program a computer can be converted into a kind of microscope for viewing the boundary of the Mandelbrot set. In principle one can zoom in for a closer look at any part of the set at any magnification. From a distant vantage the set resembles a squat, wart-covered figure eight lying on its side. Approaching the set one finds that each wart is a tiny figure shaped much like the parent set, however the magnified version is not quite the same set. As the zoom continues, each wart seems to reappear, but a closer look always turns up difference. Things go on this way forever, infinitely various and frighteningly lovely.

Roald Schrack has taken this idea and applied it to the 2068. His efforts follow.

The Mandelbrot Set

The August issue of the Scientific American has on its cover a computer-generated display. I tried the scheme on my 2068. The resolution is much poorer, but the results are quite fascinating. The program shows how I set up the algorithm. Not having a color monitor, I plotted shades of gray that are obtained by the use of user-defined graphics. The subroutine starting at line 200 is run once at the beginning to set up the graphics.

The shades of gray obtained for different values are shown here.

The nine shades of gray, numbered 0 to 8
The nine shades of gray, numbered 0 to 8

The algorithm evaluates the expression “z*z+c” where z and c are complex numbers. If the “size” of z is less than 2 then the procedure is iterated. After 100 iterations z is said to converge if its size is still < 2. If z becomes > 2 at an iteration, n, which is less than 100 , then the value of n is used to choose a level of gray; the smaller the value of n, the lighter the shade of gray. Line 140 shows that white is chosen for n<20. If you have a color monitor you can eliminate the subroutine starting at line 200 and change line 142 to:

PRINT INK a; AT x,Y; "█"

The program creates a display by testing for convergence for a different value of c at each screen location. A starting value of the real and imaginary parts of c, rcz and icz is entered on lines 20 and 30. For each screen position the values of rc and ic are incremented on lines 46 and 48. The size of the increment determines the detail in the image. I have chosen to cover the range that adds .001 to the starting values in generating my image. You can try more or less. I have chosen rcz=.26 and icz=0 as my starting values. You should read the original article to get ideas for different starting values.

You can get a factor of 8 improvement in the resolution by using the PLOT function. This should be tried only if you have a color monitor and you have lots of time. It takes about 2 hours to generate one of the images with the present resolution of 20 x 30,so it would take about 5 days to do an image 160 x 240.

Low resolution plot from this program, real part .26 to .261 across (y), imaginary part 0 to .001 down (x)
Low resolution plot from this program, real part .26 to .261 across (y), imaginary part 0 to .001 down (x)
  10 PRINT "give real and imaginary parts of c"
15 GO SUB 200
20 INPUT rcz
30 INPUT icz
32 CLS
40 FOR x=1 TO 20
42 FOR y=1 TO 30
44 LET n=1
46 LET rc=rcz+.000033*y
48 LET ic=icz+.00005*x
50 LET iz=0
60 LET rz=0
70 LET rz=rz*rz-iz*iz+rc
80 LET iz=2*rz*iz+ic
86 LET n=n+1
90 LET size=SQR (rz*rz+iz*iz)
100 IF (size>=2.) THEN GO TO 140
110 IF (n<=99) THEN GO TO 70
120 PRINT AT x,y;"█"
130 GO TO 150
140 LET a=INT ((n-20)/10)
142 PRINT AT x,y;CHR$ (145+a)
152 NEXT y
170 NEXT x
200 FOR m=0 TO 8
205 LET w=145+m
210 FOR p=0 TO 7
220 READ byte
230 POKE USR CHR$ w+p,byte
240 NEXT p
260 NEXT m
270 DATA 0,0,0,0,0,0,0,0
280 DATA 0,0,0,8,0,0,0,0
290 DATA 0,0,32,0,0,0,2,0
300 DATA 0,64,4,0,0,32,2,0
310 DATA 8,64,2,16,128,4,32,1
320 DATA 0,85,0,85,0,85,0,85
330 DATA 170,85,170,85,170.85,170,85
340 DATA 187,221,238,119,187,221,238,119
350 DATA 255,255,255,255,255,255,255,255
360 RETURN

R. A. Schrack


Complex Numbers

COMPLEX NUMBERS are an area of mathematics that has wide application in physics and in electrical engineering. The complex number Z has two components called the real and imaginary parts. Z= rZ + i * iZ where i= √-1. The rule for addition C = A + B is rc=ra+rb and ic=ia+ib. The rule for multiplication C = A * B is: rc=ra*rb-ia*ib & ic=ra*ib+rb*ia. Thus lines 70 and 80 above calculate the real and imaginary parts of Z = Z * Z + C .

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.