1average.mac is from the book "Perturbation Methods, Bifurcation Theory and
2Computer Algebra" by Rand & Armbruster (Springer 1987)
3
4average() allows one to perform first and second order averaging on an
5n-dimensional system of nonautonomous odes.  Averaging is performed
6by converting trig terms to complex exponentials, then killing
7exponentials.
8
9The example is from p114.  The method of averaging is applied to the
10van der Pol oscillator
11
12	z'' + z = e*(1-z^2)*z'
13
14In the following transcript:
15 - first order averaging is performed
16 - second order averaging is performed without re-entering the equations
17 - the second order solution is transformed to polar coordinates
18maxima-5.9.0 cvs reproduces the results from the book.
19
20(C1) load("./average.mac");
21(D1)                             ./average.mac
22(C2) average();
23DO YOU WANT TO ENTER A NEW PROBLEM? (Y/N)
24Y;
25ARE YOU CONSIDERING A WEAKLY NONLINEAR OSCILLATOR OF THE FORM
26Z'' + OMEGA0^2 Z = EPS F(Z,ZDOT,T) ? (Y/N)
27Y;
28ENTER OMEGA0
291;
30ENTER F(Z,ZDOT,T)
31(1-Z^2)*ZDOT;
32DO YOU WANT FIRST OR SECOND ORDER AVERAGING?  (1/2)
331;
34                         2     3                 3     2
35                    Y1 Y2    Y1    Y1          Y2    Y1  Y2   Y2
36(D2)        [EPS (- ------ - --- + --), EPS (- --- - ------ + --)]
37                      8       8    2            8      8      2
38
39(C3) average();
40DO YOU WANT TO ENTER A NEW PROBLEM? (Y/N)
41N;
42DO YOU WANT FIRST OR SECOND ORDER AVERAGING?  (1/2)
432;
44                        5        2   3       3        4          2
45                2  11 Y2    11 Y1  Y2    3 Y2    11 Y1  Y2   3 Y1  Y2   Y2
46(D3) MATRIX([EPS  (------ + ---------- - ----- + --------- - -------- + --)
47                    256        128        16        256         16      8
48
49               2     3                          4        3   2          2
50          Y1 Y2    Y1    Y1        2    11 Y1 Y2    11 Y1  Y2    3 Y1 Y2
51 + EPS (- ------ - --- + --)], [EPS  (- --------- - ---------- + --------
52            8       8    2                 256         128          16
53
54        5       3                  3     2
55   11 Y1    3 Y1    Y1           Y2    Y1  Y2   Y2
56 - ------ + ----- - --) + EPS (- --- - ------ + --)])
57    256      16     8             8      8      2
58
59(C4) load("./transfor.mac");
60(D4)                            ./transfor.mac
61(C5) transform();
62ENTER NUMBER OF EQUATIONS
632;
64ENTER SYMBOL FOR ORIGINAL VARIABLE 1
65Y1;
66ENTER SYMBOL FOR ORIGINAL VARIABLE 2
67Y2;
68ENTER SYMBOL FOR TRANSFORMED VARIABLE 1
69R;
70ENTER SYMBOL FOR TRANSFORMED VARIABLE 2
71THETA;
72THE RHS'S OF THE D.E.'S ARE FUNCTIONS OF THE ORIGINAL VARIABLES:
73ENTER RHS OF Y1 D.E.
74D Y1 /DT =
75RESULT[1,1];
76                      5        2   3       3        4          2
77              2  11 Y2    11 Y1  Y2    3 Y2    11 Y1  Y2   3 Y1  Y2   Y2
78D Y1 /DT = EPS  (------ + ---------- - ----- + --------- - -------- + --)
79                  256        128        16        256         16      8
80
81                                                                 2     3
82                                                            Y1 Y2    Y1    Y1
83                                                   + EPS (- ------ - --- + --)
84                                                              8       8    2
85ENTER RHS OF Y2 D.E.
86D Y2 /DT =
87RESULT[2,1];
88                           4        3   2          2        5       3
89              2    11 Y1 Y2    11 Y1  Y2    3 Y1 Y2    11 Y1    3 Y1    Y1
90D Y2 /DT = EPS  (- --------- - ---------- + -------- - ------ + ----- - --)
91                      256         128          16       256      16     8
92
93                                                              3     2
94                                                            Y2    Y1  Y2   Y2
95                                                   + EPS (- --- - ------ + --)
96                                                             8      8      2
97THE TRANSFORMATION IS ENTERED NEXT:
98ENTER Y1 AS A FUNCTION OF THE NEW VARIABLES
99Y1 =
100R*COS(THETA);
101Y1 = R COS(THETA)
102ENTER Y2 AS A FUNCTION OF THE NEW VARIABLES
103Y2 =
104R*SIN(THETA);
105Y2 = R SIN(THETA)
106                   3    2               3    2
107       dR     EPS R  SIN (THETA) + EPS R  COS (THETA) - 4 EPS R
108(D5) [[-- = - -------------------------------------------------,
109       dT                             8
110
111dTHETA            2  4    4                 2  4    2                2  2
112------ = - (11 EPS  R  SIN (THETA) + (22 EPS  R  COS (THETA) - 48 EPS  R )
113  dT
114
115    2                2  4    4                2  2    2                2
116 SIN (THETA) + 11 EPS  R  COS (THETA) - 48 EPS  R  COS (THETA) + 32 EPS )/256]]
117
118
119(C6) trigsimp(%);
120                   3                             2  4         2  2         2
121       dR     EPS R  - 4 EPS R  dTHETA     11 EPS  R  - 48 EPS  R  + 32 EPS
122(D6) [[-- = - ----------------, ------ = - ---------------------------------]]
123       dT            8            dT                      256
124
125
126
127
128Local Variables: ***
129mode: Text ***
130End: ***