Sie sind auf Seite 1von 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.
dv c v - dependent variable
g v
dt m t - independent variable

• 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.
dy
- Linear 1st order ODE    y  f (x )
dx
dy
- Non-Linear 1st order ODE  f ( x, y )
dx
Where f(x,y) is nonlinear
Ordinary Differential Equations

2. A second order equation includes a second


derivative.
d2y dy
- Linear 2nd order ODE 2
 p  Qy  f (x )
dx dx
- Non-Linear 2nd order ODE
2
d y dy
2
 p( x, y )  Q ( x, y )  y  f ( x )
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
• Euler’s Method

solution
Runge-Kutta Methods
Euler’s Method: Example
Obtain a solution between x = 0 to x = 4
with a step size of 0.5 for: dy
 2 x  12 x 2  20 x  8.5
3

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
Euler’s 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 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.

• Simple modifications are available:


– Heun’s Method
– The Midpoint Method
– Ralston’s 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    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 3 h , y i  q 21k 1h  q 22 k 2 h )

k n  f ( x i  p n 1h , y i  q n 1k 1h  q n 1,2 k 2 h    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 Euler’s 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  q11 k1h)
• 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  A value is assumed for one of the
2 unknowns to solve for the other
1 three.
a2 q11 
2
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)

• Raltson’s Method (a2= 2/3)


y
Runge-Kutta Methods
• Heun’s Method:
Involves the determination
of two derivatives for the f(xi+h,yi+k1h)
f(xi,yi)
interval at the initial point x
xi xi+h
and the end point.

y
a

Slope: 0.5(k1+k2)
x
xi xi+h
y
Runge-Kutta Methods
• Midpoint Method:
Uses Euler’s method to predict
a value of y at the midpoint of f(xi+h/2,yi+k1h/2)
f(xi,yi)
the interval: x
xi xi+h/2

a

Slope: k2
x
Chapter 25 xi xi+h
Runge-Kutta Methods y

• Ralston’s Method:

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

y
a

Slope:
(1/3k1+2/3k2)
Chapter 25
xi xi+h x
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

Das könnte Ihnen auch gefallen