1/* Filename mathieu.mac
2
3   ***************************************************************
4   *							         *
5   *                     <package name>                          *
6   *                <functionality description>                  *
7   *                                                             *
8   *          from: Computer Algebra in Applied Math.            *
9   *                   by Rand (Pitman,1984)                     *
10   *                Programmed by Richard Rand                   *
11   *      These files are released to the public domain          *
12   *            						 *
13   ***************************************************************
14*/ /*
15(d4) This program computes the transition curves in
16
17
18 Mathieu's equation using a perturbation method.
19
20
21Call it by typing:
22
23
24                      MATHIEU()
25
26*/
27
28mathieu():=(input(),y0:cos(t),findtc(),y0:sin(t),findtc())$
29input():=(n:read("ENTER TRANSITION CURVE NUMBER N"),
30      m:read("ENTER DEGREE OF TRUNCATION"))$
31findtc():=(setup1(),setup2(),for i thru m do (step1(),step2(),step3()),
32       output())$
33setup1():=(w:1,for i thru m do w:w+k[i]*e^i,x:y0,
34       for i thru m do x:x+y[i](t)*e^i)$
35setup2():=(temp1:diff(x,t,2)+x*(w+4/n^2*e*cos(2*t/n)),
36       temp1:taylor(temp1,e,0,m),for i thru m do eq[i]:coeff(temp1,e,i))$
37step1():=temp1
38      :expand(trigreduce(expand(ev(eq[i],makelist([e[j],f[j]],j,1,i-1),
39				   diff))))$
40step2():=(f[i]:solve(coeff(temp1,y0),k[i]),temp1:ev(temp1,f[i]))$
41step3():=(temp1:ode2(temp1,y[i](t),t),e[i]:ev(temp1,%k1:0,%k2:0))$
42output():=(print("delta=",expand(n^2/4*ev(w,makelist([f[j]],j,1,m)))),
43       print(" "))$
44