1 duffing.mac is from the book "Computer Algebra in Applied Mathematics:
2 An introduction to MACSYMA", by Richard H Rand, Pitman (1984).
6 x''(T) + x + e*x^3 = e*f*cos(w*T)
8 It is a model of a nonlinear oscillator driven by a sinusiodal forcing
9 function. When e is small and the forcing frequency is close to the
10 natural frequency (of unity) the equation has one or more steady state
13 This program determines the periodic solutions using Lindstedt's method.
14 The code is very similar to vandpol.mac and mathieu.mac.
16 The original code produces an error. A small patch (below) is required
17 to get the code to run with maxima-5.9.0cvs.
19 The run below, using maxima-5.9.0cvs, reproduce the result on pages
20 127-134 of the book. In the first part, the problem is solved step by
21 step. Then the whole procedure is automated.
23 (C1) load("./duffing.mac");
33 (D4) a COS(t) + e y (t) + e y (t)
40 (D6)/R/ --- (y (t)) + a COS (t) + (- f - 2 k a) COS(t) + y (t)
46 (D7)/R/ --- (y (t)) - 2 k a COS (t) + 3 a y (t) COS (t)
51 + (2 k f + (- 2 k + 3 k ) a) COS(t) + y (t) - 2 k y (t)
55 d a COS(3 t) 3 a COS(t)
56 (D8) --- (y (t)) + ----------- - f COS(t) + ----------- - 2 k a COS(t) + y (t)
61 d a COS(3 t) (4 f - 3 a ) COS(t) 3 a COS(t)
62 (D9) --- (y (t)) + ----------- + ------------------- - f COS(t) + -----------
71 (D10) [k = - ----------]
76 (D11) y (t) = ----------- + %K1 SIN(t) + %K2 COS(t)
79 Inconsistent equations: (1 2)
81 -- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
87 (C1) load("./duffing.mac");
97 (D4) a COS(t) + e y (t) + e y (t)
104 (D6)/R/ --- (y (t)) + a COS (t) + (- f - 2 k a) COS(t) + y (t)
110 (D7)/R/ --- (y (t)) - 2 k a COS (t) + 3 a y (t) COS (t)
115 + (2 k f + (- 2 k + 3 k ) a) COS(t) + y (t) - 2 k y (t)
119 d a COS(3 t) 3 a COS(t)
120 (D8) --- (y (t)) + ----------- - f COS(t) + ----------- - 2 k a COS(t) + y (t)
125 d a COS(3 t) (4 f - 3 a ) COS(t) 3 a COS(t)
126 (D9) --- (y (t)) + ----------- + ------------------- - f COS(t) + -----------
135 (D10) [k = - ----------]
140 (D11) y (t) = ----------- + a SIN(t) + b COS(t)
145 (D12) [[a = 0, b = - --]]
150 (D13) y (t) = ----------- - ---------
154 d 3 a COS(5 t) 9 a f COS(3 t) 3 a COS(3 t) f COS(t)
155 (D14) --- (y (t)) + ------------- + --------------- - ------------- - ---------
160 11 a f COS(t) 21 a COS(t)
161 + -------------- - ------------ - 2 k a COS(t) + y (t)
165 d 3 a COS(5 t) 9 a f COS(3 t) 3 a COS(3 t)
166 (D15) --- (y (t)) + ------------- + --------------- - -------------
171 (32 f - 44 a f + 21 a ) COS(t) f COS(t) 11 a f COS(t) 21 a COS(t)
172 + -------------------------------- - --------- + -------------- - ------------
180 (D16) [k = - -----------------------]
185 a COS(5 t) + (36 a f - 24 a ) COS(3 t)
186 (D17) y (t) = ---------------------------------------- + a SIN(t) + b COS(t)
191 (D18) [[a = 0, b = - ---------------]]
195 a COS(5 t) + (36 a f - 24 a ) COS(3 t)
196 (D19) y (t) = ----------------------------------------
200 (36 a f - 23 a ) COS(t)
201 - ------------------------
205 The process can be automated
209 y (t) = ----------- - ---------
213 a COS(5 t) 9 a f COS(3 t) 3 a COS(3 t) 9 a f COS(t)
214 y (t) = ----------- + --------------- - ------------- - -------------
223 a COS(7 t) 13 a f COS(5 t) 3 a COS(5 t) 81 a f COS(3 t)
224 y (t) = ----------- + ---------------- - ------------- + ----------------
225 3 32768 6144 2048 2048
228 423 a f COS(3 t) 297 a COS(3 t) 81 a f COS(t) 1217 a f COS(t)
229 - ----------------- + --------------- - -------------- + ----------------
230 8192 16384 2048 24576
238 e (128 f - 236 a f + 221 a f - 81 a ) e (32 f - 44 a f + 21 a )
239 w= - ------------------------------------------ - ----------------------------
251 --- duffing.mac.orig 2004-02-14 11:42:26.389030400 +1100
252 +++ duffing.mac 2004-02-14 11:27:35.948640000 +1100
254 :expand(trigreduce(expand(ev(eq[i],makelist([e[j],f[j]],j,1,i-1),
256 step2(i):=(f[i]:solve(coeff(temp1,cos(t)),k[i]),temp1:ev(temp1,f[i]))$
257 -step3(i):=temp1:ev(ode2(temp1,y[i](t),t),%k1:a[i],%k2:b[i])$
258 +step3(i):=(temp1:ode2(temp1,y[i](t),t),
259 + temp1:subst(a[i],%k1,temp1),temp1:subst(b[i],%k2,temp1))$
260 step4(i):=(temp2:rhs(temp1),temp2:diff(temp2,t),
261 temp2:solve([ev(rhs(temp1),t:0),ev(temp2,t:0)],[a[i],b[i]]))$
262 step5(i):=e[i]:ev(temp1,temp2)$