Lecture 21 - Ordinary Differential Equations - IVP
Lecture 21 - Ordinary Differential Equations - IVP
Equations - IVP
CVEN 302
July 26, 2002
Lecture’s Goals
ODE Methods
• Modified Euler
• 2nd order Runge-Kutta Method
• 4th order Runge-Kutta Method
• Multi-step Method
– Adam Bashforth
– Adam Moulton Method
– Predictor-Corrector Method
• Stability
Modified Euler Method
The Modified Euler method uses the slope at the
new location and is a predictor-corrector technique.
yn yn 1
yn 1 yn h
2
O h
2
2
Runge-Kutta Methods
Runge-Kutta methods are very popular because of their
good efficiency; and are used in most computer
programs for differential equations. They are single-
step methods, as the Euler methods.
Runge-Kutta Methods
To convey some idea of how the Runge-Kutta is
developed, let’s look at the derivation of the 2nd order.
Two estimates
yn 1 yn ak1 bk 2
k1 hf xn , yn
k 2 hf xn h, yn k1
Runge-Kutta Methods
The initial conditions are:
dy
f x, y y x0 y0
dx
The Taylor series expansion
dy xn , yn h d y xn , yn
2 2
y xn 1 y xn h 2
dx 2! dx
Runge-Kutta Methods
Expand the derivatives:
2
d y d dy
2
f x, y f x f y fx fy f
dx dx dx
The Taylor series expansion becomes
yn 1 yn hf h f x f y f
12
2
Runge-Kutta Methods
From the Runge-Kutta
yn 1 yn ahf bhf xn h, yn hf
The definition of the function
f xn h, yn hf f hf x hf f y
Expand the next step
yn 1 yn ahf bh f hf x hf f y
yn a b hf bh 2 f bh 2 f f y
Runge-Kutta Methods
From the Runge-Kutta
yn 1 yn a b hf bh f bh f f y
2 2
1 1
Use the coefficients a b , 1
2 2
Runge-Kutta Method
(2 Order) Example
nd
k1 hf xi , yi
k 2 hf xi h, yi k1
1
yi 1 yi k1 k 2
2
Runge-Kutta Method
(2 Order) Example
nd
2 1 3 3
The values are a , b , ,
3 3 2 2
k1 hf xi , yi
k 2 hf xi h, yi k1
yi 1 yi ak1 bk 2
Runge-Kutta Method
(2 Order) Example [b]
nd
Euler y k1
(Error of the order h2)
k 1 h f x , y
Modified Euler 1
(Error of the order h3) y k1 k 2
2
k 1 h f x , y
k 2 h f x h , y k 1
Heun 1
(Error of the order h4) y k 1 3k 3
4
k 1 h f x , y
1 1
k 2 h f x h, y k1
3 3
2 2
k 3 h f x h, y k 2
3 3
4 th order Runge Kutta 1
(Error of the order h5) y k1 2 k 2 2k 3 k 4
6
k 1 h f x , y
1 1
k 2 h f x h, y k1
2 2
1 1
k 3 h f x h, y k 2
2 2
k 4 h f x h , y k 3
The 4th Order Runge-Kutta
This is a fourth order function that solves an initial
value problems using a four step program to get an
estimate of the Taylor series through the fourth
order.
1
The general form y k1 2k 2 2k3 k 4
of the equations: 6
k1 h f x, y
1 1
k 2 h f x h, y k1
2 2
1 1
k3 h f x h, y k 2
2 2
k 4 h f x h, y k3
4 -order
th
Runge-Kutta Method
f2
f4
f3
f1 f
1
f f1 2 f 2 2 f 3 f 4
6
xi xi + h/2 xi + h
Runge-Kutta Method
(4 Order) Example
th
dx
The initial condition is: y 0 1
The step size is: h 0.1
The 4 Order Runge-Kutta
th
Runge-Kutta Method -2
0 1 2 3 4
Y Value
-4
(4 Order) Example
th -6
-8
Exact
4th order
solution. If we were to 0
0 1 2 3 4
go out to x=5. -2
Y Value -4
y(5) = -111.4129 (-111.4132)
-6 Exact
4 10.00
Absolute |Error|
0
0 1 2 3 4 6.00
-2
Y Value
-4 4.00
-6 Exact 2.00
2nd order
-8 0.00
4th order
-10 0 1 2 3 4 5
X Value X Value
The 4th Order Runge-Kutta
Higher order differential equations can be treated
as if they were a set of first-order equations.
Runge-Kutta type forward integration solutions can
be obtain. A more direct solution can be obtained
by repeating the whole process used in first-order
cases.
The 4 Order Runge-Kutta
th
dy xi1
f x
dx yi 1 yi f x dx
dy f x dx xi
xi1
dy y i 1 yi f x dx
xi
Multi-Step Methods
The integral can be represented.
xi1
h
f x dx 3 f i f i1 Two Point
xi 2
Three Point Adam Bashforth
h
23 f i 16 f i1 5 f i2
12
Multi-Step Methods
The integral can be represented.
xi1
f x dx
xi
Four Point Adam Bashforth
h
55 f i 59 f i1 37 f i2 9 f i3
24
Multi-Step Methods
These methods are known as explicit schemes because
the use of current and past values are used to obtain the
future step.
dx
The initial condition is: y 0 1
The step size is: h 0.1
4 Point Adam Bashforth
From the 4th order Runge Kutta
f 0,1 1.0000
f 0.1,1.104829 1.094829
f 0.2,1.218597 1.178597
f 0.3,1.340141 1.250141
The 4 Point Adam Bashforth is:
0.1
y 55 f 0.3 59 f 0.2 37 f 0.1 9 f 0
24
4 Point Adam Bashforth
The results are:
Y Value
go through large number -4
Adam Bashforth
-6
of calculations. -8
4th order Runge-Kutta
Exact
-10
X Value
Multi-Step Methods
There are second set of multi-step methods, which are
known as implicit methods. The implicit methods use
the future steps to modify the future steps.
h
y 5 f i1 8 f i f i1
12
Four Point Adam-Moulton Method
h
y 9 f i1 19 f i 5 f i1 f i2
24
Implicit Multi-Step Methods
The method uses what is known as a Predictor-Corrector
technique. It uses the explicit scheme to estimate the
initial guess and uses the value to guess the future y* and
dy/dx= f*(x,y*) values. Using these results, the Adam
Moulton method can be applied.
Implicit Multi-Step Methods
Adams third order Predictor-Corrector scheme.
dx
The initial condition is: y 0 1
The step size is: h 0.1
4 Point Adam Bashforth
From the 4th order Runge Kutta
f 0,1 1.0000
f 0.1,1.104829 1.094829
f 0.2,1.218597 1.178597
0.1
y 23 f 0.2 16 f 0.1 5 f 0.0
12
3 Point Adam Moulton
Predictor-Corrector Method
The results of explicit scheme is:
0.1
y 231.178597 161.094829 51
12
0.121587
The functional values are:
y * 0.3 1.218597 0.121587 1.340184
f * 0.3,1.340184 1.250184
3 Point Adam Moulton
Predictor-Corrector Method
The results of implicit scheme is:
0.1
y 51.250184 81.178597 11.094829
12
0.121541
The functional values are:
y 0.3 1.218597 0.121541 1.340138
f 0.3,1.340184 1.250138
3 Point Adam Moulton
Predictor-Corrector Method
The values for the Adam Moulton
Adam Moulton Three Point Predictor-Corrector Scheme
x y f sum y* f* sum
0 1 1
0.1 1.104829 1.094829
0.2 1.218597 1.178597 0.121587 1.340184 1.250184 0.121541
0.3 1.340138 1.250138 0.128081 1.468219 1.308219 0.12803
0.4 1.468168 1.308168 0.133155 1.601323 1.351323 0.133098
0.5 1.601266 1.351266 0.136659 1.737925 1.377925 0.136597
0.6 1.737863 1.377863 0.138429 1.876291 1.386291 0.138359
0.7 1.876222 1.386222 0.13828 2.014502 1.374502 0.138204
0.8 2.014425 1.374425 0.136013 2.150438 1.340438 0.135928
0.9 2.150353 1.340353 0.131404 2.281757 1.281757 0.13131
1 2.281663 1.281663 0.124206 2.405869 1.195869 0.124102
3 Point Adam Moulton
Predictor-Corrector Method
Adam Moulton 3 Point Implicit Scheme
The implicit Adam
Moulton method gave 4
Y Value
more than a three points. -4
4th order Runge-Kutta
Exact
-6
Adam Moulton
-8 Adam Bashforth
-10
X Value
Summary
• Modified Euler
• 2nd Order Runge-Kutta
• 4th Order Runge-Kutta Method
• Higher Order Runge-Kutta Methods
• Explicit Multi-Step Methods
• Implicit Multi-Step Methods
• Stability
Homework
• Check the Homework webpage.