1 /* Mathieu's equation: third order averaging */
5 depends([w1,w2,v1,v2,u1,u2],[abar,psibar,t]);
6 depends([abar,psibar],t);
9 f:-4*x*(del1+e*del2+e^2*del3+cos(2*t));
10 de1:[diff(a,t)=-e*sin(t+psi)*f,diff(psi,t)=-e/a*cos(t+psi)*f];
11 transf:[a=abar+e*w1+e^2*v1+e^3*u1,psi=psibar+e*w2+e^2*v2+e^3*u2];
13 de3:solve(%,[diff(abar,t),diff(psibar,t)])$
14 de4:taylor(de3,e,0,3)$
15 for i:0 thru 3 do eq[i]:coeff(de4,e,i);
19 /* first order averaging */
21 ws2:expand(trigreduce(expand(ws1)))$
23 ws4:ws3,%integconst1:0,%integconst2:0$
24 ws5:ws4-ratcoef(ws4,t)*t$
25 ws6:solve(part(ws5,1),[w1,w2]);
27 neweq[1]:expand(trigreduce(expand(ws7)));
29 /* second order averaging */
31 vs2:expand(trigreduce(expand(vs1)))$
33 vs4:vs3,%integconst3:0,%integconst4:0$
34 vs5:vs4-ratcoef(vs4,t)*t$
35 vs6:solve(part(vs5,1),[v1,v2]);
37 neweq[2]:expand(trigreduce(expand(vs7)));
39 /* third order averaging */
40 us1:eq[3],ws6,vs6,diff$
41 us2:expand(trigreduce(expand(us1)))$
43 us4:us3,%integconst5:0,%integconst6:0$
44 us5:us4-ratcoef(us4,t)*t$
45 us6:solve(part(us5,1),[u1,u2]);
47 neweq[3]:expand(trigreduce(expand(us7)));
49 neweqs:sum(neweq[i]*e^i,i,0,3);
51 depends([xbar,ybar],t);
52 depends([abar,psibar],t);
53 [xbar = abar*cos(psibar),ybar = -abar*sin(psibar)];
60 ev(%,sin(psibar) = -ybar/abar,cos(psibar) = xbar/abar);