'Program EULER.BAS illustrates numerical chaos in various ODEs solved by the 'Euler method with a large step size '(c) 1997 by J. C. Sprott (http://sprott.physics.wisc.edu/) SCREEN 12 PALETTE 0, 63: PALETTE 15, 0 DEFDBL A-Z DIM s\$(3) s\$(0) = "Van der Pol" s\$(1) = "Circle" s\$(2) = "Center" s\$(3) = "Lorenz" q\$ = " " c% = 0 h = .1 WHILE q\$ <> CHR\$(27) IF q\$ = CHR\$(0) + CHR\$(77) THEN c% = (c% + 1) MOD 4 'Right arrow IF q\$ = CHR\$(0) + CHR\$(75) THEN c% = (c% + 3) MOD 4 'Left arrow IF q\$ = CHR\$(0) + CHR\$(72) THEN h = 1.1 * h 'Up arrow IF q\$ = CHR\$(0) + CHR\$(80) THEN h = h / 1.1 'Down arrow IF q\$ <> "" THEN CLS LINE (0, 0)-(639, 479), , B LOCATE 2, 3: PRINT s\$(c%) LOCATE 3, 3: PRINT "h ="; CSNG(h) x = .01: y = .01 END IF SELECT CASE c% CASE 0 xnew = x + h * y y = y + h * ((1 - x * x) * y - x) x = xnew PSET (320 + 72 * x, 240 - 72 * y) CASE 1 xnew = x + h * y y = y + h * ((1 - x * x - y * y) * y - x) x = xnew PSET (320 + 150 * x, 240 - 150 * y) CASE 2 xnew = x + h * y y = y - h * x x = xnew PSET (320 + 1500 * x, 240 - 1500 * y) CASE 3 xnew = x + h * (x - y - x * x * x) y = y + h * (x - x * x * y) x = xnew PSET (320 + 180 * x, 240 - 180 * y) END SELECT q\$ = INKEY\$ WEND