ODE Single Step
ODE Single Step
DIFFERENTIAL EQUATIONS:
SINGLE-STEP METHODS
1 Introduction to ODE
Introduction
1 The general form of an nt h order ODE is
Recall
h i = x i − x i −1 , i = 1, 2, 3, · · · , n (4)
Single-Step Scheme
Definition
For single step method’s the solution at any point is obtained by using the solution
at the previous point.
1 With this method, the solution at any point y i +1 is obtained by using the
solution at only the previous point y i and at the point itself.
A general single step implicit method can be written as
y i +1 = y i + h f (x i +1 , x i , y i +1 , y i , h) (5)
2 The function f is called the increment function.
2 Given an initial value y 0 , then the other values of y are computed successively
as
y 1 = y 0 + h f (x 0 , y 0 , h), when i = 0 (7)
y 2 = y 1 + h f (x 1 , y 1 , h), when i = 1 (8)
y 3 = y 2 + h f (x 2 , y 2 , h), when i = 2 (9)
.. .. ..
. . .
y n = y n−1 + h f (x n−1 , y n−1 , h), when i = n − 1 (10)
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 9 / 49
Single-Step Methods and Multi-Step Schemes
Single-Step Scheme
Note
All single-step methods are self starting, that is, they do not require values of y or
it’s derivatives beyond the immediate previous point.
Multi-Step Methods
With this method, the solution at point y i +1 is obtained using the solution at a
number of previous points, y i , y i −1 , y i −2 , y i −3 , · · · .
1 Two-step implicit depends on y i +1 , y i , y i −1
2 Two-step explicit depends on y i , y i −1
3 Four-step implicit depends on y i +1 , y i , y i −1 , y i −2 , y i −3
4 Four-step explicit depends on y i , y i −1 , y i −2 , y i −3
Multi-Step Schemes
1 A classical example of a two-step implicit method can be written as
y i +1 = y i + h f (x i +1 , x i , x i −1 , y i +1 , y i , y i −1 , h) (11)
2 A classical example of a three-step explicit method can be written as
y i +1 = y i + h f ( x i , x i −1 , x i −2 , y i , y i −1 , y i −2 , h) (12)
3 A general k -step explicit method can be written as
y i +1 = y i + h f (x i −k+1 , · · · , x i −1 , x i , y i −k+1 , · · · , y i −1 , y i , h) (13)
4 A general k -step implicit method can be written as
y i +1 = y i + h f (x i −k+1 , · · · , x i −1 , x i , x i +1 , y i −k+1 , · · · , y i −1 , y i , y i +1 , h) (14)
Note
The following are equivalent
Note
The following are equivalent
All these methods are derived using Taylor series. Given the Taylor
series:
y(x i +1 ) = y(x i ) + h f [(x i + θh), y(x i + θh)]; 0≤θ≤1 (15)
These schemes can be deduced from the above depending on the value of θ .
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 15 / 49
Solution To IVP’s Using Single-Step Methods 1. Taylor Series of Order 1 or Euler Method
θ=0
2. Backward Euler
1 Given the general Taylor series:
θ=1
.
3 The scheme is given by the formula
2 Substituting eq. (23) into eq. (22), we obtain the Modified Euler as
h h
·µ ¶ ¸
y(x i +1 ) = y(x i ) + h f xi + , y(x i ) + f (x i , y i ) (24)
2 2
4. Trapezium Method
2 Substituting eq. (27) into eq. (25) we obtain the Euler-Cauchy iterative scheme
as:
h© ª
y(x i +1 ) = y(x i ) + f [x i , y(x i )] + f [x i +1 , y(x i +1 )] (28)
2
h© ª
= y(x i ) + f [x i , y(x i )] + f [x i +1 , y(x i ) + h f [x i , y(x i )]] (29)
2
Example
Solve the following IVP
using
1 Euler method
2 Modified Euler method
3 Euler-Cauchy method
In each case compute the absolute error at x = 0.6
Euler Method
Given the step size h = 0.2. Then the x values are given by the interval table
From eq. (2), y ′ = f (x, y). Therefore making y ′ the subject from the question we
have
x
y ′ = f (x, y) = (33)
y
Iteratively, xi
f (x i , y i ) = (34)
yi
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 23 / 49
Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method
Modified Euler
The formula is given as
h h
¶
·µ ¸
y(x i +1 ) = y(x i ) + h f x i + , y i + f (x i , y i ) (46)
2 2
h h
· ¸
y i +1 = y i + h f x i + , y i + f (x i , y i ) (47)
2 2
Again xi
f (x i , y i ) = (48)
yi
The initial conditions can be deduced as
x 0 = 0, and y 0 = 1
Hence
AE = |E S − AS| = |1.167 − 1.1148| = 0.0522
6. Runge-Kutta Methods
k 1 and k 2 (64)
3 whereas the fourth-order Runge-Kutta uses four slopes;
k 1 , k 2 , k 3 , and k 4 (65)
Second-Order Runge-Kutta
where
k 1 = h f (x i , y i ) and
k 2 = h f (x i + θh, y i + θk 1 )
2 The value of θ is arbitrary such that 0 ≤ θ ≤ 1.
3 This lead to a myriad number of solution schemes
Second-Order Runge-Kutta
1 When θ = 1
1 1
y i +1 = y i + k 1 + k 2 (67)
2 2
where k1 = h f (x i , y i ) and
k 2 = h f (x i + h, y i + k 1 )
This is the same as the Heun’s method.
2 When θ = 1/2
y i +1 = y i + k 2 (68)
where k1 = h f (x i , y i ) and
k 2 = h f (x i + h/2, y i + k 1 /2)
This is the same as the Modified Euler
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 35 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods
Fourth-Order Runge-Kutta
In the case of RK4, the iterative scheme is given by
1
y i +1 = y i + (k 1 + 2k 2 + 2k 3 + k 4 ) (69)
6
where
1 k 1 = h f (x i , y i ),
h k1
µ ¶
2 k2 = h f xi + , y i +
2 2
h k2
µ ¶
3 k3 = h f xi + , y i +
2 2
¡ ¢
4 k 4 = h f x i + h, y i + k 3
Example
Solve the following IVP
Solution
Given the step size h = 0.2. Then the x values are given by the interval table
We know that
x
y ′ = f (x, y) = (71)
y
Iteratively, xi
f (x i , y i ) = (72)
yi
The initial conditions can be deduced as
x 0 = 0, and y 0 = 1
Now let substitute eqs. (74) to (77) into the main formula eq. (73). Hence
1
y 1 = y 0 + (k 1 + 2k 2 + 2k 3 + k 4 ) (78)
6
1
= 1 + [0 + 2(0.02) + 2(0.02) + 0.04] (79)
6
= 1.02 (80)
Now let substitute eqs. (82) to (85) into the main formula eq. (81). Hence
1
y 2 = y 1 + (k 1 + 2k 2 + 2k 3 + k 4 ) (86)
6
1
= 1.02 + [0.04 + 2(0.06) + 2(0.06) + 0.079] (87)
6
= 1.079 (88)
h k1
µ ¶ µ ¶
0.2 0.074
k2 = h f x2 + , y 2 + = 0.2 f 0.4 + , 1.079 +
2 2 2 2
= 0.2 f (0.5, 1.116) (91)
µ ¶
0.5
= 0.2 = 0.09
1.116
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 45 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods
Exercise
using
1 Euler method, hence determine the relative error at x = 0.1
2 Modified Euler method, hence determine the relative error at x = 0.2
3 Euler-Cauchy method, hence determine the relative error at x = 0.3
4 Fourth-Order Runge-Kutta, hence determine the relative error at x = 0.4