Ch25 Runge Kutta Method0

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

PART 7

Ordinary Differential
Equations ODEs

Ordinary Differential Equations


Part 7

Equations which are composed of an


unknown function and its derivatives are
called differential equations.
v - dependent variable
dv
c
g v
t - independent variable
dt
m
Differential equations play a
fundamental role in engineering
because many physical phenomena are
best formulated mathematically in terms
of their rate of change.

Ordinary Differential
Equations
When a function involves one dependent
variable, the equation is called an ordinary
differential equation (ODE).

A partial differential equation (PDE) involves


two or more independent variables.

Ordinary Differential Equations


Differential equations are also classified as to
their order:
1. A first order equation includes a first derivative as
its highest derivative.
- Linear 1 order ODE
st

dy
y f (x )
dx

dy
- Non-Linear 1 order ODE
f ( x, y )
dx
Where f(x,y) is nonlinear
st

Ordinary Differential Equations


2. A second order equation includes a second
derivative.
2
d
y
dy
nd
p Qy f (x )
- Linear 2 order ODE
2
dx
dx
- Non-Linear 2nd order ODE
2

d y
dy
p ( x, y ) Q ( x, y ) y f ( x )
2
dx
dx
Higher order equations can be reduced to a system
of first order equations, by redefining a variable.

Ordinary Differential Equations

Runge-Kutta Methods
This chapter is devoted to solving ODE of the
form:

dy
f ( x, y )
dx

Eulers Method

solution

Runge-Kutta Methods

Eulers Method: Example


Obtain a solution between x = 0 to x = 4
dy
with a step size of 0.5 for:
2 x 3 12 x 2 20 x 8.5

dx

Initial conditions are: x = 0 to y = 1

Solution:

y (0.5) y (0 ) f (0,1).(0.5)
1.0 8.5 x0.5 5.25

y (1.0 ) y (0.5) f (0.5,5.25).(0.5)


5.25 ( 2(0.5)3 12(0.5) 2 20(0.5) 8.5).(0.5) 5.875
y ( 2.0 ) y (1.0 ) f (1.0,5.875 ).(0.5)
5.25 ( 2(1.0 )3 12(1.0 ) 2 20(1.0 ) 8.5).(0.5) 5.125

Eulers Method: Example


Although the computation captures the
general trend solution, the error is
considerable.
This error can be reduced by using a smaller
step size.

Improvements of Eulers
method

A fundamental source of error in Eulers


method is that the derivative at the
beginning of the interval is assumed to
apply across the entire interval.
Simple modifications are available:
Heuns Method
The Midpoint Method
Ralstons Method

Runge-Kutta Methods
Runge-Kutta methods achieve the accuracy of a
Taylor series approach without requiring the
calculation of higher derivatives.
y i 1 y i (x i , y i , h )h
Increment function
a1k 1 a2 k 2 L an k n
(representative slope
a ' s constants
over the interval)
k 1 f (x i , y i )

k 2 f (x i p1h , y i q11k 1h )
k 3 f (x i p 3h , y i q 21k 1h q 22 k 2 h )
M
k n f (x i p n 1h , y i q n 1k 1h q n 1,2 k 2 h L q n 1,n 1k n 1h )
p ' s and q ' s are constants

Runge-Kutta Methods

Various types of RK methods can be devised by


employing different number of terms in the
increment function as specified by n.
1. First order RK method with n=1 is Eulers
method.

Error is proportional to O(h)

2. Second order RK methods:


- Error is proportional to O(h2)

yi 1 yi (a1k1 a2 k 2 )h

k1 f ( x i , yi )
k 2 f ( xi p1h, yi q11k1h)

Values of a1, a2, p1, and q11 are evaluated by setting


the second order equation to Taylor series expansion
to the second order term.

Runge-Kutta Methods
Three equations to evaluate the four unknown
constants are derived:
a1 a2 1
1
a 2 p1
2
1
a2 q11
2

A value is assumed for one of the


unknowns to solve for the other
three.

Runge-Kutta Methods
1
1
a1 a2 1, a 2 p1 , a2 q11
2
2

We can choose an infinite number of values for


a2,there are an infinite number of second-order
RK methods.
Every version would yield exactly the same
results if the solution to ODE were quadratic,
linear, or a constant.
However, they yield different results if the
solution is more complicated (typically the case).

Runge-Kutta Methods
Three of the most commonly used methods
are:
Huen Method with a Single Corrector
(a2=1/2)

The Midpoint Method (a2= 1)

Raltsons Method (a2= 2/3)

Runge-Kutta Methods
y

Heuns Method:
Involves the
determination of two
derivatives for the
interval at the initial
point and the end point.

f(xi,yi)
xi

f(xi+h,yi+k1h)
xi+h

y
a
Slope: 0.5(k1+k2)
xi

xi+h

Runge-Kutta
Methods

Midpoint Method:

Uses Eulers method to predict


a value of y at the midpoint of
the interval:

f(xi,yi)
xi

f(xi+h/2,yi+k1h/2)
x
xi+h/2

y
a
Slope: k2
Chapter 25

xi

xi+h

Runge-Kutta Methods

Ralstons Method:
f(xi,yi)
xi

f(xi+ 3/4 h,
yi+3/4k1h)
xi+3/4h
x

y
a
Slope:
(1/3k1+2/3k2)
Chapter 25

xi

xi+h

Chapter 25

22

Runge-Kutta Methods
3. Third order RK methods

Chapter 25

Runge-Kutta Methods
4. Fourth order RK methods
1
yi 1 yi (k1 2k 2 2k3 k 4 )h
6
where
k1 f ( x i , yi )
1
1
k 2 f ( xi h, yi k1h)
2
2
1
1
k3 f ( xi h, yi k 2 h)
2
2
k3 f ( xi h, yi k3h)
Chapter 25

Comparison of Runge-Kutta
Methods
Use first to fourth order RK methods to solve the
equation from x = 0 to x = 4
Initial condition y(0) = 2, exact answer of y(4) =
75.33896

f ( x , y ) 4e

0 .8 x

0.5 y

Chapter 25

You might also like