SlideShare a Scribd company logo
1 of 13
Part 7:
Ordinary Differential Equations
–
–
–
–
–

Runge-Kutta Methods
Euler’s Method
Heun’s Method
Midpoint method
Systems of Equations
Runge-Kutta Methods
 We want to solve an ordinary differential equation of the form:
y

'

dy

f ( x, y )

dx

 The general approach of the solution is in the form of:
(new value)=(old value) + (slope) x (step size)

 All of the one-step methods under this
general category are called RungeKutta methods.
> Euler’s method
> Heun’s method
> Midpoint method
 The differences in these methods are
in the way (slope) is defined.

Slope=

yi

xi

xi

1

1

yi

h
Euler’s Method
 Simplest way of approximating the slope is in the form of first
derivative. Apply forward scheme finite difference for the starting
point:
y

yi

'

yi

1

h

predicted

f ( xi , yi )

yi

Then,
yi

1

yi

f ( xi , y i ) h

Euler’s
method
formula

where f(xi, yi) is calculated from
the initial condition.

1

true

yi

xi

xi

1

 That is the slope at the beginning is approximated as the slope
over the entire interval.
 As in the forward scheme finite difference method, error for this
approximation is O(h).
EX: Use Euler’s method to solve
dy

2x

3

12 x

2

20 x

8 .5

dx

from x=0 to x=2 with a step size of 0.5. The initial condition at x=0 is y=1.
Differential equation: f ( x , y )
Using Euler’s formula:
y ( 0 .5 )

y (0)

f ( 0 ,1) 0 . 5

2x

3

12 x

5 . 25

2

20 x

t

8 .5

63 . 1 %

Second step:
y (1)

y ( 0 .5 )

f ( 0 . 5,5 . 25 ) 0 . 5

5 . 875

t

95 . 8 %

Other steps:
y (1 . 5 )

5 . 1250

y ( 2 .0 )

4 . 5000

t
t

131 %
125 . 0 %

Error can be reduced by using a smaller step size (h).
Considering that Euler’s method has an error O(h), halving the step size will
halve the error.
Heun’s Method
 It is an improvement of Euler’s method.
 Improve the slope of the interval by averaging derivatives at the
starting and end points.
Slope=f(xi+1’ yi+10)

Slope=[f(xi’ yi)+f(xi+1’ yi+10)]/2

Slope=f(xi’ yi)

xi

Predictor

xi

1

xi

Corrector

xi

1
Approximate the slope at the starting point using Euler’s method
y

'

f ( x, y )

Extrapolate linearly to find y at the end point:
0

yi

yi

1

f ( xi , y i ) h

standard Euler method stops here.

This intermediate solution (predictor) is used to calculate the slope
at the end point:
'

0

yi

f ( xi 1 , yi 1 )

1

Calculate average of the two slopes at the starting and end points:
'

'

yi

'

y

yi

1

2

Use this slope to re-calculate y value at the end point (corrector):
'

yi

1

yi

yh
0

Predictor:
Corrector:

yi
yi

1

yi

1

yi

f ( xi , y i ) h

f ( xi , y i )

0

f ( xi 1 , y i 1 )

h

Heun’s
method

2

 Corrector equation involves yi+1 on both sides, which means that it
can be applied iteratively for the end point (i.e., older
approximation can be used iteratively to calculate a new
approximation).
 The iteration does not necessarily converge to the true solution
but approaches a solution with a finite truncation error.
 The method is accurate to O(h2).(compare to O(h) accuracy of
Euler’s method).
EX: Use Heun’s method to numerically solve the following ODE
y

'

4e

0 .8 x

0 .5 y

from x=0 to x=4 with a step size of h=1. Initial condition is (0,2).
Calculate the slope at the starting point (x=0):
'

y0

4e

0

0 .5 ( 2 )

3

Apply Euler’s (predictor) formula to evaluate y10
0

y1

2

3 (1)

5

t

25 . 3 %

Calculate slope at the end point (x=1)
'

0

y1

f ( x1 , y 1 )

4e

0 . 8 (1 )

0 .5 (5 )

Calculate average of the two slopes:
'

y

3

6 . 401164
2

4 . 701082

6 . 402164

Euler’s
method
Use the corrector formula to calculate the new prediction at x=1:
y1

2

4 . 701082 (1)

6 . 701082

t

8 . 18 %

Above is based on a single iteration at y1. Apply another iteration to refine the
predictor:
y1

2

[3

4e

0 . 8 (1 )

0 . 5 ( 6 . 701082 )]

6 . 275811

t

1 . 31 %

6 . 382129

t

3 . 03 %

2

Further correction:
y1

2

[3

4e

0 . 8 (1 )

Results for all the
points from x=0 to x=4:
(15 iterations at each point)

0 . 5 ( 6 . 275811 )]
2

x

y (true)

y (Heun)

0

2.0000000

2.0000000

0.00

1

6.1946314

6.360866

2.68

2

14.843922

15.302237

3.09

3

33.677172

34.743276

3.17

4

75.338963

77.735096

3.18

t(%)
Midpoint Method
 It is another improvement of Euler’s method.
 Approximate y at the midpoint of the interval, and use it for the
average slope of the entire interval.
Slope=f(xi+1/2’ yi+1/2)

Slope=f(xi+1/2’ yi+1/2)

xi

xi
yi

1/ 2

yi

f ( xi , yi )

Predictor

xi

1/ 2

h
2

yi

1

yi

f ( xi

1/ 2

Corrector

xi
, yi

1

1/ 2

)h
 No iteration can be made for the corrector.
 Just as the centered difference is superior to forward or backward
difference schemes, midpoint is superior to Euler’s method in the
same manner.

Euler’s method
Midpoint method

O(h)
O(h2)

truncation error

Summary:
 All the three methods, Euler’s, Heun’s (without iteration), and
midpoint methods, mentioned so far are under the general
category of one-step approaches called Runge-Kutta methods.
 Heun’s and midpoint methods are generally superior to Euler’s
method, even though they require somewhat more calculations.
Systems of Equations
 Problems requiring the solution of a system of ODE’s are very
common in engineering applications.
dy 1
dx
dy 2
dx

f 1 ( x , y 1 , y 2 ,..., y n )
f 2 ( x , y 1 , y 2 ,..., y n )

....
dy n
dx

n- initial conditions
need to be known
at the starting
value of x

f n ( x , y 1 , y 2 ,..., y n )

Euler’s Method:
 Simply apply Euler’s method for each equation at each step.
 Strcictly apply the one-step Euler’s formula for every equation
before proceeding to the next-step (i.e., do not update any
variable during a single step).
EX: Solve the following system of ODEs using Euler’s method.
dy 1

dy 2

0 .5 y1

dx

dx

4

0 .3 y 2

0 .1 y1

Assume that for x=0, y1=4, and y2=6. Integrate to x=2 with a step size h=0.5.
Apply Euler’s method:
y1 ( 0 . 5 )

4

y 2 ( 0 .5 )

6

0 .5 ( 4 ) 0 .5
4

0 .3( 6 )

3
0 . 1( 4 ) 0 . 5

6 .9

Other points are calculated in the same fashion. Results to x=2 are below:
x

y1

y2

0

4

6

0.5

3

6.9

1.0

2.25

7.715

1.5

1.6875

8.44525

2.0

1.265625

9.094087

More Related Content

What's hot

Linear differential equation
Linear differential equationLinear differential equation
Linear differential equation
Pratik Sudra
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
Sanjay Singh
 
Basic differential equations in fluid mechanics
Basic differential equations in fluid mechanicsBasic differential equations in fluid mechanics
Basic differential equations in fluid mechanics
Tarun Gehlot
 

What's hot (20)

HERMITE SERIES
HERMITE SERIESHERMITE SERIES
HERMITE SERIES
 
Mathematical Expectation And Variance
Mathematical Expectation And VarianceMathematical Expectation And Variance
Mathematical Expectation And Variance
 
Newton's forward difference
Newton's forward differenceNewton's forward difference
Newton's forward difference
 
Taylor's series
 Taylor's  series   Taylor's  series
Taylor's series
 
First order non-linear partial differential equation & its applications
First order non-linear partial differential equation & its applicationsFirst order non-linear partial differential equation & its applications
First order non-linear partial differential equation & its applications
 
Linear differential equation
Linear differential equationLinear differential equation
Linear differential equation
 
MILNE'S PREDICTOR CORRECTOR METHOD
MILNE'S PREDICTOR CORRECTOR METHODMILNE'S PREDICTOR CORRECTOR METHOD
MILNE'S PREDICTOR CORRECTOR METHOD
 
Error analysis in numerical integration
Error analysis in numerical integrationError analysis in numerical integration
Error analysis in numerical integration
 
Differential equations of first order
Differential equations of first orderDifferential equations of first order
Differential equations of first order
 
MATLAB : Numerical Differention and Integration
MATLAB : Numerical Differention and IntegrationMATLAB : Numerical Differention and Integration
MATLAB : Numerical Differention and Integration
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
 
Fourier series
Fourier series Fourier series
Fourier series
 
Basic differential equations in fluid mechanics
Basic differential equations in fluid mechanicsBasic differential equations in fluid mechanics
Basic differential equations in fluid mechanics
 
Numerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPTNumerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPT
 
Gamma function
Gamma functionGamma function
Gamma function
 
Reduction forumla
Reduction forumlaReduction forumla
Reduction forumla
 
Es272 ch3b
Es272 ch3bEs272 ch3b
Es272 ch3b
 
Fundamental theorem of arithmatic
Fundamental theorem of arithmaticFundamental theorem of arithmatic
Fundamental theorem of arithmatic
 
Binomial distribution
Binomial distributionBinomial distribution
Binomial distribution
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
 

Viewers also liked

Eulermethod2
Eulermethod2Eulermethod2
Eulermethod2
stellajoh
 
Adequacy of solutions
Adequacy of solutionsAdequacy of solutions
Adequacy of solutions
Tarun Gehlot
 
A2 /EXPT/THER/KELLY/APRIL
A2 /EXPT/THER/KELLY/APRILA2 /EXPT/THER/KELLY/APRIL
A2 /EXPT/THER/KELLY/APRIL
Rama Chandra
 
Eulermethod3
Eulermethod3Eulermethod3
Eulermethod3
stellajoh
 
Euler method notes sb
Euler method notes sbEuler method notes sb
Euler method notes sb
janetvmiller
 

Viewers also liked (20)

Eulermethod2
Eulermethod2Eulermethod2
Eulermethod2
 
Unit vi
Unit viUnit vi
Unit vi
 
Runge kutta
Runge kuttaRunge kutta
Runge kutta
 
Numerical solution using runge kutta with programming in c++
Numerical solution using runge kutta with programming in c++Numerical solution using runge kutta with programming in c++
Numerical solution using runge kutta with programming in c++
 
DLR_DG_AZIZ_2003
DLR_DG_AZIZ_2003DLR_DG_AZIZ_2003
DLR_DG_AZIZ_2003
 
AP Calculus AB March 25, 2009
AP Calculus AB March 25, 2009AP Calculus AB March 25, 2009
AP Calculus AB March 25, 2009
 
Ch02 7
Ch02 7Ch02 7
Ch02 7
 
AP Calculus AB March 26, 2009
AP Calculus AB March 26, 2009AP Calculus AB March 26, 2009
AP Calculus AB March 26, 2009
 
Calc 6.1b
Calc 6.1bCalc 6.1b
Calc 6.1b
 
DIFFRENTIAL EQUATIONS
DIFFRENTIAL EQUATIONSDIFFRENTIAL EQUATIONS
DIFFRENTIAL EQUATIONS
 
Numerical Integration
Numerical IntegrationNumerical Integration
Numerical Integration
 
Ma2002 1.6 rm
Ma2002 1.6 rmMa2002 1.6 rm
Ma2002 1.6 rm
 
Adequacy of solutions
Adequacy of solutionsAdequacy of solutions
Adequacy of solutions
 
Ma2002 1.16 rm
Ma2002 1.16 rmMa2002 1.16 rm
Ma2002 1.16 rm
 
A2 /EXPT/THER/KELLY/APRIL
A2 /EXPT/THER/KELLY/APRILA2 /EXPT/THER/KELLY/APRIL
A2 /EXPT/THER/KELLY/APRIL
 
Applied numerical methods lec6
Applied numerical methods lec6Applied numerical methods lec6
Applied numerical methods lec6
 
Cequel: Chemical Equilibrium in Excel
Cequel:  Chemical Equilibrium in ExcelCequel:  Chemical Equilibrium in Excel
Cequel: Chemical Equilibrium in Excel
 
Eulermethod3
Eulermethod3Eulermethod3
Eulermethod3
 
Euler method notes sb
Euler method notes sbEuler method notes sb
Euler method notes sb
 
10 09
10 0910 09
10 09
 

Similar to Es272 ch7

Computational techniques
Computational techniquesComputational techniques
Computational techniques
Rafi Dar
 
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docxCALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
RAHUL126667
 

Similar to Es272 ch7 (20)

Applications Of MATLAB Ordinary Differential Equations (ODE
Applications Of MATLAB  Ordinary Differential Equations (ODEApplications Of MATLAB  Ordinary Differential Equations (ODE
Applications Of MATLAB Ordinary Differential Equations (ODE
 
Computational techniques
Computational techniquesComputational techniques
Computational techniques
 
Term project
Term projectTerm project
Term project
 
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docxCALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docx
 
numericalmethods.pdf
numericalmethods.pdfnumericalmethods.pdf
numericalmethods.pdf
 
Euler Method
Euler MethodEuler Method
Euler Method
 
Mit18 330 s12_chapter5
Mit18 330 s12_chapter5Mit18 330 s12_chapter5
Mit18 330 s12_chapter5
 
Maths digital text
Maths digital textMaths digital text
Maths digital text
 
Calc 6.1a
Calc 6.1aCalc 6.1a
Calc 6.1a
 
Computational Dynamics edited
Computational Dynamics editedComputational Dynamics edited
Computational Dynamics edited
 
Complex Variables and Numerical Methods
Complex Variables and Numerical MethodsComplex Variables and Numerical Methods
Complex Variables and Numerical Methods
 
Introduction to Differential Equations
Introduction to Differential EquationsIntroduction to Differential Equations
Introduction to Differential Equations
 
Calculus
CalculusCalculus
Calculus
 
Episode 50 : Simulation Problem Solution Approaches Convergence Techniques S...
Episode 50 :  Simulation Problem Solution Approaches Convergence Techniques S...Episode 50 :  Simulation Problem Solution Approaches Convergence Techniques S...
Episode 50 : Simulation Problem Solution Approaches Convergence Techniques S...
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve
 
Ijmet 10 01_021
Ijmet 10 01_021Ijmet 10 01_021
Ijmet 10 01_021
 
MATLAB ODE
MATLAB ODEMATLAB ODE
MATLAB ODE
 
Trapezoidal Method IN Numerical Analysis
Trapezoidal Method IN  Numerical AnalysisTrapezoidal Method IN  Numerical Analysis
Trapezoidal Method IN Numerical Analysis
 
Maths iii quick review by Dr Asish K Mukhopadhyay
Maths iii quick review by Dr Asish K MukhopadhyayMaths iii quick review by Dr Asish K Mukhopadhyay
Maths iii quick review by Dr Asish K Mukhopadhyay
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value Problems
 

More from Batuhan Yıldırım (9)

Es272 ch6
Es272 ch6Es272 ch6
Es272 ch6
 
Es272 ch5b
Es272 ch5bEs272 ch5b
Es272 ch5b
 
Es272 ch5a
Es272 ch5aEs272 ch5a
Es272 ch5a
 
Es272 ch4b
Es272 ch4bEs272 ch4b
Es272 ch4b
 
Es272 ch4a
Es272 ch4aEs272 ch4a
Es272 ch4a
 
Es272 ch1
Es272 ch1Es272 ch1
Es272 ch1
 
Es272 ch0
Es272 ch0Es272 ch0
Es272 ch0
 
Es272 ch3a
Es272 ch3aEs272 ch3a
Es272 ch3a
 
Es272 ch2
Es272 ch2Es272 ch2
Es272 ch2
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Es272 ch7

  • 1. Part 7: Ordinary Differential Equations – – – – – Runge-Kutta Methods Euler’s Method Heun’s Method Midpoint method Systems of Equations
  • 2. Runge-Kutta Methods  We want to solve an ordinary differential equation of the form: y ' dy f ( x, y ) dx  The general approach of the solution is in the form of: (new value)=(old value) + (slope) x (step size)  All of the one-step methods under this general category are called RungeKutta methods. > Euler’s method > Heun’s method > Midpoint method  The differences in these methods are in the way (slope) is defined. Slope= yi xi xi 1 1 yi h
  • 3. Euler’s Method  Simplest way of approximating the slope is in the form of first derivative. Apply forward scheme finite difference for the starting point: y yi ' yi 1 h predicted f ( xi , yi ) yi Then, yi 1 yi f ( xi , y i ) h Euler’s method formula where f(xi, yi) is calculated from the initial condition. 1 true yi xi xi 1  That is the slope at the beginning is approximated as the slope over the entire interval.  As in the forward scheme finite difference method, error for this approximation is O(h).
  • 4. EX: Use Euler’s method to solve dy 2x 3 12 x 2 20 x 8 .5 dx from x=0 to x=2 with a step size of 0.5. The initial condition at x=0 is y=1. Differential equation: f ( x , y ) Using Euler’s formula: y ( 0 .5 ) y (0) f ( 0 ,1) 0 . 5 2x 3 12 x 5 . 25 2 20 x t 8 .5 63 . 1 % Second step: y (1) y ( 0 .5 ) f ( 0 . 5,5 . 25 ) 0 . 5 5 . 875 t 95 . 8 % Other steps: y (1 . 5 ) 5 . 1250 y ( 2 .0 ) 4 . 5000 t t 131 % 125 . 0 % Error can be reduced by using a smaller step size (h). Considering that Euler’s method has an error O(h), halving the step size will halve the error.
  • 5. Heun’s Method  It is an improvement of Euler’s method.  Improve the slope of the interval by averaging derivatives at the starting and end points. Slope=f(xi+1’ yi+10) Slope=[f(xi’ yi)+f(xi+1’ yi+10)]/2 Slope=f(xi’ yi) xi Predictor xi 1 xi Corrector xi 1
  • 6. Approximate the slope at the starting point using Euler’s method y ' f ( x, y ) Extrapolate linearly to find y at the end point: 0 yi yi 1 f ( xi , y i ) h standard Euler method stops here. This intermediate solution (predictor) is used to calculate the slope at the end point: ' 0 yi f ( xi 1 , yi 1 ) 1 Calculate average of the two slopes at the starting and end points: ' ' yi ' y yi 1 2 Use this slope to re-calculate y value at the end point (corrector): ' yi 1 yi yh
  • 7. 0 Predictor: Corrector: yi yi 1 yi 1 yi f ( xi , y i ) h f ( xi , y i ) 0 f ( xi 1 , y i 1 ) h Heun’s method 2  Corrector equation involves yi+1 on both sides, which means that it can be applied iteratively for the end point (i.e., older approximation can be used iteratively to calculate a new approximation).  The iteration does not necessarily converge to the true solution but approaches a solution with a finite truncation error.  The method is accurate to O(h2).(compare to O(h) accuracy of Euler’s method).
  • 8. EX: Use Heun’s method to numerically solve the following ODE y ' 4e 0 .8 x 0 .5 y from x=0 to x=4 with a step size of h=1. Initial condition is (0,2). Calculate the slope at the starting point (x=0): ' y0 4e 0 0 .5 ( 2 ) 3 Apply Euler’s (predictor) formula to evaluate y10 0 y1 2 3 (1) 5 t 25 . 3 % Calculate slope at the end point (x=1) ' 0 y1 f ( x1 , y 1 ) 4e 0 . 8 (1 ) 0 .5 (5 ) Calculate average of the two slopes: ' y 3 6 . 401164 2 4 . 701082 6 . 402164 Euler’s method
  • 9. Use the corrector formula to calculate the new prediction at x=1: y1 2 4 . 701082 (1) 6 . 701082 t 8 . 18 % Above is based on a single iteration at y1. Apply another iteration to refine the predictor: y1 2 [3 4e 0 . 8 (1 ) 0 . 5 ( 6 . 701082 )] 6 . 275811 t 1 . 31 % 6 . 382129 t 3 . 03 % 2 Further correction: y1 2 [3 4e 0 . 8 (1 ) Results for all the points from x=0 to x=4: (15 iterations at each point) 0 . 5 ( 6 . 275811 )] 2 x y (true) y (Heun) 0 2.0000000 2.0000000 0.00 1 6.1946314 6.360866 2.68 2 14.843922 15.302237 3.09 3 33.677172 34.743276 3.17 4 75.338963 77.735096 3.18 t(%)
  • 10. Midpoint Method  It is another improvement of Euler’s method.  Approximate y at the midpoint of the interval, and use it for the average slope of the entire interval. Slope=f(xi+1/2’ yi+1/2) Slope=f(xi+1/2’ yi+1/2) xi xi yi 1/ 2 yi f ( xi , yi ) Predictor xi 1/ 2 h 2 yi 1 yi f ( xi 1/ 2 Corrector xi , yi 1 1/ 2 )h
  • 11.  No iteration can be made for the corrector.  Just as the centered difference is superior to forward or backward difference schemes, midpoint is superior to Euler’s method in the same manner. Euler’s method Midpoint method O(h) O(h2) truncation error Summary:  All the three methods, Euler’s, Heun’s (without iteration), and midpoint methods, mentioned so far are under the general category of one-step approaches called Runge-Kutta methods.  Heun’s and midpoint methods are generally superior to Euler’s method, even though they require somewhat more calculations.
  • 12. Systems of Equations  Problems requiring the solution of a system of ODE’s are very common in engineering applications. dy 1 dx dy 2 dx f 1 ( x , y 1 , y 2 ,..., y n ) f 2 ( x , y 1 , y 2 ,..., y n ) .... dy n dx n- initial conditions need to be known at the starting value of x f n ( x , y 1 , y 2 ,..., y n ) Euler’s Method:  Simply apply Euler’s method for each equation at each step.  Strcictly apply the one-step Euler’s formula for every equation before proceeding to the next-step (i.e., do not update any variable during a single step).
  • 13. EX: Solve the following system of ODEs using Euler’s method. dy 1 dy 2 0 .5 y1 dx dx 4 0 .3 y 2 0 .1 y1 Assume that for x=0, y1=4, and y2=6. Integrate to x=2 with a step size h=0.5. Apply Euler’s method: y1 ( 0 . 5 ) 4 y 2 ( 0 .5 ) 6 0 .5 ( 4 ) 0 .5 4 0 .3( 6 ) 3 0 . 1( 4 ) 0 . 5 6 .9 Other points are calculated in the same fashion. Results to x=2 are below: x y1 y2 0 4 6 0.5 3 6.9 1.0 2.25 7.715 1.5 1.6875 8.44525 2.0 1.265625 9.094087