1550078481-Ordinary_Differential_Equations__Roberts_

(jair2018) #1
The Initial Value Problem y' = f(x, y); y(c) = d 95

with(DEtools):
de:=diff(y(x), x) = y(x) + x:
sol:=dsolve( {de, y(O) = 1 }, numeric, method=classica l[foreuler], stepsize=
0.2):
for i from 0 to 5 do
sol(.2 * i);
end do;
The first statement informs MAPLE to loa d the required softwa re package
DEtools. The second statement specifies the differential equation which is


to be solved- dy/dx = y + x. In order to so lve a different differential equa-

tion, the expression y(x) + x must b e replaced with an appropriate expression
which conforms to MAPLE syntax. The third statement specifies the ini-


tial condition to use-in this case, y(O) = 1. To change the init ia l condition


ch a nge the values 0 and 1 accordingly. The specification "numeric" which
appears in the third statement tells the computer to solve the initial value
problem numerically. The third statement a lso indicates the integration is to
be performed using the forward Euler's method (method=classical[foreuler])
and the stepsize is to be 0 .2. The forward Euler's method, called foreuler in
MAPLE, denotes Euler's method. Other methods we have discussed are spec-
ified in MAPLE as follows: heunform denotes the improved Euler's method,
impoly denotes the modified Euler's method, and rk4 denotes the fourth or-
der Runge-Kutta method. The last three statements in the program form
a "loop" which compu tes t he values x = .2 i at which the independent
variable and its associated numerical solution value, sol(.2
i) , are to b e
printed. In this example, t he values printed will be (0, sol(O)), (.2, sol(.2)),
... , (1.0, sol(l.O)). If the initia l condition is specified at x = a and inte-
gration takes place over the interval [a, b] where the stepsize h is chosen so.
that n = (b - a)/h is an integer , then in the fourth statement above change
5 to n and in the fifth statement above change .2 i to a + h i. This will
cause n + 1 pairs of values (x, so l(x)) to be printed at n + 1 equa lly spaced
points throughout the interval [a , b]. The spacing between the values will b e
h. When h is very small, instead of printing the solution every step, you may
want to print the solution only every ten steps, or every one hundred steps,
or every one t h ousand steps. This is accomplished by cha nging the value
5 in statement four and t he expression .2 * i in statement six appropriately.


EXERCISES 2.4.1



  1. Consider the initial value problem y' = x^2 - y; y(O) = 1.


a. Derive the Taylor series expansion formula of order 3 for this
initia l value problem.
b. Use t he formula derived in part a. and a constant stepsize h = .1
to calculate an approximate solution on t he interva l [O, l].
Free download pdf