0% found this document useful (0 votes)
18 views46 pages

ODE Single Step

This document discusses numerical solutions of ordinary differential equations using single-step methods. It introduces single-step and multi-step schemes for solving initial value problems. Single-step methods compute the solution at the next point using only the previous point, while multi-step methods use multiple previous points. Several single-step methods are described including the Euler method, Backward Euler method, and Modified Euler method. These methods are derived from Taylor series expansions by choosing different values of the parameter θ.

Uploaded by

Michael Boadu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views46 pages

ODE Single Step

This document discusses numerical solutions of ordinary differential equations using single-step methods. It introduces single-step and multi-step schemes for solving initial value problems. Single-step methods compute the solution at the next point using only the previous point, while multi-step methods use multiple previous points. Several single-step methods are described including the Euler method, Backward Euler method, and Modified Euler method. These methods are derived from Taylor series expansions by choosing different values of the parameter θ.

Uploaded by

Michael Boadu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

NUMERICAL SOLUTIONS OF ORDINARY

DIFFERENTIAL EQUATIONS:
SINGLE-STEP METHODS

Dr. Gabriel Obed Fosu


Department of Mathematics
Kwame Nkrumah University of Science and Technology
Google Scholar: https://scholar.google.com/citations?user=ZJfCMyQAAAAJ&hl=en&oi=ao
ResearchGate ID: https://www.researchgate.net/profile/Gabriel_Fosu2

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 1 / 49


Lecture Outline

1 Introduction to ODE

2 Single-Step Methods and Multi-Step Schemes

3 Solution To IVP’s Using Single-Step Methods

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 2 / 49


Introduction to ODE

Introduction
1 The general form of an nt h order ODE is

f (x, y ′ , y ′′ , y ′′′ , · · · , y (n) ) = 0 (1)

2 The order of an ODE is the order of its highest derivative.


3 A differential equation together with some initial conditions is called an Initial
Value Problem(IVP).
4 A first order IVP can be written as:

y ′ = f (x, y); y(x 0 ) = y 0 (2)


5 The methods for solving this IVP’s can be classified into single-step methods
and multi-step methods.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 4 / 49


Introduction to ODE

Recall

1 Given an interval [x 0 , b] in which a solution is desired.


2 The interval is divided into finite number of sub-intervals by points

x0 < x1 < x2 < · · · < xn ; xn = b (3)


3 These points are called mesh points or grid points.
4 The spacing between the points are given by

h i = x i − x i −1 , i = 1, 2, 3, · · · , n (4)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 5 / 49


Single-Step Methods and Multi-Step Schemes

Single-Step Scheme

Definition
For single step method’s the solution at any point is obtained by using the solution
at the previous point.

Single-step methods can be classified as


Implicit single-step schemes
Explicit single-step schemes

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 7 / 49


Single-Step Methods and Multi-Step Schemes

Implicit Single-Step Schemes

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.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 8 / 49


Single-Step Methods and Multi-Step Schemes

Explicit Single-Step Scheme


1 In the explicit case, the right-hand side does not depend on y i +1 . For the
explicit scheme eq. (5) reduces to:
y i +1 = y i + h f (x i , y i , h) (6)

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

1 The solution of y 1 requires only one previous point y 0 .


2 The solution of y 2 requires only one previous point y 1 .
3 The solution of y 3 requires only one previous point y 2 .
4 The solution of y n requires only one previous point y n−1 .

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.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 10 / 49


Single-Step Methods and Multi-Step Schemes

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 11 / 49


Single-Step Methods and Multi-Step Schemes

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)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 12 / 49


Single-Step Methods and Multi-Step Schemes

Note
The following are equivalent

y i +1 = y(x i +1 ), y i = y(x i ), ···

Note
The following are equivalent

f i = f [x i , y(x i )], f i +1 = f [x i +1 , y(x i +1 )], ···

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 13 / 49


Solution To IVP’s Using Single-Step Methods

Solution To IVP’s Using Single-Step Methods


Some numerical techniques used for solving IVP’s include:
1 Euler or Taylor series Method
2 Backward Euler
3 Modified Euler or Midpoint Method
4 Trapezium Method
5 Heun’s Method or Euler-Cauchy Method
6 Runge-Kutta (RK) Methods

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

Taylor Series of Order 1 or Euler Method


1 Given the general Taylor series:

y(x i +1 ) = y(x i ) + h f [(x i + θh), y(x i + θh)]; 0≤θ≤1 (16)

2 The Euler Method is obtained from eq. (16) be letting

θ=0

3 The scheme is given by the formula

y(x i +1 ) = y(x i ) + h f [x i , y(x i )] (17)

4 This is an explicit scheme.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 16 / 49


Solution To IVP’s Using Single-Step Methods Backward Euler

2. Backward Euler
1 Given the general Taylor series:

y(x i +1 ) = y(x i ) + h f [(x i + θh), y(x i + θh)]; 0≤θ≤1 (18)


2 The Backward Euler is obtained from eq. (18) be letting

θ=1

.
3 The scheme is given by the formula

y(x i +1 ) = y(x i ) + h f [(x i + h), y(x i + h)] (19)


= y(x i ) + h f [x i +1 , y(x i +1 )] (20)
4 This is an implicit scheme.
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 17 / 49
Solution To IVP’s Using Single-Step Methods Modified Euler or Midpoint Method

3. Modified Euler or Midpoint Method


1 Given the general Taylor series:
y(x i +1 ) = y(x i ) + h f [(x i + θh), y(x i + θh)]; 0≤θ≤1 (21)
2 The Modified Euler method is obtained from eq. (21) be letting
1
θ=
2
3 The scheme is given by the formula
h h
·µ ¶ µ ¶¸
y(x i +1 ) = y(x i ) + h f xi + , y xi + (22)
2 2
³ ´
4 However, x i + h2 is not a nodal point, hence we approximate y x i + h
2 using the
h
Euler method with spacing 2
.
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 18 / 49
Solution To IVP’s Using Single-Step Methods Modified Euler or Midpoint Method

Modified Euler or Midpoint Method

1 The Euler approximation is given by eq. (23).


h h
µ ¶
y xi + = y(x i ) + f (x i , y i ) (23)
2 2

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

3 This is an explicit scheme

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 19 / 49


Solution To IVP’s Using Single-Step Methods Trapezium Method

4. Trapezium Method

1 If the continuously varied slope in x i and x i +1 is approximated by the mean of


the slope, then the trapezium method is deduced as
h© ª
y(x i +1 ) = y(x i ) + f [x i , y(x i )] + f [x i +1 , y(x i +1 )] (25)
2
h
= yi + [ f i + f i +1 ] (26)
2
2 This is an implicit scheme.
3 When this is converted to an explicit scheme we obtain the Heun’s method.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 20 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

5. Heun’s Method or Euler-Cauchy Method


1 This is the explicit form of the trapezium method. This conversion is made
possible by using the approximation

y(x i +1 ) = y(x i ) + h f [x i , y(x i )] (27)

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 21 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Example
Solve the following IVP

y y ′ = x, y(0) = 1, 0 ≤ x ≤ 0.6, h = 0.2

using
1 Euler method
2 Modified Euler method
3 Euler-Cauchy method
In each case compute the absolute error at x = 0.6

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 22 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Euler Method
Given the step size h = 0.2. Then the x values are given by the interval table

x 0 = 0, x 1 = 0.2, x 2 = 0.4, x 3 = 0.6 (30)

The Euler formula is given as


y(x i +1 ) = y(x i ) + h f [x i , y(x i )] (31)
y i +1 = y i + h f (x i , y i ) (32)

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

Euler Method: Iteration 1: when i=0


The formula reduces to
y(x 1 ) = y(x 0 ) + h f [x 0 , y(x 0 )] (35)
y 1 = y 0 + h f (x 0 , y 0 ) (36)
From the question, that is y(0) = 1, the initial conditions can be deduced as
x 0 = 0, and y 0 = 1
Therefore x0 0
f (x 0 , y 0 ) = = =0
y0 1
Hence
y 1 = y 0 + h f (x 0 , y 0 ) (37)
= 1 + 0.2(0) (38)
=1 (39)
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 24 / 49
Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Euler Method: Iteration 2: when i=1


The formula reduces to
y 2 = y 1 + h f (x 1 , y 1 )
From the interval table (30), x 1 = 0.2, and from the previous solution y 1 = 1
Therefore x 1 0.2
f (x 1 , y 1 ) = = = 0.2
y1 1
Hence
y 2 = y 1 + h f (x 1 , y 1 ) (40)
= 1 + 0.2(0.2) (41)
= 1.04 (42)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 25 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Euler Method: Iteration 3: when i=2


The formula reduces to
y 3 = y 2 + h f (x 2 , y 2 )
From the interval table (30), x 2 = 0.4, and from the previous solution y 2 = 1.04
Therefore
y 3 = y 2 + h f (x 2 , y 2 ) (43)
µ ¶
0.4
= 1.04 + 0.2 (44)
1.04
= 1.117 (45)

Therefore, the nodal points are:


(x 0 , y 0 ) = (0, 1); (x 1 , y 1 ) = (0.2, 1); (x 2 , y 2 ) = (0.4, 1.04); (x 3 , y 3 ) = (0.6, 1.117)
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 26 / 49
Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Euler vs Analytical Solution


The differential equation is solved using separation of variables
dy x
Z Z
y = ′
= =⇒ dyy = xd x =⇒ y 2 = x 2 + c
dx y
Implementing the initial condition to find c
12 = 02 + c =⇒ c = 1
Therefore the analytical solution is
p
y= x2 + 1
Hence at point x 3 = 0.6
p
y 3 = y(0.6) = 0.62 + 1 = 1.166
The absolute error
AE = |E S − AS| = |1.166 − 1.117| = 0.049
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 27 / 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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 28 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Modified Euler Iteration 1: when i=0


The formula reduces to
h h
· ¸
y 1 = y 0 + h f x 0 + , y 0 + f (x 0 , y 0 ) (49)
2 2
· µ ¶¸
0.2 0.2 0
= 1 + 0.2 f 0 + , 1+ (50)
2 2 1
= 1 + 0.2 f (0.1, 1) (51)
µ ¶
0.1
= 1 + 0.2 (52)
1
= 1.02 (53)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 29 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Modified Euler Iteration 2: when i=1


From the interval table (30), x 1 = 0.2, and from the previous solution y 1 = 1.02
The solution is as follows
h h
· ¸
y 2 = y 1 + h f x 1 + , y 1 + f (x 1 , y 1 ) (54)
2 2
· µ ¶¸
0.2 0.2 0.2
= 1.02 + 0.2 f 0.2 + , 1.02 + (55)
2 2 1.02
= 1.02 + 0.2 f (0.3, 1.04) (56)
µ ¶
0.3
= 1.02 + 0.2 (57)
1.04
= 1.0777 (58)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 30 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Modified Euler Iteration 3: when i=2


From the interval table (30), x 2 = 0.4, and from the previous solution y 2 = 1.0777
The solution is as follows
h h
· ¸
y 3 = y 2 + h f x 2 + , y 2 + f (x 2 , y 2 ) (59)
2 2
· µ ¶¸
0.2 0.2 0.4
= 1.0777 + 0.2 f 0.4 + , 1.03 + (60)
2 2 1.0777
= 1.0777 + 0.2 f (0.5, 1.1148) (61)
µ ¶
0.5
= 1.0777 + 0.2 (62)
1.1148
= 1.1674 (63)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 31 / 49


Solution To IVP’s Using Single-Step Methods Heun’s Method or Euler-Cauchy Method

Modified Euler vs Analytical Solution

Therefore the nodal points are:

(x 0 , y 0 ) = (0, 1); (x 1 , y 1 ) = (0.2, 1.02); (x 2 , y 2 ) = (0.4, 1.0777); (x 3 , y 3 ) = (0.6, 1.1148)

Hence
AE = |E S − AS| = |1.167 − 1.1148| = 0.0522

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 32 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

6. Runge-Kutta Methods

1 This is also a single-step method used for solving IVPs.


2 A Runge-Kutta method of second-order uses two slopes, that is

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)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 33 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Second-Order Runge-Kutta

1 A general second-order Runge-Kutta (RK2) is of the form


k2
µ¶
1
y i +1 = y i + 1 − k1 + (66)
2θ 2θ

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 34 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 36 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Example
Solve the following IVP

y y ′ = x, y(0) = 1, 0 ≤ x ≤ 0.6, h = 0.2

using Runge-Kutta fourth-order scheme.


Hence determine the absolute error at x = 0.6

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 37 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Solution
Given the step size h = 0.2. Then the x values are given by the interval table

x 0 = 0, x 1 = 0.2, x 2 = 0.4, x 3 = 0.6 (70)

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 38 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 1: when i=0


The formula reduces to
1
y 1 = y 0 + (k 1 + 2k 2 + 2k 3 + k 4 ) (73)
6
where
µ ¶
0
k 1 = h f (x 0 , y 0 ) = 0.2 =0 (74)
1
h k1
µ ¶ µ ¶
0.2 0
k2 = h f x0 + , y 0 + = 0.2 f 0 + , 1+
2 2 2 2
= 0.2 f (0.1, 1) (75)
µ ¶
0.1
= 0.2 = 0.02
1

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 39 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 1: when i=0


h k2
µ ¶ µ ¶
0.2 0.02
k3 = h f x0 + , y 0 + = 0.2 f 0 + , 1+
2 2 2 2
= 0.2 f (0.1, 1.01)
µ ¶ (76)
0.1
= 0.2
1.01
= 0.02
¡ ¢
k 4 = h f x 0 + h, y 0 + k 3 = 0.2 f (0 + 0.2, 1 + 0.02)
= 0.2 f (0.2, 1.02)
(77)
µ ¶
0.2
= 0.2
1.02
= 0.04
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 40 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 1: when i=0

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)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 41 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 2: when i=1


From the interval table (70), x 1 = 0.2, and from the previous solution y 1 = 1.02
The formula reduces to
1
y 2 = y 1 + (k 1 + 2k 2 + 2k 3 + k 4 ) (81)
6
where
¶ µ
0.2
k 1 = h f (x 1 , y 1 ) = 0.2 = 0.04 (82)
1.02
h k1
µ ¶ µ ¶
0.2 0.04
k2 = h f x1 + , y 1 + = 0.2 f 0.2 + , 1.02 +
2 2 2 2
= 0.2 f (0.3, 1.04) (83)
µ ¶
0.3
= 0.2 = 0.06
1.04
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 42 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 2: when i=1


h k2
µ ¶ µ ¶
0.2 0.06
k3 = h f x1 + , y 1 + = 0.2 f 0.2 + , 1.02 +
2 2 2 2
= 0.2 f (0.3, 1.05)
µ ¶ (84)
0.3
= 0.2
1.05
= 0.06
¡ ¢
k 4 = h f x 1 + h, y 1 + k 3 = 0.2 f (0.2 + 0.2, 1.02 + 0.06)
= 0.2 f (0.4, 1.08)
(85)
µ ¶
0.4
= 0.2
1.08
= 0.079
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 43 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 2: when i=1

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)

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 44 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 3: when i=2


From the interval table (70), x 2 = 0.4, and from the previous solution y 2 = 1.079
The formula reduces to
1
y 3 = y 2 + (k 1 + 2k 2 + 2k 3 + k 4 ) (89)
6
where
µ¶
0.4
k 1 = h f (x 2 , y 2 ) = 0.2 = 0.074 (90)
1.079

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

Iteration 3: when i=2


h k2
µ ¶ µ ¶
0.2 0.09
k3 = h f x2 + , y 2 + = 0.2 f 0.4 + , 1.079 +
2 2 2 2
= 0.2 f (0.5, 1.125)
µ ¶ (92)
0.5
= 0.2
1.125
= 0.089
¡ ¢
k 4 = h f x 2 + h, y 2 + k 3 = 0.2 f (0.4 + 0.2, 1.079 + 0.089)
= 0.2 f (0.6, 1.168)
(93)
µ ¶
0.6
= 0.2
1.168
= 0.103
Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 46 / 49
Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Iteration 3: when i=2


Now let substitute eqs. (90) to (93) into the main formula eq. (89). Hence
1
y 3 = y 2 + (k 1 + 2k 2 + 2k 3 + k 4 ) (94)
6
1
= 1.079 + [0.07 + 2(0.09) + 2(0.089) + 0.103] = 1.168 (95)
6

Therefore the nodal points are;


(x 0 , y 0 ) = (0, 1); (x 1 , y 1 ) = (0.2, 1.02); (x 2 , y 2 ) = (0.4, 1.079); (x 3 , y 3 ) = (0.6, 1.168)

Hence AE = |E S − AS| = |1.167 − 1.168| = 0.001 (96)


Comparing the absolute error, we may conclude that, the fourth-order Runge-Kutta
scheme gives a more approximate solution than the other single-step schemes.

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 47 / 49


Solution To IVP’s Using Single-Step Methods Runge-Kutta Methods

Exercise

Solve the initial value problem

y ′ = 2x + 3y, y(0) = 1, x ∈ [0, 0.4], h = 0.1

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

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 48 / 49


END OF LECTURE
THANK YOU

Dr. Gabby (KNUST-Maths) ODE: Single Step Methods 49 / 49

You might also like