A Nonlinear Oscillator,
Numerical Solution

Problem 3, on P.S. #3, 2002.  Numerical check of perturbation
solution, problem not solved here.

Finds a numerical solution to:
y'' + y nonosc_pert_1.gif
with y'(0)=0 and y(0)=1.
The period in the numerical solution is then compared to the prediction made from the perturbation expansion.  The math for the
perturbation expansion is not shown here.

In[1]:=

nonosc_pert_2.gif

The following line was changed to text.  You may want to change the Format>Style to "Input" to execute the statement, and confirm that Mathematica cannot find an analytical solution:

DSolve[{y''[t]+y[t]+eps*y[t]^3==0,y[0]==1,y'[0]==0},y[t],t]

So we resort to a numerical solution for a specified value of eps:

In[2]:=

nonosc_pert_3.gif

In[3]:=

nonosc_pert_4.gif

Out[3]=

nonosc_pert_5.gif

Plot the analytical solution  for eps=0 in black and the numerical
solution for eps=0.5  in red:

In[4]:=

nonosc_pert_6.gif

Out[4]=

nonosc_pert_7.gif

Here we make a more convenient interface to access the interpolating function that contains the numerical solution.  Notice the replacement rule is inside a nested list, which is accessed by the [[1,1]]:

In[5]:=

nonosc_pert_8.gif

Let's give it a try:

In[6]:=

nonosc_pert_9.gif

Out[6]=

nonosc_pert_10.gif

Let's find  t where y(t)=0 in the numerical solution:

In[7]:=

nonosc_pert_11.gif

nonosc_pert_12.gif

nonosc_pert_13.gif

Out[7]=

nonosc_pert_14.gif

Now make a module to find the first t where y(t)=0 for a
specified value of ε.

In[8]:=

nonosc_pert_15.gif

Try it:

In[9]:=

nonosc_pert_16.gif

Out[9]=

nonosc_pert_17.gif

In[10]:=

nonosc_pert_18.gif

Out[10]=

nonosc_pert_19.gif

Make a table of ratio of the period of oscillation to that with ε=0.

In[11]:=

nonosc_pert_20.gif

Out[11]=

nonosc_pert_21.gif

In[12]:=

nonosc_pert_22.gif

In[13]:=

nonosc_pert_23.gif

Out[13]=

nonosc_pert_24.gif

Compare the numerical result, which we assume to be exact, (green) with the perturbation result (red).

In[14]:=

nonosc_pert_25.gif

Out[14]=

nonosc_pert_26.gif

Now compare with the perturbation result out to nonosc_pert_27.gif:

In[15]:=

nonosc_pert_28.gif

In[16]:=

nonosc_pert_29.gif

Out[16]=

nonosc_pert_30.gif

Spikey Created with Wolfram Mathematica 8.0