0% found this document useful (0 votes)
53 views29 pages

Hacettepe University Department of Environmental Engineering

This document discusses numerical methods for solving ordinary differential equations (ODEs). It introduces Euler's method and higher-order Runge-Kutta methods. Euler's method uses the slope at the initial point to estimate the solution at later points. Higher-order methods improve this estimate using slopes at multiple points within each interval. The document provides examples of applying Euler's method and the midpoint method, Heun's method, and the fourth-order Runge-Kutta method to solve ODEs numerically. It also discusses solving systems of ODEs and error analysis of these numerical methods.

Uploaded by

Dilan Ağkoç
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)
53 views29 pages

Hacettepe University Department of Environmental Engineering

This document discusses numerical methods for solving ordinary differential equations (ODEs). It introduces Euler's method and higher-order Runge-Kutta methods. Euler's method uses the slope at the initial point to estimate the solution at later points. Higher-order methods improve this estimate using slopes at multiple points within each interval. The document provides examples of applying Euler's method and the midpoint method, Heun's method, and the fourth-order Runge-Kutta method to solve ODEs numerically. It also discusses solving systems of ODEs and error analysis of these numerical methods.

Uploaded by

Dilan Ağkoç
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/ 29

HACETTEPE UNIVERSITY

DEPARTMENT OF ENVIRONMENTAL
ENGINEERING

CEV 206 – NUMERICAL ANALYSIS

LECTURE 10

Dr. Ece Kendir Çakmak


ORDINARY DIFFERENTIAL EQUATIONS
 As the function involves one independent variable, the
equation is called an ordinary differential equation(ODE)

 first-order equation- the highest derivative is a first


derivative.
 second-order equation- he highest derivative is a first
derivative. a second derivative.
HOW CAN ODEs BE SOLVED
NUMERICALLY?
EULER’S METHOD
 The first derivative provides a direct
estimate of the slope at xi
ERROR ANALYSIS IN EULER’S METHOD
 Truncation errors and Round-off errors
 For truncation errors:

Where Et: the true local truncation error

As the order increases, the orders in the terms


decrease, SO:

Where Ea: the approximate


OR
local truncation error
EXAMPLE-EULER’S METHOD (from
reference book)
 Use Euler’s method to numerically integrate and estimate
the erros for the following eqn for x=0 to x=4 and inital
conditions (x=0, y=1): (Step size, h=0.5)

f(xi,yi)=-2*0+12*0-20*0+8.5=8.5

y(0.5) = y(0)+ f(xi,yi)*h = 1+(8.5)*0.5=5.25


 True value of y(0.5) = -0.5*(0.5^4)+4*(0.5^3)-
10(0.5^2)+8.5+1=3.21875

Et=100*(3.21875-5.25)/(3.21875)=-63.1% (also called global error)

Ea= (also called local error)

First derivative of the dy/dx=-6x^2+24x- 20 , when x=0 it is -20


Second derivative of the dy/dx=-12x+24 , when x=0 it is 24
Third derivative of the dy/dx=-12

So: Ea: (0.5^2)*(-20/2)+ (0.5^3)*(24/6)+(0.5^4)(-12/24)= -2.03 and


as the percent error:100* ( -2.03/3.21875)=-63.1%
HOW CAN WE REDUCE ERRORS?
 1. By decreasing the step size.
 2. If the underlying function (that is, thesolution of the
differential equation) is linear, because for a straight line
the second derivative would be zero
HEUN’S METHOD
 One method to improve the estimate of the slope
involves the determination of two derivatives for the
interval (one at the initial point and another at the end
point).
 And use the average to get a better estimation.
PREDICTOR EQUATION
CORRECTOR EQUATION
THE MIDPOINT METHOD
 uses Euler’s method to predict a value of y at the
midpoint of the interval
RUNGE-KUTTA METHODS
 Have the accuracy of a Taylor series approach without
requiring the calculation of higher derivatives.

increment function (a representative


slope over the interval)
 a’s are constants
 k’s are:

p’s and q’s are constants


First- Second order Runge Kutta Method-
ORDERs

 the first-order RK method with n=1 is Euler’s


method.
 second-order RK methods use an increment
function with two terms (n=2).
 These second-order methods will be exact if
the solution to the differential equation is
quadratic.
 The third- and fourth-order RK methods(n=3
and 4) are also developed.
Second Order Runge Kutta Method
 The second-order version :

values for al, a2,p1, and q11


are evaluated by setting the equation above equal
to a Taylor series expansion to the second-
order term
Heun’s method with a single corrector
(a2=1/2)

 As a2=1/2,
 a1=1-1/2=1/2
 p1=q11=1

FINAL EQUATION
The midpoint method ( a2=1)

 As a2=1
 a1=0
 p1=q11=1/2
Ralston’s method ( a2= 2/3)

 As a2=2/3,
 a1=1-2/3=1/3
 p1=q11=3/4
Second Order Runge Kutta Examples
 Use Heun’s method, the midpoint method and the
Ralston’s method to numerically integrate:

for x=0 to x=4 and inital


conditions (x=0, y=1): (Step
size, h=0.5)
Third order Runge Kutta Methods
 For n=3
Fourth order Runge Kutta Methods
 Most used one:
Higher order Runge Kutta Method
Solving Systems of Equations (ODEs)

n initial conditions with known x values


Example for solving set of ODEs (reference
book)
 Solve the following set of ODEs using Euler’s method and
Runge Kutta Method ( fourth order) when x=0, y1=4 and
y2=6 ( Integrate to x=2 and step size, h=0.5)
CLASS EXERCISE
 Solve the problem below where t=0 to 2 where y(0)=1
with step size h=0.5

 dy/dt= y*t^3-1.5*y

 Solve with:
 Euler’s method
 Midpoint method
 Fourth-Order Runge Kutta Method
NEXT TWO WEEKS
 HW 5 ( 2-3 questions, it will be uploaded on Monday)

 FINAL EXAM:
 Please focus on ( there will be 5 questions):
 - Taylor Series
 - Gauss, Gauss-Jordan, Gauss-Siedel
 - Numerical integration methods ( Trapezoidal rule,
Simpson’s rule..)
 - Euler’s method, Runge Kutta methods…
 -MATLAB

You might also like