BASIC Source Code For Simulating Nth-Order Non-Linear Differential Equations
Signal Display Systems ã 2004
The following code examples illustrate how to expand Nth-order chaotic equations and to find iterative solutions numerically using this expansion:
Phase 2.bas:
10 Cls
Rem This source code is copyrighted by Signal Display Systems, Inc. 2003, All rights reserved
Rem when x1=x2 the unstable region is x1 < -.263 and x1 >.263 if param1 = 3 and
Rem param2 = 2. For these paramters, chaotic behavior occurs when
Rem x1 > -.263 and x1 <.263 (assuming x1 = x2)
Rem x1 and x2 are initial conditions, param1 and param2 are characteristic
Rem values of the equation (see line70)
Rem
Rem osc5 is for param1 = 1.5 and param2 = 1
Rem osc6 is for param1 = 6 and param2 = 4
Rem osc7 is for param1 = param2 = 0.025
Rem stability points are proportional to (1/param1 || 1/param2)
Rem If param1 = param2, stability points = 1/(2*param1)
Rem current paramters on line 12 and 13
12 param1 = 3
13 param2 = 2
15 INPUT "INPUT INITIAL X1 VALUE "; x1
16 INPUT "INPUT INITIAL X2 VALUE "; x2
20 INPUT "INPUT OUT FILE NAME "; FILE$
Rem Line 20 asks for the output file to write data to
Rem the output file is data sequentially calculated on line 70
Rem and is basically time-domain output
Rem
50 OPEN "O", #1, FILE$
52 For A = 2.8 To 4! Step 0.025
60 For I = 1 To 1000
65 Rem characteristic equation below
70 x = param1 * A * X1 * X1 - param2 * A * X2 * X2
71 X2 = X1: X1 = x
Rem Line 71 says - update x1 and x2. x2 is the oldest value so it gets
Rem transfered from x1 first. Then x1 gets updated from the new x value
Rem From the write-up, x1 is the same as Vo(k-1) and x2 is the same as
Rem Vo(k-2), and x is the same as Vo(k)
Rem The differential equation starts with Vc1 and Vc2 and all of its
Rem derivatives. The difference equation takes this and converts the
Rem derivatives to Vo(k-n) where n is the nth derivative of Vc. This
Rem is because the time rate of change of function (derivative) can
Rem be expressed as [Vo(k) - Vo(k-1)]/T, where T is taken to be 1 time
Rem unit, or T = 1 for the first derivative.
Rem 72 IF I > 80 THEN 80 ELSE 90
Rem Line 72 is if you want to cut-off the first 80 values - there appears
Rem to be a lot of information in these values though
80 Print #1, A, x
85 N = N + 1
90 Next I
95 Next A
100 Close #1
105 Print N
110 End
Seqdat2.bas:
1 Rem This is the same program as phase2.bas but with four initial conditions
2 Rem instead of two initial cond's as in phase2.bas.
3 Rem More initial conditions can be added (hypothetically infinite if your
4 Rem processor has enough floating point accuracy) by expanding upon the formula
5 Rem in lines 70 and 71. Param1 and param2 produce smaller convergence points
6 Rem for the chaotic action as more init. conditions are added.
7 Rem This code is copyrighted by Signal Display Systems, Inc. 2003, All rights reserved
8 Rem *********************************************************************************
10 Cls
12 param1 = 3
13 param2 = 2
14 param3 = 2: param4 = 2
15 INPUT "INPUT INITIAL X1 VALUE "; x1
16 INPUT "INPUT INITIAL X2 VALUE "; x2
17 INPUT "INPUT INITIAL X3 VALUE "; x3
18 INPUT "INPUT INITIAL X4 VALUE "; x4
20 INPUT "INPUT OUT FILE NAME "; FILE$
Rem Line 20 asks for the output file to write data to
Rem the output file is data sequentially calculated on line 70
Rem and is basically time-domain output
Rem
50 OPEN "O", #1, FILE$
52 For A = 2.8 To 4! Step 0.025
60 For I = 1 To 1000
70 x = param1 * A * X1 * X1 * X1 * X1 - param2 * A * X2 * X2 * X2 * X2 - param3 * A * x3 * x3 * x3 * x3 - param4 * A * x4 * x4 * x4 * x4
71 x4 = x3: x3 = X2: X2 = X1: X1 = x
80 Print #1, A, x
90 Next I
95 Next A
100 Close #1
110 End