!LORENTZ EQUATIONS

!dx/dt = S(y-x)

!dy/dt = R*x - y - xz

!dz/dt = xy -Bz

!USE S = 10, R = 28, B = 8/3, x0 = z0 = 0, y0 =1

!deltat = 0.001

SET MODE "graphics"

SET COLOR "GREEN"

OPEN #1: SCREEN 0,1,0,.33

SET WINDOW 0,50,-30,30

SET COLOR "YELLOW"

PLOT 0,0;50,0

SET COLOR "BLACK"

PLOT 0,-30;50,-30

PLOT 0,30;50,30

OPEN #2: SCREEN 0,1,.33,.66

SET WINDOW 0,50,-30,30

SET COLOR "YELLOW"

PLOT 0,0;50,0

SET COLOR "BLACK"

PLOT 0,-30;50,-30

PLOT 0,30;50,30

!

OPEN #3: SCREEN 0,1,.66,.99

SET WINDOW 0,50,-30,30

SET COLOR "YELLOW"

PLOT 0,0;50,0

SET COLOR "BLACK"

PLOT 0,-30;50,-30

PLOT 0,30;50,30

!

SET COLOR "BLACK"

LET S=10

LET R=28

LET B=8/3

!

LET x=0

LET y=1

LET z=0

!

LET x2=0

LET y2=1.0001

LET z2=0

!

WINDOW #1

PRINT "x0=";x,"y0=";y,"z0=";z

!

WINDOW #2

PRINT "x0=";x2,"y0=";y2,"z0=";z2

WINDOW #3

PRINT "ERROR WINDOW"

PRINT x2-x,y2-y,z2-z

!

SET COLOR "BLUE"

LET DT = 0.01

!

DO WHILE t<=50

!

LET xdot = S*(y-x)

LET ydot = R*x - y - x*z

LET zdot = x*y - B*z

LET x = x + xdot*DT

LET y = y + ydot*DT

LET z = z + zdot*DT

!

LET xdot2 = S*(y2-x2)

LET ydot2 = R*x2 - y2 - x2*z2

LET zdot2 = x2*y2 - B*z2

LET x2 = x2 + xdot2*DT

LET y2 = y2 + ydot2*DT

LET z2 = z2 + zdot2*DT

LET t = t + DT

! !

WINDOW #1

PLOT t,x;

!

WINDOW #2

PLOT t,x2;

!

WINDOW #3

PLOT t,x-x2;

!

LOOP

!

END