The Mandelbrot Set

Authors

Roald Schrack

Publication

Publication Details

Volume: 3 Issue: 7

Date

October 1985

Pages

11
See all articles from CATS v3 n7
The Mandelbrot Set
Low resolution plot from this program.

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 use of user-defined graphics. The routine 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 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 the value of n, 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 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 of 160 x 240.

1 rem Mandelbrot set in low resolution by Roald Schack
2 rem https://archive.org/details/cats-newsletter/CATS%20v3%20n7%20Oct%201985/page/11/mode/1up
10 print "Give real or imaginary parts of c"
15 go sub 200
20 input rcz
30 input icz
32 cls
40 for x=1 to 20
43 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
190 stop
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

Products

 

Downloadable Media

Scroll to Top