0% found this document useful (0 votes)
36 views12 pages

ES-341: Numerical Analysis: Dr. Mazhar Ali Mehboob Ul Haq (TA)

The document discusses the Runge-Kutta method for solving initial value problems (IVPs). It introduces IVPs and explains that Runge-Kutta obtains discrete approximations of the solution at finite time steps. The derivation shows expanding the solution to a second-order Taylor series and rearranging terms to arrive at the Runge-Kutta formulation.

Uploaded by

Maheen
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)
36 views12 pages

ES-341: Numerical Analysis: Dr. Mazhar Ali Mehboob Ul Haq (TA)

The document discusses the Runge-Kutta method for solving initial value problems (IVPs). It introduces IVPs and explains that Runge-Kutta obtains discrete approximations of the solution at finite time steps. The derivation shows expanding the solution to a second-order Taylor series and rearranging terms to arrive at the Runge-Kutta formulation.

Uploaded by

Maheen
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/ 12

ES-341:

Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)

Numerical
Methods for
Initial Value
Problem
ES-341: Numerical Analysis
Runge Kutta Method
for solving Initial
Value Problem

Dr. Mazhar Ali


Mehboob ul Haq (TA)

Faculty of Engineering Sciences

Ghulam Ishaq Khan Institute of Engineering Sciences and Technology

20th May 2022

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 1 / 12
ES-341:
Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)

Numerical
Methods for
Initial Value
Problem
Runge Kutta Method
for solving Initial
Value Problem

1 Numerical Methods for Initial Value Problem


Runge Kutta Method for solving Initial Value Problem

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 2 / 12
ES-341:
Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)

Numerical
Methods for
Initial Value
Problem
Runge Kutta Method
for solving Initial
Value Problem

Numerical Methods for Initial Value Problem

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 3 / 12
ES-341:
Numerical General form of an Ordinary Differential Equation (ODE)
Analysis

Dr. Mazhar Ali An Ordinary Differential (ODE) is a differential equations which


Mehboob ul Haq
(TA) involves the derivatives of one variable dependent functions i.e.,
Numerical
y (x), g (x), f (x), . . . with respect to an independent variable x.
Methods for
Initial Value
Problem
y ′ = f (x, y )
Runge Kutta Method
for solving Initial
Value Problem

Geometrical meaning
Let y1 (x) is the solution of the O.D.E. y ′ = f (x, y ).
𝒚𝟏 (𝒙) → solution of ODE is the integral curve 𝒚′ = 𝒇(𝒙, 𝒚) → represents
the directional field.

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 4 / 12
ES-341:
Numerical
Analysis Initial Value Problem (IVP)
Dr. Mazhar Ali
Mehboob ul Haq Let us consider an Initial Value Problem (IVP) as,
(TA)

Numerical dy
Methods for
Initial Value
= f (t, y ); a ≤ t ≤ b; y (a) = α
Problem dt
Runge Kutta Method
for solving Initial
Value Problem
The solution for this IVP can be stated as,

y (t), a≤t≤b

Here, we consider a numerical method for solving IVP, referred to


as “Runge Kutta Method”. It obtains an approximation on the
well-posed IVP. It is also known as Modified Runge Kutta
Method/Huen’s Method
Runge Kutta Method obtains discrete approximations of the
solution y (t) at discrete/finite steps
ti = {t0 , t1 , . . . , tn }, i = 1, 2, . . . , n. Defined as,

tn − t0
ti+i = ti + h, i = 0, 1, . . . , n; h=
n

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 5 / 12
ES-341:
Numerical
Analysis
Derivation: Runge Kutta Method
Dr. Mazhar Ali
Mehboob ul Haq
(TA) Let us consider y (t) is the unique solution to the IVP, expanding
this up to the second order Taylor series,
Numerical
Methods for
Initial Value
h2 ′′
Problem
y (t + h) = y (t) + hy ′ (t) + y (t) + O(h3 )
Runge Kutta Method
for solving Initial 2
Value Problem

b−a
Here h is the step size i.e., h = n .

y (t) = f (t, y ) ⇒ y ′′ (t) = ft (t, y ) + fy (t, y )y ′ (t)

h2  
y (t + h) = y (t) + hf (t, y ) + ft (t, y ) + fy (t, y )y ′ (t) + O(h3 )
2
h
y (t + h) = y (t) + f (t, y )
2
hh i
+ f (t, y ) + hft (t, y ) + hfy (t, y )f (t, y ) + O(h3 )
2

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 6 / 12
ES-341:
Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)
h
y (t + h) = y (t) + f (t, y )
Numerical
Methods for
2
Initial Value hh i
Problem + f (t, y ) + hft (t, y ) + hfy (t, y )f (t, y ) + O(h3 )
Runge Kutta Method 2
for solving Initial
Value Problem

We can describe the multivariate Taylor series as,

f (t + h, y + k) = f (t, y ) + hft (t, y ) + kfy (t, y ) + . . .


 
f t + h, y + hf (t, y ) ≈ f (t, y ) + hft (t, y ) + hfy (t, y )f (t, y )

Hence, we can finalize the expression as,


h h  
y (t + h) = y (t) + f (t, y ) + f t + h, y + hf (t, y ) + O(h3 )
2 2

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 7 / 12
ES-341:
Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)

Numerical
Methods for
Initial Value
Problem We can finalize algorithm as,
Runge Kutta Method
for solving Initial
Value Problem
h
yi+1 = yi + (k1 + k2 )
2
k1 = f (ti , yi )
 
k2 = f ti + h, yi + hk1

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 8 / 12
ES-341:
Numerical
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
(TA)
Runge Kutta Algorithm
Numerical
Methods for
Start with t0 = α, tn = β
Initial Value
Problem Define step size h = (tn − t0 )/n, discretization of interval [α, β]
Runge Kutta Method
for solving Initial into n steps.
Value Problem  
Define slope/function f t, y (t) .
Define y (t0 ) = α.
Start iteration counter k = 0 : 1 : n
1 Calculate ti = t0 + k(h)
2 Define k1 = f (ti ,yi ) 
3 Calculate k2 = f ti + h, yi + hk1
4 Calculate yi+1 = yi + h2 (k1 + k2 )
end counter

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 9 / 12
ES-341:
Numerical
Analysis Example 1: Initial Value Problem (IVP)
Dr. Mazhar Ali
Mehboob ul Haq Let us consider an Initial Value Problem (IVP) as,
(TA)

Numerical
Methods for
y ′ = y − t 2 + 1; 0 ≤ t ≤ 2; y (0) = 0.5
Initial Value
Problem
Runge Kutta Method
for solving Initial
consider step size h = 0.5.
Value Problem

Solution
First we identify t0 = 0 and tn = 2
We can describe number of discrete steps as
n = (tn − t0 )/h = (2 − 0)/0.5 = 4. Hence, ti = {t0 , t1 , t2 , t3 , t4 }.
We can describe ti+1 = ti + i(h), i = 0, 1, 2, 3, 4.
ti yi = y (ti )
t0 = 0 y0 = 0.5
t1 = 0.5 y1
t2 = 1.0 y2
t3 = 1.5 y3
t4 = 2.0 y4

Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 10 / 12
ES-341:
Numerical
Analysis
Iteration 1:
Dr. Mazhar Ali
Mehboob ul Haq t0 = 0, y0 = y (t0 ) = 0.5
(TA)
k1 = f (t0 , y0 ) = y0 − t02 + 1 = (0.5) − (0)2 + 1 = 1.5
Numerical
Methods for
Initial Value t0 + h = 0.5, y0 + h(k1 ) = 0.5 + 0.5(1.5) = 1.2500
Problem
Runge Kutta Method
for solving Initial k2 = f (t0 + h, y0 + hk1 ) = (1.25) − (0.5)2 + 1 = 2
Value Problem

h
y1 ≈ y0 + (k1 + k2 ) = 1.3750
2

Iteration 2:
t1 = 0.5, y1 = y (t1 ) = 1.375
k1 = f (t1 , y1 ) = y1 − t12 + 1 = (1.375) − (0.5)2 + 1 = 2.1250
t1 + h = 1.0, y1 + h(k1 ) = 1.375 + 0.5(2.1250) = 2.4375
k2 = f (t1 + h, y1 + hk1 ) = (2.4375) − (1.0)2 + 1 = 2.4375
h
y2 ≈ y1 + (k1 + k2 ) = 2.5156
2
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 11 / 12
ES-341:
Numerical Iteration 3:
Analysis

Dr. Mazhar Ali


Mehboob ul Haq
t2 = 1.0, y2 = y (t2 ) = 2.5156
(TA)
k1 = f (t2 , y2 ) = y2 − t22 + 1 = (2.5156) − (1.0)2 + 1 = 2.5156
Numerical
Methods for
Initial Value
t2 + h = 1.5, y2 + h(k1 ) = 2.5156 + 0.5(2.5156) = 5.0332
Problem
Runge Kutta Method
for solving Initial
k2 = f (t2 + h, y2 + hk1 ) = (5.0332) − (1.5)2 + 1 = 2.5234
Value Problem

h
y3 ≈ y2 + (k1 + k2 ) = 3.7754
2

Iteration 4:
t3 = 1.5, y3 = y (t3 ) = 3.7754
k1 = f (t3 , y3 ) = y3 − t32 + 1 = (3.7754) − (1.5)2 + 1 = 2.5254
t3 + h = 2.0, y3 + h(k1 ) = 3.7754 + 0.5(2.5254) = 6.1790
k2 = f (t3 + h, y3 + hk1 ) = (6.1790) − (2.0)2 + 1 = 2.0381
h
y4 ≈ y3 + (k1 + k2 ) = 4.9163
2
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20th May 2022 12 / 12

You might also like