Professional Documents
Culture Documents
Definition. An nth order Ordinary Differential Equation (ODE) may be written in the form
dy d 2 y
dn y
F x , y , , 2 , , n =1(1)
dx d x
dx
Equation (1) is termed nth order because the highest ordered derivative appearing in the equation is of order n,
and ordinary because only total derivatives are present (no partial derivatives, therefore there is only one
independent variable).
A function y (x) that satisfies Equation (1) is said to be a solution of the equation. By a solution for a given
x, y ,
dy d 2 y
dn y
, 2 ,, n
dx d x
dx
x . For an nth order ODE, n even conditions are normally sufficient to yiels a unique
solution.
Example. Consider the 1st order ODE
dy
= y (2)
dx
The analytical solution of this is
dy
y = dx ln y=x + ln c y=ce x(3)
This is a family of solution for different values of c . If the condition
unique value of c (c=1) giving the unique solution
10
8
6
4
2
y=2e^x
y=e^x
y=(1/2)e*x
0
-1 -0.5 0 0.5 1 1.5 2 2.5 3
-2
Any nth order ODE may be written as a system of n 1st order ODEs by defining as a system of n1 new
variables. For example, the second order ODE Bessel Function
2
dy
2d y
2
2
x
+ x + ( x p ) y =0
2
dx
dx
Letting z=dy /dx , we can rewrite the equation as a pair of 1st order ODEs
dy
2 dz
2
2
z=0x
+ xz + ( x p ) y=0
dx
dx
Since any higher order ODE (or system of such ODEs) can be rewritten in a similar fashion, only the numerical
solution of the 1st order ODE will be considered.
General form.
y ( x ) which satisfies both the equation and one specified initial condition. Numerically the solution
y (x )
y0
x1
y1
x2
y2
x3
y3
x4
y4
.
.
.
.
.
.
xn
yn
y ( x0 ) = y 0
in the interval
x0
to
xn
Notation: [ a , b ] = interval in the indeval in the independent variable ober which n solution is desired.
n= number of subintervals in [ a , b ]
h= step size (ba)/n
x at which
y ( x ) is computed
y ( xi ) =
true value of
xi
y ( x) at
y i= computed approximation of
y ( x) at
(usually unknown)
at
xi
xi
(usually unknown)
i= y i y ( x i )=
at
xi
values of
xj
yj
and/or
fj
[ x i , x i+1 ]
methods are: a) it is difficult to get started, and b) it is difficult to change step size once the calculation is
underway. However, the multistep methods are require less computation, compared with one-step method to
produce results of comparable accuracy.
NUMERICAL SOLUTION OF FIRST ORDER ODEs BY DIRECT USE OF THE TAYLOR SERIES
EXPANSION OF THE SOLUTION FUNCTION y (x) (TSE)
Given :
dy
=f ( x , y ) withinitial solution y ( x 0 )= y 0 , one step method of approximating the
dx
Given ODE :
h2 '
h3
hn
hn +1 ( n)
f ( x i , y ( xi ) ) + f ' ' ( x i , y ( x i) ) ++ f ( n1 ) ( xi , y ( x i ) ) +
f ( x i , y ( x i ) ) where x i x i +1
2!
3!
n!
( n+ 1 ) !
dy
=f ( x , y )=f
dx
df f f y f f
'
= +
= +
f =f
dx x y x x y
d2 f f ' d f f
= =
+
f
d x 2 x dx x y
f f
f f
+
f +
+
f f
x x y
y x y
) (
y (x )
dy
2
=f ( x , y )=x with y ( x 0) = y 0
dx
f ( x , y ) =x2 f ' ( x , y )=2 x f ' ' ( x , y )=2 f ' ' ' ( x , y ) =0
y ( xi +1 )= y ( x i ) +hf ( x i , y ( x i ) ) +
y ( x i ) + h x 2i +
h2 '
h3
f ( x i , y ( x i ) )+ f ' ' ( xi , y ( x i ) )
2!
3!
h2
h3
( 2 x i ) + ( 2 ) +0
2!
3!
y ( x i ) + h x 2i +h2 xi +
h3
(a)
3
y ( xi )
values at
x i , i=1,2,3, .
, by
repeated use of Equation (a). Note that since the 3rd and higher ordered derivatives are zero, the values given
Equation (a) are exact, assuming no round-off errors.
h3
y ( x1 ) = y ( x0 ) + h x 20 +h 2 x 0+
3
y ( x2 ) = y ( x1 ) + h x 21 +h2 x1 +
h3
3
y ( x3 ) = y ( x2 ) + h x 22 +h2 x 2+
h3
3
2.
dy
=f ( x , y )=2 y with y ( x 0 )= y 0
dx
f ( x , y ) =2 y f ' ( x , y )=
f ' ' ( x , y )=
f ' ' ' ( x , y )=
'
f f
+
f =0+2 ( 2 y )=4 y =f '
x y
'
f f
+
f =0+4 ( 2 y ) =8 y=f ' '
x y
f'' f ''
+
f =0+8 ( 2 y )=16 y=f ' ' '
x y
y ( xi +1 )= y ( x i ) +hf ( x i , y ( x i ) ) +
h2 '
h3
h4
f ( x i , y ( x i ) ) + f ' ' ( x i , y ( x i ) ) + f '' ' ( x i , y ( xi ) )
2!
3!
4!
4
Truncating thw series after the fifth term (or retaining the term through h , and substituting the
xi
to
yi
(2 h )2 ( 2 h )3 ( 2 h ) 4
=1+2
h+
+
+
, and if we designate
2!
3!
4!
the calculated values given in the previous equation are approximations to the true value of
y ( xi +1 ) ,i=1,2,3 .
, brought about by truncating the series. Applying the above equation,
y 1= y 0
y 2= y 1
y 3= y 2
and
f ( x i , y i ) , i=0,1,2, .
|d i|C h p+1
where
di
is the local
steps is
di
Given ODE : L + Ri=E , at i (t=0 )=0
dt
Required:
L=?
i=
E
( 1eRt / L) . We will compare
R
results of the numerical method from Euler method for the different step sizes wit(h this
analytical solution. The given ODE is rewrittem in the form suitable for the Euler
method:
di ERi
=
=f ( t ,i )
dt
L
Then the Euler formulais i j+1=i j+ hf ( t j , i j ) =i j +h
For h=1 sec ,i 1=i 0 +1
ERi j
102 i j
=i j + h
L
5
102 i 0
102 0
=0+
=2.0 ; i2 =3.2 sec
5
5
Summary of Results
Analyti
Time
cal
in
h=1
solutio
Sec
n
0
0
0
Error
h=0.1
Error
h=0.0
1
Error
h=0.0
01
Error
1.6484
0
2.000
0
0.351
60
1.675
83
0.027
43
1.651
06
0.002
66
1.648
46
2.7533
6
3.200
0
0.446
64
2.789
98
0.036
62
2.766
10
0.012
74
2.753
18
3.4940
3
3.920
0
0.425
97
3.530
70
0.036
67
3.497
57
0.003
54
3.493
64
3.9905
2
4.352
0
0.361
48
4.023
16
0.032
64
3.993
65
0.003
13
3.990
02
0.0000
6
0.0001
8
0.0003
9
0.0005
0
RUNGE-KUTTA METHODS
A. Important properties of the Runge-Kutta Methods
1. They are one-step methods
2. They require the evaluation of f (x , y ) , and none of its derivatives
3. They result with accuracies equivalent to TSE of
through
f ( x)
retaining terms
( xi , y i , h )
evaluations
x i x xi +1
on the interval
, that is,
( xi , y i , h ) =a k 1+ b k 2 (2)
Substituting (2) in the general form then yields
y i+1= yi +h ( a k 1 +b k 2 ) (3)
Now let
k 1=f ( x i , y i ) ( 4)
k 2=f ( x i+ ph , y i +q k 1) (5)
1
1
a= , b= , p=1, q=1
2
2
( 12 k + 12 k )= y + h2 (k +k )
1
k 1=f ( x i , y i )
k 2=f ( x i+ h , yi + k 1 )
a=0, b=1, p=q=
1
y i+1= yi +h ( a k 1 +b k 2 ) = y i+ h 0+ k 2 = y i+ h k 2
2
k 1=f ( x i , y i )
k
h
k 2=f x i + , y i + 1
2
2
k 3 =f ( x i+ h , y ik 1 +2 k 2 )
E. 4th Order R-K Method
1
2
General Formula:
h
y i+1= yi + ( k 1 +2 k 2 +2 k 3 +k 4 )
6
k 1=f ( x i , y i )
k
h
k 2=f x i + , y i + 1
2
2
(
)
k
h
k =f ( x + , y + )
2
2
2
k 4=f ( xi +h , y i +k 3 )
SIMULTANEOUS SOLUTION TO SYSTEM OF 1ST ORDER ODEs
Problem: Find the solution of the system of ODE in the form
( x , y , z )dz
dy
=f
=f ( x , y , z )
dx
dx
k 3 =f ( x i+ h , y ik 1 +2 k 2 , z ir 1+ 2r 2 )
h
z i+1=z i + ( r 1 + 4 r 2 +r 3 )
6
r 1=f ( xi , y i , z i )
k
r
h
r 2=f x i + , y i+ 1 , zi + 1
2
2
2
r 3=f ( x i+ h , y ik 1 +2 k 2 , z ir 1 +2 r 2 )
d4 y
d3 y
d2 y
dy
4
+
4
xy
+
4
x
+2 y + 4 y =0
4
3
2
dx
dx
dx
dx
Method: Reduction of order
Let
2
3
dy
dp d y
dw d y
p= ; w= = 2 ; z= = 3
dx
dx d x
dx d x
Substitution:
DE 1 :
dz
=4 xyz4 xw2 xp4 y 4
dx
DE 2 :
dy
=p
dx
DE 3 :
dp
=w
dx
DE 2 :
dw
=z
dx