0% found this document useful (0 votes)
224 views

Unit 9 (Ordinary Differential Equations)

This document discusses numerical methods for solving ordinary differential equations (ODEs). It covers the following topics: 1. Euler's method and improvements of Euler's method for approximating solutions of ODEs using single-step methods. 2. Runge-Kutta methods, which are multiple-step methods that use information from more than one previous step to estimate solutions. 3. Systems of equations and general methods for boundary value problems, two other types of problems involving ODEs.

Uploaded by

ebrahim5936
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
224 views

Unit 9 (Ordinary Differential Equations)

This document discusses numerical methods for solving ordinary differential equations (ODEs). It covers the following topics: 1. Euler's method and improvements of Euler's method for approximating solutions of ODEs using single-step methods. 2. Runge-Kutta methods, which are multiple-step methods that use information from more than one previous step to estimate solutions. 3. Systems of equations and general methods for boundary value problems, two other types of problems involving ODEs.

Uploaded by

ebrahim5936
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Numerical Methods (CISE-301)

Unit-9
(Ordinary Differential Equations)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Contents (Unit-9):
1) Euler’s Method (Sec 25.1)

2) Improvements of Euler’s Method (Sec 25.2)

3) Runge-Kutta Methods (Sec 25.3)

4) Systems of Equations (Sec 25.4)

5) General Methods for Boundary-Value Problems (Sec 27.1)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Derivative = Slope

Derivatives

Ordinary Derivatives Partial Derivatives


𝑑𝑑𝑑𝑑 𝜕𝜕𝜕𝜕
𝑑𝑑𝑑𝑑 𝜕𝜕𝜕𝜕
v is a function of one u is a function of more than one
independent variable independent variable

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Derivative = Slope
Differential Equations

Partial Differential Equations


Ordinary Differential Equations
𝑑𝑑 2 𝑣𝑣 𝜕𝜕 2 𝑢𝑢 𝜕𝜕 2 𝑢𝑢
+ 6𝑡𝑡𝑡𝑡 = 1 − =0
𝑑𝑑𝑡𝑡 2 𝜕𝜕𝑦𝑦 2 𝜕𝜕𝑥𝑥 2
Involve one or more Ordinary derivatives of
unknown functions Involve one or more Partial derivatives of
unknown functions

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Ordinary Differential Equations (ODE) involve one or more ordinary derivatives of
unknown functions with respect to one independent variable

𝑑𝑑𝑑𝑑(𝑡𝑡)
− 𝑣𝑣(𝑡𝑡) = 𝑒𝑒 𝑡𝑡
𝑑𝑑𝑑𝑑 𝑥𝑥(𝑡𝑡): Unknown Function

𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑(𝑡𝑡)
−5 + 2𝑥𝑥(𝑡𝑡) = cos( 𝑡𝑡)
𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑

𝑡𝑡: Independent Variable

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 The velocity of a falling parachutist is given by
𝑀𝑀: 𝑀𝑀𝑎𝑎𝑎𝑎𝑎𝑎

𝑐𝑐: 𝐷𝐷𝑟𝑟𝑟𝑟𝑟𝑟 𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓


ODE
𝑣𝑣: 𝑉𝑉𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒
𝑑𝑑𝑑𝑑 𝑐𝑐 (Dependent variable)
= 9.8 − 𝑣𝑣 unknown function to be
𝑑𝑑𝑑𝑑 𝑀𝑀 determined

(Independent Variable)
the variable with respect to which
other variables are differentiated

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 The order of an ODE is the order of the highest order derivative

𝑑𝑑𝑑𝑑(𝑡𝑡)
− 𝑥𝑥(𝑡𝑡) = 𝑒𝑒 𝑡𝑡 1st order ODE
𝑑𝑑𝑑𝑑

𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑 𝑡𝑡
−5 + 2𝑥𝑥(𝑡𝑡) = cos( 𝑡𝑡) 2nd order ODE
𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑

3
𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑(𝑡𝑡)
− + 2𝑥𝑥 4 (𝑡𝑡) = 1 2nd order ODE
𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 An ODE is linear if
 The unknown function and its derivatives appear to power one

 No product of the unknown function and/or its derivatives

𝑑𝑑𝑑𝑑(𝑡𝑡) 𝑑𝑑𝑑𝑑(𝑡𝑡)
− 𝑥𝑥(𝑡𝑡) = 𝑒𝑒 𝑡𝑡 Linear ODE − cos( 𝑥𝑥(𝑡𝑡)) = 1 Non-Linear ODE
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑

𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑 𝑡𝑡 𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑(𝑡𝑡)


−5 + 2𝑥𝑥(𝑡𝑡) = cos( 𝑡𝑡) Linear ODE −5 𝑥𝑥(𝑡𝑡) = 2 Non-Linear ODE
𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑 𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑

2
𝑑𝑑 𝑥𝑥(𝑡𝑡)
3
𝑑𝑑𝑑𝑑(𝑡𝑡) 𝑑𝑑 2 𝑥𝑥(𝑡𝑡) 𝑑𝑑𝑑𝑑(𝑡𝑡)
− + 𝑥𝑥(𝑡𝑡) = 1 Non-Linear ODE − + 𝑥𝑥(𝑡𝑡) = 1 Non-Linear ODE
𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑 𝑑𝑑𝑡𝑡 2 𝑑𝑑𝑑𝑑
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Ordinary Differential Equations:
 A solution to a differential equation is a function that satisfies the original equation.

𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸: 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆:

𝑑𝑑𝑑𝑑(𝑡𝑡) 𝑥𝑥(𝑡𝑡) = 𝑒𝑒 −𝑡𝑡


+ 𝑥𝑥(𝑡𝑡) = 0
𝑑𝑑𝑑𝑑
𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃:

𝑑𝑑𝑑𝑑(𝑡𝑡)
= −𝑒𝑒 −𝑡𝑡
𝑑𝑑𝑑𝑑

𝑑𝑑𝑑𝑑(𝑡𝑡)
+ 𝑥𝑥(𝑡𝑡) = −𝑒𝑒 −𝑡𝑡 + 𝑒𝑒 −𝑡𝑡 = 0
Is it Unique? 𝑑𝑑𝑑𝑑

All functions of the form 𝑥𝑥 𝑡𝑡 = 𝑘𝑘𝑒𝑒 −𝑡𝑡 (where 𝑘𝑘 is a real constant) are solutions
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Ordinary Differential Equations:
 Uniqueness of a solution
 In order to uniquely specify a solution to an 𝑛𝑛𝑡𝑡𝑡 order differential equation we need 𝑛𝑛 conditions

𝑑𝑑 2 𝑦𝑦(𝑥𝑥)
2
+ 4𝑦𝑦(𝑥𝑥) = 0 2nd order ODE
𝑑𝑑𝑡𝑡

𝑦𝑦(0) = 𝑎𝑎 Two conditions are needed


to uniquely specify the
𝑦𝑦(0)
̇ = 𝑏𝑏 solution

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Uniqueness of a solution

This 𝐶𝐶 is called a constant of integration. The fact that such an


arbitrary constant appears indicates that the solution is not
unique. In fact, it is but one of an infinite number of possible
functions (corresponding to an infinite number of possible
values of 𝐶𝐶) that satisfy the differential equation.
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Ordinary Differential Equations:
 Auxiliary Conditions
Auxiliary Conditions

More Difficult
Initial Conditions Boundary Conditions
Initial Value Boundary Value
All conditions are at one point of the The conditions are not at one point
Problems Problems
independent variable of the independent variable

𝑥𝑥̈ + 2𝑥𝑥̇ + 𝑥𝑥 = 𝑒𝑒 −2𝑡𝑡 𝑥𝑥̈ + 2𝑥𝑥̇ + 𝑥𝑥 = 𝑒𝑒 −2𝑡𝑡

𝑥𝑥(0) = 1, 𝑥𝑥(0)
̇ = 2.5 𝑥𝑥(0) = 1, 𝑥𝑥(2)
̇ = 1.5

Same Different

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Classification of ODE
 Order
 1st order ODE
 2nd order ODE
 𝑁𝑁 𝑡𝑡𝑡 order ODE

 Linearity
 Linear ODE
 Non-Linear ODE

 Auxiliary Conditions
 Initial Value Problems
 Boundary Value Problems

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Numerical methods for ODE

Numerical Methods for ODE

Single-Step Methods Multiple-Step Methods

Estimates of the solution at a Estimates of the solution at a


particular step are entirely based on particular step are based on
information on the previous step information on more than one step

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Numerical methods for ODE

xi-2 xi-1 xi xi+1 xi-2 xi-1 xi xi+1

Single-Step Methods Multiple-Step Methods

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Ordinary Differential Equations:
 Summary of ODE
 Basic definitions of ODE
 Order
 Linearity
 Initial Conditions
 Solution
 Classify ODE
 1st order ODE, 2nd order ODE, 𝑁𝑁 𝑡𝑡𝑡 order ODE
 Linear ODE, Non-Linear ODE
 Initial Value Problems, Boundary Value Problems
 Classify the solution methods
 Single step methods, multiple step methods

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Sec 25.1)
Euler’s Method:
 Recall from Taylor Series

𝑁𝑁𝑁𝑁𝑁𝑁 𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉 = 𝑂𝑂𝑂𝑂𝑂𝑂 𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉𝑉 + 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 × 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆

This formula is referred to as Euler’s / Euler-Cauchy / point-slope method.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method:
 First order Taylor series method is known as Euler’s
Method

 Only the constant term and linear term are used in


Euler’s method

 The error due to the use of the truncated Taylor series


is of order 𝑂𝑂(ℎ2 )

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method:
 Interpretation of Euler Method

y2 𝑦𝑦2 = 𝑦𝑦1 + ℎ𝑓𝑓(𝑥𝑥1, 𝑦𝑦1)


Slope=f(x1,y1)
ℎ𝑓𝑓(𝑥𝑥1, 𝑦𝑦1)
Slope=f(x0,y0)
y1 𝑦𝑦1 = 𝑦𝑦0 + ℎ𝑓𝑓(𝑥𝑥0, 𝑦𝑦0)
ℎ𝑓𝑓(𝑥𝑥0, 𝑦𝑦0)
y0

x0 x1 x2 x
h h

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):
Use Euler’s method to numerically integrate the given system from 𝑥𝑥 = 0 to 𝑥𝑥 = 4 with a step size
of 0.5. The initial condition at 𝑥𝑥 = 0 is 𝑦𝑦 = 1.
Note: The exact solution is

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):
True Solution

%age Relative Error

2nd Step

True Solution

%age Relative Error

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):

Euler’s method for the given system from 𝑥𝑥 = 0 to 𝑥𝑥 = 4


with a step size of 0.5. The initial condition at 𝑥𝑥 = 0 is
𝑦𝑦 = 1.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):
For the step size of 0.5, estimate the error of the 1st step for the given system. Also use it to
determine the error due to each higher-order term of the Taylor series.

1st derivative of the ODE

2nd derivative of the ODE

3rd derivative of the ODE

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Example):
For the step size of 0.5, estimate the error of the 1st step for the given system. Also use it to
determine the error due to each higher-order term of the Taylor series.

Which is exactly the same error that was incurred in the initial step of previous example

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Euler’s Method (Class Activity):
Use Euler’s method to solve the given system to determine 𝑦𝑦 1.01 , 𝑦𝑦 1.02 , 𝑦𝑦(1.03) with a step
size of 0.01. The initial condition at 𝑥𝑥 = 1 is 𝑦𝑦 = −4.

𝑓𝑓(𝑥𝑥, 𝑦𝑦) = 1 + 𝑥𝑥 2

𝑦𝑦𝑖𝑖+1 = 𝑦𝑦𝑖𝑖 + 𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ℎ

𝑖𝑖 𝑥𝑥𝑖𝑖 𝑦𝑦𝑖𝑖 True value


𝑦𝑦1 = 𝑦𝑦0 + 𝑓𝑓 𝑥𝑥0 , 𝑦𝑦0 ℎ = −4 + 0.01(1 + (1)2 ) = −3.98
0 1.00 −4.00 −4.00
2
𝑦𝑦2 = 𝑦𝑦1 + 𝑓𝑓 𝑥𝑥1 , 𝑦𝑦1 ℎ = −3.98 + 0.01 1 + 1.01 = −3.9598 1 1.01 −3.98 −3.97996

𝑦𝑦3 = 𝑦𝑦2 + 𝑓𝑓 𝑥𝑥2 , 𝑦𝑦2 ℎ = −3.9598 + 0.01 1 + 1.02 2 = −3.9394 2 1.02 −3.9595 −3.95959
3 1.03 −3.9394 −3.93091

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Sec 25.2)
Improvements of Euler’s Method:
 A fundamental source of error in Euler’s method is that the derivative at the beginning of
the interval is assumed to apply across the entire interval.

 Improvements of Euler’s method can be done using


 Heun’s Method

 Midpoint Method

These methods provide the accuracy of the 2nd order Taylor series method without the need to calculate 2nd order derivative

 Runge-Kutta Methods

This method provide the accuracy of the high order Taylor series method without the need to calculate high order derivative

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method:
 Heun’s Method
 One method to improve the estimate of the slope involves

Predictor
the determination of two derivatives for the interval, one
at the initial point and another at the end point

 The two derivatives are then averaged to obtain an


improved estimate of the slope for the entire interval

Graphical representation of iterating


the corrector of Heun’s method to

Corrector
obtain an improved estimate

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method:
 Heun’s Method
 One of the Runge-Kutta methods (RK2), as it uses 2

Predictor
slopes.

 One at the initial point (𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) and another one at the
0
predicted value of the final point (𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )

Corrector
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Improvements of Euler’s Method:
 Heun’s Method
0
𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) + 𝑓𝑓(𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )
𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 =
2 0
𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑓𝑓(𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )

0
(𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )

1
(𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )
(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )

𝑥𝑥0 𝑥𝑥𝑖𝑖+1

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Example):
Use Heun’s method to integrate the given system from 𝑥𝑥 = 0 to 𝑥𝑥 = 4 with a step size of 1. The
initial condition at 𝑥𝑥 = 0 is 𝑦𝑦 = 2.

Analytical Solution

Predictor

Slope at initial conditions

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Example):
Corrector

Slope at (1,5)

Average of both the slopes

Notice: The errors sometimes grow as the iterations proceed, such increases can occur, especially for large step sizes.
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Improvements of Euler’s Method (Example):
1 & 15
Iteration/step

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Class Activity):
Use Heun’s method to solve the given system to determine 𝑦𝑦 0.1 , 𝑦𝑦 0.2 with a step size of 0.1.
The initial condition at 𝑦𝑦(0) = 1.
𝑦𝑦(𝑥𝑥)
̇ = 1 + 𝑥𝑥 2 + 𝑦𝑦

Step-1
Predictor: 𝑦𝑦10 = 𝑦𝑦0 + ℎ𝑓𝑓(𝑥𝑥0 , 𝑦𝑦0 ) = 1 + 0.1(2) = 1.2


Corrector: 𝑦𝑦11 = 𝑦𝑦0 + 𝑓𝑓(𝑥𝑥0 , 𝑦𝑦0 ) + 𝑓𝑓(𝑥𝑥1 , 𝑦𝑦10 ) = 1.2105
2
Step-2

Predictor: 𝑦𝑦20 = 𝑦𝑦1 + ℎ𝑓𝑓(𝑥𝑥1 , 𝑦𝑦1 ) = 1.4326


Corrector: 𝑦𝑦21 = 𝑦𝑦1 + 𝑓𝑓(𝑥𝑥1 , 𝑦𝑦1 ) + 𝑓𝑓(𝑥𝑥2 , 𝑦𝑦20 ) = 1.4452
2
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Improvements of Euler’s Method:
 Midpoint Method
 This technique uses Euler’s method to predict a value of 𝑦𝑦 at
the midpoint of the interval

 This predicted value is used to calculate slope at midpoint

 This slope is then used to extrapolate linearly from 𝑥𝑥𝑖𝑖 to 𝑥𝑥𝑖𝑖+1

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method:
 Midpoint Method
𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑓𝑓(𝑥𝑥 1 , 𝑦𝑦 1 )
𝑖𝑖+ 𝑖𝑖+
2 2
𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )
(𝑥𝑥 1 , 𝑦𝑦 1 )
𝑖𝑖+ 𝑖𝑖+
2 2

(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )

𝑥𝑥0 𝑥𝑥 1 𝑥𝑥𝑖𝑖+1
𝑖𝑖+
2

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Class Activity):
Use Midpoint method to solve the given system to determine 𝑦𝑦 0.1 , 𝑦𝑦 0.2 with a step size of 0.1.
The initial condition at 𝑦𝑦(0) = 1.
𝑦𝑦(𝑥𝑥)
̇ = 1 + 𝑥𝑥 2 + 𝑦𝑦

Step-1 ℎ
𝑦𝑦 1 = 𝑦𝑦0 + 𝑓𝑓(𝑥𝑥0 , 𝑦𝑦0 ) = 1 + 0.05(1 + 0 + 1) = 1.1
0+
2 2

𝑦𝑦1 = 𝑦𝑦0 + ℎ𝑓𝑓(𝑥𝑥 1 , 𝑦𝑦 1 ) = 1 + 0.1(1 + 0.0025 + 1.1) = 1.2103


0+ 0+
2 2

Step-2 ℎ
𝑦𝑦 1 = 𝑦𝑦1 + 𝑓𝑓(𝑥𝑥1 , 𝑦𝑦1 ) = 1.2103 + .05(1 + 0.01 + 1.2103) = 1.3213
1+
2 2

𝑦𝑦2 = 𝑦𝑦1 + ℎ𝑓𝑓(𝑥𝑥 1 , 𝑦𝑦 1 ) = 1.2103 + 0.1(2.3438) = 1.4446


1+ 1+
2 2

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Improvements of Euler’s Method (Class Activity):
 Comparison
Methods Local Truncation Error Global Truncation Error

Euler Method
𝑂𝑂(ℎ2 ) 𝑂𝑂(ℎ)
𝑦𝑦𝑖𝑖+1 = 𝑦𝑦𝑖𝑖 + ℎ𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )
Heun′s Method
0
Predictor: 𝑦𝑦𝑖𝑖+1 = 𝑦𝑦𝑖𝑖 + ℎ𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )𝑂𝑂(ℎ3 )𝑂𝑂(ℎ2 )
𝑂𝑂(ℎ3 ) 𝑂𝑂(ℎ2 )
𝑘𝑘+1 ℎ 𝑘𝑘
Corrector: 𝑦𝑦𝑖𝑖+1 = 𝑦𝑦𝑖𝑖 + 𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) + 𝑓𝑓(𝑥𝑥𝑖𝑖+1 , 𝑦𝑦𝑖𝑖+1 )
2
Midpoint

𝑦𝑦 1 = 𝑦𝑦𝑖𝑖 + 𝑓𝑓(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 )𝑂𝑂(ℎ3 )𝑂𝑂(ℎ2 )
𝑖𝑖+
2 2 𝑂𝑂(ℎ3 ) 𝑂𝑂(ℎ2 )

𝑦𝑦𝑖𝑖+1 = 𝑦𝑦𝑖𝑖 + ℎ𝑓𝑓(𝑥𝑥 1 , 𝑦𝑦 1 )


𝑖𝑖+ 𝑖𝑖+
2 2

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Sec 25.3)
Runge-Kutta Methods:
 Runge-Kutta (RK) methods achieve the accuracy of a Taylor series approach without
requiring the calculation of higher derivatives. Many variations exist but all can be cast
in the generalized form

 Here 𝜑𝜑(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 , ℎ) is called an increment function, which can be interpreted as a


representative slope over the interval. The increment function can be written in general
form as

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods:
Alternate Representations

Heun’s Method with a Single Corrector The Midpoint Method Ralston’s Method
(𝑎𝑎2 = 1⁄2) (𝑎𝑎2 = 1) (𝑎𝑎2 = 2⁄3)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Example):
Use Midpoint method and Ralston’s method to numerically integrate the given system from 𝑥𝑥 = 0 to
𝑥𝑥 = 4 with a step size of 0.5. The initial condition at 𝑥𝑥 = 0 is 𝑦𝑦 = 1. Moreover, compare the results
with the values obtained using another second-order RK algorithm, that is, the Heun’s method
without corrector iteration.
Midpoint Method Ralston’s Method

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Example):

Notice:

All the 2nd order RK methods are superior to Euler’s method

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods:
3rd order RK Methods 4th order RK Methods Higher order RK Methods

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Example):
Use classical 4th order RK method to integrate the given systems.
a) Step size ℎ = 0.5 with 𝑦𝑦 0 = 1
b) Step size ℎ = 0.5 with 𝑦𝑦 0 = 2 from 𝑥𝑥 = 0 to 𝑥𝑥 = 0.5.

The answer is exact, because the true solution is quartic, thus the 4th order method gives exact result.
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Runge-Kutta Methods (Example):
Use classical 4th order RK method to integrate the given systems.
a) Step size ℎ = 0.5 with 𝑦𝑦 0 = 1
b) Step size ℎ = 0.5 with 𝑦𝑦 0 = 2 from 𝑥𝑥 = 0 to 𝑥𝑥 = 0.5.

Slope at the midpoint

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Runge-Kutta Methods (Example):

Notice:

 The higher-order methods attain better accuracy for the same


computational effort
 The gain in accuracy for the additional effort tends to diminish after a
point. (Notice that the curves drop rapidly at first and then tend to level
off.)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Systems of Equations (Sec 25.4)
Systems of Equations:
 Many practical problems in engineering and science
require the solution of a system of simultaneous ODE
rather than a single equation.

 The solution of such a system requires that 𝑛𝑛 initial


conditions be known at the starting value of 𝑥𝑥.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Systems of Equations (Example):
Solve the given set of differential equations using Euler’s method, assuming that at 𝑥𝑥 = 0, 𝑦𝑦1 = 4
and 𝑦𝑦2 = 6. Integrate to 𝑥𝑥 = 2 with a step size of 0.5.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Systems of Equations (Example):
Solve the given set of differential equations using 4th order RK method, assuming that at 𝑥𝑥 = 0, 𝑦𝑦1 =
4 and 𝑦𝑦2 = 6. Integrate to 𝑥𝑥 = 2 with a step size of 0.5.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Systems of Equations (Example):
Solve the given set of differential equations using 4th order RK method, assuming that at 𝑥𝑥 = 0, 𝑦𝑦1 =
4 and 𝑦𝑦2 = 6. Integrate to 𝑥𝑥 = 2 with a step size of 0.5.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Systems of Equations (Example):
Solve the given set of differential equations using 4th order RK method, assuming that at 𝑥𝑥 = 0, 𝑦𝑦1 =
4 and 𝑦𝑦2 = 6. Integrate to 𝑥𝑥 = 2 with a step size of 0.5.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for Boundary-Value
Problems (Sec 27.1)
General Methods for BVP:
 Auxiliary Conditions
Auxiliary Conditions

More Difficult
Initial Conditions Boundary Conditions
Initial Value Boundary Value
All conditions are at one point of the The conditions are not at one point
Problems Problems
independent variable of the independent variable

𝑥𝑥̈ + 2𝑥𝑥̇ + 𝑥𝑥 = 𝑒𝑒 −2𝑡𝑡 𝑥𝑥̈ + 2𝑥𝑥̇ + 𝑥𝑥 = 𝑒𝑒 −2𝑡𝑡

𝑥𝑥(0) = 1, 𝑥𝑥(0)
̇ = 2.5 𝑥𝑥(0) = 1, 𝑥𝑥(2)
̇ = 1.5

Same Different

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
 Auxiliary Conditions

Initial Value Problems Boundary Value Problems

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
 The conservation of heat can be used to develop a heat balance for a long, thin rod. If the
rod is not insulated along its length and the system is at a steady state, if ℎ′ is a heat
transfer coefficient (𝑚𝑚−2 ) that parameterizes the rate of heat dissipation to the
surrounding air and 𝑇𝑇𝑎𝑎 is the temperature of the surrounding air.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
 Boundary value problem can be solved using
 Shooting Method

 Finite-Difference Method

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
Boundary-Value Problems Convert Initial-value problem
 Shooting Method
 Guess a values for the auxiliary conditions at one point of time

 Solve the initial value problem using Euler, Runge-Kutta, etc.

 Check if the boundary conditions is satisfied otherwise modify the guess and resolve the problem

 Use interpolation in updating the guess

 It is an iterative procedure and can be efficient in solving the BVP

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
 Shooting Method

Target

Target

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
 Shooting Method

Target

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP:
Boundary-Value Problems Convert Algebraic Equations
 Finite-Difference Method
 Finite divided differences are substituted for the derivatives in the original equation.

 Thus, a linear differential equation is transformed into a set of simultaneous algebraic equations that
can be solved.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP (Example):
Use the Finite-Difference method to solve the given equation for a 10 𝑚𝑚 rod with ℎ′ = 0.01 𝑚𝑚−2 ,
𝑇𝑇𝑎𝑎 = 20, step size ∆𝑥𝑥 = 2𝑚𝑚 and the boundary conditions 𝑇𝑇 0 = 40 and 𝑇𝑇(10) = 200.

Substitute 𝑖𝑖 = 1,2,3,4 in the equation to constitute 4 linear equations with 4 unknown

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


General Methods for BVP (Example):
 Comparison

Dr. Muhammad Majid Gulzar (CIE-KFUPM)

You might also like