Chaos Written by Ian Holbrough (ianholbrough@callnetuk.com) Honorable Mention, Winter 1999 ECS BASIC Programming Competition March 12, 1999 ________________________________________________________________ Its a demonstration of chaotic behaviour on the Inty. It uses the well known chaotic construct Xn+1=Xn ( K - Xn ) Where K is the feedback factor Xn is the current value of X Xn+1 is the next value of X The program initially asks for value of K 0 - ~2 tend to a single digit ~2 - ~3.5 tend to 2 or 4 or 8 stable cycle points ~3.5 - 4 tend to chaos and a seed for Xn (typically any value will do) The screen will then clear and the values of X are plotted, accompanied by a sound. The scale on the screen is 0 - 4 with 0 being the left hand edge, 4 being the right. Press 1 on the keypad at any time to enter new values. Chaos v1.1 I got the math slightly wrong, having looked it up this morning rather than playing it from memory. The function should have been Xn+1 = K Xn ( 1 - Xn ) not Xn+1 = Xn ( K - Xn ) as I stated and programmed. The difference only seems to affect the range of possible Xn's generated by the function, limiting it to the range 0 - 1. Therefore, the plotting function now displays fro 0 on the left to 1 on the right. I also added graticules at 0, 0.25, 0.5 and 0.75 to help with visualising. With regard to the math, its all to do with the determinism of the function. For low values of K over time Xn will tend to a single stable value. However, as K increases it this stable value increases. Suddnely this behaviour stops and Xn never stettles down but oscillates between 2 values. This change in behaviour is known as a bifurcation (or some other similar spelling). This process continues. However, at some point the oscillation breaks down altogether, and no repeating pattern is decernable in the numbers. Although deterministic the behaviour is chaotic. I can recommend a book on the subject "Chaos by James Gleick ISBN 0 7474 0413 5" 10 C=1 20 E=0 30 L=1000 200 GSUB 900 210 PRIN "ENTER K THE" 220 PRIN "FEEDBACK FACTOR" 230 PRIN "RANGE (0-4)" 240 PRIN "OR -1 TO EXIT" 250 PRIN " " 260 INPU K 270 IF (K=-1) GOTO 800 280 IF (K>4) GOTO 200 290 IF (K<0) GOTO 200 300 GSUB 900 310 PRIN "ENTER XN THE" 320 PRIN "SEED NUMBER" 330 PRIN "RANGE (0-1)" 340 PRIN "OR -1 TO EXIT" 350 PRIN " " 360 INPU X 370 IF (X=-1) GOTO 800 380 IF (X>1) GOTO 300 390 IF (X<0) GOTO 300 500 FM(4)=0 510 CLR 520 SET A$=": : : : " 530 A=X*20 540 A$(A)=10 550 PUT A$ 560 P=(1-X)*4096 570 CALL ENVT 580 CALL HAND 590 IF (H=1) GOTO 200 600 X=K*X*(1-X) 610 GOTO 520 800 GSUB 900 810 PRIN "THANK YOU" 820 PRIN " " 830 END 900 CLR 910 CALL HUSH 920 FM(4)=1 930 PRIN " INTY CHAOS!" 940 PRIN " BY FASTED" 950 FM(4)=0 960 PRIN "-------------------- " 970 RET