'Program MANCHAOS.BAS plots the Mandelbrot set with colors for different 'periods and black for aperiodic (chaotic) orbits (period > nb%). 'Compile this program with PowerBASIC (http://www.powerbasic.com/) '(c) 1997 by J. C. Sprott (http://sprott.physics.wisc.edu/) screen 12 defext a-z nb%=16000 'Bailout number (also highest period checked) dim x!(nb%),y!(nb%) for i%=0 to 639 a=-2.1+(8/3)*i%/640 if inkey$<>"" then end for j%=0 to 240 b=1-2*j%/480 c%=15 x=a y=b for k%=0 to nb% xnew=x*x-y*y+a ynew=2*x*y+b if csng(xnew)=csng(x) and csng(ynew)=csng(y) then c%=1 exit for end if x!(k%)=x: y!(k%)=y x=xnew y=ynew if x*x+y*y>4 then exit for if k%=nb% then found%=0: c%=0 for l%=nb% to 1 step -1 if x!(l%)=csng(x) and y!(l%)=csng(y) then c%=2+((nb%-l%) mod 13) exit for end if next l% end if next k% pset(i%,j%),c%: pset(i%,480-j%),c% next j% next i% line(0,0)-(639,479),0,b while inkey$="": wend end