This MuPad program demonstrates a "regular perturbation expansion" for a duffing equation with a weak nonlinearity.

 

First, we reset the workspace. Always do this. And when you want to run the program again, do: Notebook>Evaluate All.

 

reset();

 

We define the form of the solution. For convenience, we use the letter 'a' instead of epsilon. Note that we have defined x, x0, x1 as functions of t. If we did not, when we differentiate with respect to time, we will get zero.

 

Also, remember in all these assignment statements to use := instead of =. This is a common error and can cause hours of frustration :)

 

x(t):=x0(t) + a*x1(t)

x0(t) + a*x1(t)

To take the second derivative, we use diff(x(t),t,t). The first derivative is of

 

xdotdot :=diff(x(t),t,t)

a*diff(x1(t), t, t) + diff(x0(t), t, t)

 

We now define a variable called 'diffeq' that contains the LHS of the differential equation. Again, continue to use x(t).

 

diffeq:=xdotdot+x(t)+a*(x(t))^3

x0(t) + a*(x0(t) + a*x1(t))^3 + a*x1(t) + a*diff(x1(t), t, t) + diff(x0(t), t, t)

 

We now get the zeroth order term corresponding to a^0 in the above equation by setting a=0.

 

diffeq_0:=subs(diffeq,a=0)

diff(x0(t), t, t) + x0(t)

 

Now we get the coefficient of a^1 in two steps. (1) Take the derivative of diffeq with respect to a and (2) evaluate this derivative at a=0.

 

diffeq_1:=diff(diffeq,a)

x1(t) + (x0(t) + a*x1(t))^3 + 3*a*x1(t)*(x0(t) + a*x1(t))^2 + diff(x1(t), t, t)

diffeq_1:= subs(diffeq_1,a=0)

diff(x1(t), t, t) + x0(t)^3 + x1(t)

 

Now that we have the two differential equations, let us solve them one by one.

 

First, in MuPad, we have to "define" the ODE using the function called ode. The syntax is as follows. check help for more information.

 

diffeq_0:=ode({diffeq_0=0,x0'(0)=0},x0(t))

ode({D(x0)(0) = 0, (D@@2)(x0)(t) + x0(t)}, x0(t))

x0_sol:=solve(diffeq_0)

{C60*cos(t)}

x0_sol:=x0_sol[1]

C60*cos(t)

diffeq_1:=subs(diffeq_1,x0(t)=x0_sol)

diff(x1(t), t, t) + C60^3*cos(t)^3 + x1(t)

diffeq_1:=Simplify(diffeq_1)

diff(x1(t), t, t) + C60^3*cos(t)^3 + x1(t)

diffeq_1:=ode({diffeq_1=0,x1'(0)=0},x1(t))

ode({D(x1)(0) = 0, C60^3*cos(t)^3 + (D@@2)(x1)(t) + x1(t)}, x1(t))

Simplify(solve(diffeq_1))

{(C60^3*cos(t)^3)/8 - (3*C60^3*cos(t))/8 - (3*t*sin(t)*C60^3)/8 + C64*cos(t)}

 

OK, in the above solution, the third term has 't' sitting in front and this will grow to infinity as t goes to infinity. Such a term is called a "secular" term.

 

What is the meaning of this secular term? We know that the motion is bounded and never grows to infinity, so why does this solution say that it grows to infinity.

 

Unfortunately, this is a drawback of this method. It turns out that this method generates more and more of these "secular" terms as we expand to higher and higher orders of 'a'. Each of these terms is bigger than the previous, but they all cancel each other to produce a convergent series. But this is rather useless as we would like to truncate at one or two orders of 'a'.

 

The so-called Lindstedt-Poincare method fixes this problem.