# lorenz oscillator # x' = -10*(x-y) # y' = -xz+rx-y # z' = xy-8z/3 #---set parameters--- R = 50 M = 2000 Step = .01 Err_tol = .001 input R M Step #---define system--- N = 3 X = 0 Y[1] = 10 Y[2] = -10 Y[3] = 30 function F[1]() = -10*(Y[1]-Y[2]) function F[2]() = -Y[1]*Y[3]+R*Y[1]-Y[2] function F[3]() = Y[1]*Y[2]-8*Y[3]/3 #---optional i/o--- write_lab lorenz.csv X Y1 Y2 Y3 Step write_dat X Y[1] Y[2] Y[3] Step #---integration here--- for_i = 1 M call step: "midpoint.s" if abs(Y[1])+abs(Y[2])+abs(Y[3])>1.e3 show_line "Solution out of range on step " @i break end_if write_dat X Y[1] Y[2] Y[3] Step end_i close_file lorenz.csv show_line "Done, data in lorenz.csv" show_line "Wait for plot" system "..\thor ..\chaos\lorenz.thor"