Beruflich Dokumente
Kultur Dokumente
Introduction
Consider the following linear differential equation
a2 HxL
2 y
x2
+ a1 HxL
y
x
+ a0 HxL y = 0
(1)
+ p HxL
y
x
(2)
+ q HxL y = 0
From the existence and uniqueness theorems for ODEs, there is a unique solution to (2) about an
interval near x0 that satisfies the initial conditions y Hx0 L = C1 , y' Hx0 L = C2 . Further, since the
functions p(x) and q(x) are analytic at x0 , they can be expanded in a Maclaurin power series about x0 :
p HxL = An Hx - x0 Ln , q HxL = Bn Hx - x0 Ln
n= 0
(3)
n= 0
y HxL = f HxL = an Hx - x0 Ln
(4)
n=0
The coefficients an in (4) can be determined by substituting the series into the ODE and equating coefficients multiplying equal powers of Hx - x0 L. This procedure is shown in the next section.
Mathematica Solution
Example 1 : Linear equation with variable coefficients
Consider the following linear differential equation with variable coefficients:
2 y
t
+ 2 t3
y
t
+2 y = 0
(5)
ODESeriesSoln.nb
Note a closed form analytical solution to this problem cannot be found by Mathematica's differential
equation solver DSolve. Instead, we will attempt to find a power series solution to this problem about an
ordinary point t0 . By inspection we can deduce that there are no singular points for t 0, It will be
convenient to have a numerical solution that we can used to assess the accuracy our power series
solution.
The numerical solution to this equation is shown below for 0t3
eqnBC = 9y @tD + t3 y @tD + 2 y@tD 0, y@0D 1, y @0D - 2=;
sol = NDSolve@eqnBC, y@tD, 8t, 0, 10<D;
myPlot1 = Plot@y@tD .sol, 8t, 0, 3<, PlotRange All,
AxesLabel 8"t", "yHtL"<, PlotStyle Blue, Frame True,
FrameLabel 8Style@"x", 10, "Label"D, Style@"yHxL", 10, "Label"D<D
1.0
0.5
yHxL
0.0
-0.5
-1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
To show each step we will work with only a few terms in the series
Since we show each step of the analysis, it is convenient to work with only a few terms in the series.
The first step is to generate a power series expansion of the unknown function y(t), which we call
myPowerSeries, up to order 3, i.e., with a truncation error of O HtL4 .
myPowerSeries = Series@y@tD, 8t, 0, 3<D
y@0D + y @0D t +
1
2
y @0D t2 +
1
6
Next we define our ODE and initial conditions (it will be convenient to define the initial conditions as
replacement rules)
myODE = y ''@tD + t3 y '@tD + 2 y@tD 0;
myIC = 8y@0D -> 1, y '@0D - 2<;
The next step is to substitute the power series expansion into the ODE. Recall myPowerSeries is a
special Mathematica object called a SeriesData object: it behaves like a pure function when it comes
to substituting into an ODE
myODESeries = myODE . y@tD -> myPowerSeries
H2 y@0D + y @0DL + I2 y @0D + yH3L @0DM t +
y @0D +
1
2
1
3
yH3L @0D +
1
6
We can use LogicalExpand to equate coefficients at each order of tn to zero which determines the
system of algebraic equations we need to solve for our unknown coefficients yHnL @0D . However the
initial conditions determine two of those coefficients: y[0] and y'[0]. Here is the result
ODESeriesSoln.nb
1
2
1
3
yH3L @0D +
1
6
yH5L @0D 0
Finally, we can substitute the values for our coefficients into our original power series expansion of y[t].
(We need also to substitute the values for y[0] and yH1L @0D which are determined from the initial
conditions)
mySeriesSol = myPowerSeries . seriesCoef . myIC
1 - 2 t - t2 +
2 t3
3
+ O@tD4
Please note that all these calculations were done in exact arithmetic. Thus there are no round-off errors
as we include higher orders of the expansion. Finally let us plot the results. Please note that our solution
is in the form of a SeriesData object. Hence, before we can plot is we must convert it to a normal
Mathematica expression by wrapping it with Normal and then with Evaluate to force evaluation within
the plot routine.
myPlot2 = Plot@Evaluate@Normal@mySeriesSolDD,
8t, 0, 2.3`<, PlotRange All, PlotStyle Red, Frame True,
FrameLabel 8Style@"x", 10, "Label"D, Style@"yHxL", 10, "Label"D<D
1.0
0.5
yHxL
0.0
-0.5
-1.0
-1.5
-2.0
0.0
0.5
1.0
1.5
2.0
ODESeriesSoln.nb
Show@myPlot1, myPlot2D
1.0
0.5
t
0.0
yHxL
-0.5
-1.0
-1.5
-2.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
The above plots show that our series solution is accurate for t < 0.5. Clearly we can extend the range
of applicability by including more terms in the series. At this point it makes more sense to write a small
module that does the steps of the solution. We explore this option in the next example.
If we inspect the code for this module we see that many of the steps are identical to what we used
previously , with some slight changes for variable names. The first two statements are used to extract
the ODE from the initial conditions in the variable sys which the user supplies. The key is to first extract
out the initial conditions from the list sys using the select function with a rule that checks to see which
elements are initial conditions. Here is an explanation of the method: suppose our system of equations
was
sysTest = 8y@0D 1, y '@tD y@tD + 2<;
ODESeriesSoln.nb
Then if we take the derivative for each element of the list, the IC yields true
8D@y@0D 1, tD, D@y '@tD 1, tD<
8True, y @tD 0<
Thus if we use D@, tD & as our test function in Select we can extract out the ICs
ICTest = Select@sysTest, D@, tD &D
8y@0D 1<
Once we have the initial conditions we can use complement to get the ODE equations
Complement@sysTest, ICTestD
8y @tD 2 + y@tD<
The rest of the code is virtually identical to what we did previously. Once we have the ICs we convert
them to Rules and by asking the user to specify the independent and dependent variables we are able
to code the steps for a single set of independent and dependent variables.
Let us try out this module on the following system of equations
sys = 9x ''@xD + x3 x '@xD + 2 x@xD 0, x@0D == 1, x '@0D == - 2=
92 x@xD + x3 x @xD + x @xD 0, x@0D 1, x @0D - 2=
2 x3
3
x4
6
x5
30
+ O@xD6
We can use the module to plot and compare the solution with the original numerical solution. Here is a
plot of the solution with 100 terms in the expansion
plt2 =
Plot@Evaluate@Normal@ODESeriesSoln@sys, x, x, 100DDD, 8x, 0, 4<, PlotStyle Red,
Frame True, FrameLabel 8Style@"x", 10, "Label"D, Style@"yHxL", 10, "Label"D<D;
Show@plt2, myPlot1, PlotRange 880, 3<, 8- 3, 1<<D
1
yHxL
-1
-2
-3
0.0
0.5
1.0
1.5
2.0
2.5
3.0
ODESeriesSoln.nb
Note that this is a 3rd order nonlinear ODE. We have 2 "initial conditions" at h=0. The third condition is
specifies as h : F'@D 0. For our series solution we will use the initial conditions at h=0, taken to
be an ordinary point. Thus we will need to solve for the coefficients in terms of F''(0) . In fact we will
show that the solution is given in the form
(7)
n=0
where
C0 =
1
2
(8)
This solution was found by Weyl (1942). Here is the solution found using our module:
ODESeriesSoln@sys2, h, F, 11D
Solve::svars : Equations may not give solutions for all "solve" variables.
1
2
F @0D h2 -
1
120
F @0D2 h5 +
11 F @0D3 h8
40 320
5 F @0D4 h11
532 224
+ O@hD12
References
These notes build on Mathematica programming methods that are discussed in the notebook;
ODESingularPoints.nb. I also found the following references most helpful.