Perturbation Solution of
x^2 + ϵ x - 1    = 0

Find  an approximate solution of
x^2 + ϵ x - 1 = 0
as
x(ϵ) = Underoverscript[∑, n = 0, arg3]  x _ n ϵ^n
The equation obviously has an analytical solution, so the purpose
here is to demonstrate the perturbation method on an equation with
a known solution, so that we can see that the method works.

In[1]:=

Off[General :: spell1]

First, define the equation:

In[2]:=

qe = x^2 + ϵ x - 1 == 0 ;

Find the exact solutions, which comes out as a list of 2 replacment rules:

In[3]:=

qex = Solve[qe, x]

Out[3]=

{{x -> 1/2 (-ϵ - (4 + ϵ^2)^(1/2))}, {x -> 1/2 (-ϵ + (4 + ϵ^2)^(1/2))}}

Show how to access the element of a list (in case you do not know):

In[4]:=

qex[[2]]

Out[4]=

{x -> 1/2 (-ϵ + (4 + ϵ^2)^(1/2))}

In[5]:=

qex[[2, 1]]

Out[5]=

x -> 1/2 (-ϵ + (4 + ϵ^2)^(1/2))

Check that these solutions really do satisfy qe:

In[6]:=

qe /. qex[[1, 1]] // Simplify

Out[6]=

True

In[7]:=

qe /. qex[[2, 1]] // Simplify

Out[7]=

True

Define functions x(ϵ)for the two exact, analytical solutions

In[8]:=

xe2[ϵ_] = x /. qex[[1]]

Out[8]=

1/2 (-ϵ - (4 + ϵ^2)^(1/2))

In[9]:=

xe1[ϵ_] = x /. qex[[2]]

Out[9]=

1/2 (-ϵ + (4 + ϵ^2)^(1/2))

Now prepare to find an approximate  perturbation solution.  Note
the O[ϵ] symbol is powerful in Mathematica, try changing {n,0,2} to {n,0,10) and see what happens...

In[10]:=

xs = Sum[x _ n ϵ^n, {n, 0, 2}] + O[ϵ]^3

Out[10]=

x _ 0 + x _ 1 ϵ + x _ 2 ϵ^2 + O[ϵ]^3

Substitute the series solution for xinto the equation qe:

In[11]:=

peq = qe /. x -> xs

Out[11]=

(-1 + x _ 0^2) + (x _ 0 + 2 x _ 0 x _ 1) ϵ + (x _ 1 + x _ 1^2 + 2 x _ 0 x _ 2) ϵ^2 + O[ϵ]^3 == 0

LogicalExpand is really cool, and works because of the presence of the O[ϵ] symbol :

In[12]:=

eqns = LogicalExpand[peq]

Out[12]=

-1 + x _ 0^2 == 0 && x _ 0 + 2 x _ 0 x _ 1 == 0 && x _ 1 + x _ 1^2 + 2 x _ 0 x _ 2 == 0

The "logical and" might just as well be a list of equations that need to be true.  In fact the equation can be accessed as list, for example:

In[13]:=

eqns[[1]]

Out[13]=

-1 + x _ 0^2 == 0

Obviously, the above equation has solutionx x _ 0 = 1 and x _ 0 = -1.
Taking FormBox[RowBox[{x _ 0, =, RowBox[{1, we,  , solve,  , for,  , Cell[TextData[Cell[BoxData[x ]]]]}]}], TraditionalForm]                                                                                           1and x _ 2:

In[14]:=

proot = Solve[{x _ 0 == 1, eqns[[2]], eqns[[3]]}, {x _ 1, x _ 2}]

Out[14]=

{{x _ 2 -> 1/8, x _ 1 -> -1/2}}

Similarly,  with x _ 0 = -1 :

In[15]:=

nroot = Solve[{x _ 0 == -1, eqns[[2]], eqns[[3]]}, {x _ 1, x _ 2}]

Out[15]=

{{x _ 2 -> -1/8, x _ 1 -> -1/2}}

So here are the two approximate solutions to qe:

In[16]:=

xa1[ϵ_] = Normal[xs] /. x _ 0 -> 1 /. proot[[1]]

Out[16]=

1 - ϵ/2 + ϵ^2/8

In[17]:=

xa2[ϵ_] = Normal[xs] /. x _ 0 -> -1 /. nroot[[1]]

Out[17]=

-1 - ϵ/2 - ϵ^2/8

Compare the exact (green) and approximate (red) solutions:

In[18]:=

Plot[{xa1[ϵ], xe1[ϵ]}, {ϵ, -3., 3.}, PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 1, 0]}]

[Graphics:HTMLFiles/index_44.gif]

Out[18]=

-Graphics -

In[19]:=

Plot[{xa2[ϵ], xe2[ϵ]}, {ϵ, -3., 3.}, PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 1, 0]}]

[Graphics:HTMLFiles/index_47.gif]

Out[19]=

-Graphics -


Converted by Mathematica  (March 3, 2003)