You are on page 1of 28

# Chapter 6

DIFFERENTIAL
EQUATIONS : ORDINARY
DIFFERENTIAL EQUATIONS
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Ordinary Differential
Equations
Equations which are composed of an
unknown function and its derivatives are
called differential equations.
Play a fundamental role in engineering
because many physical phenomena are
best formulated mathematically in terms of
their rate of change.

dv
c
g v
dt
m

v- dependent variable
t- independent
variable

Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

## When a function involves

- one independent variable an ordinary
differential equation (or ODE).
- two or more independent variables a partial
differential equation (or PDE).

## Differential equations are also classified as

to their order.
A first order equation includes a first derivative
as its highest derivative.
A second order equation includes a second
derivative.

## Higher order equations can be reduced to a

system of first order equations, by
redefining a variable.
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

EULERS METHOD

## The first derivative provides a direct estimate of

the slope at xi

f ( xi , yi )
where f(xi,yi) is the differential equation
evaluated at xi and yi.
This estimate can be substituted into the
equation:

yi 1 yi f ( xi , yi )h

Eulers formula

## A new value of y is predicted using the slope to

extrapolate linearly over the step size h.
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Example 1
Use Eulers method to numerically integrate
dy 1 x 1

dx 4 y
from x=0 to x=2 with a step size of 0.5. The
initial condition at x=0 is y=1. Compare
the results with the true value.

## by Lale Yurttas, Texas

A&M University

ytrue

0.0

1.0000

0.5

1.1456

1.0

1.3229

1.5

1.5207

2.0

1.7321
Chapter 6

Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Figure 25.3

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Method

## Two types of error:

Truncation error

f ( xi , yi ) 2
Ea
h
2!
Ea O ( h 2 )

Round-off errors

Solution:
the error can be reduced by reducing the step
size
If the solution to the differential equation is linear,
the method will provide error free predictions as for
a straight line the 2nd derivative would be zero.
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Figure 25.4

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

IMPROVEMENTS OF
EULERS METHOD
Source of error in Eulers method is the
derivative at the beginning of the interval
is assumed to apply across the entire
interval.
Two simple modifications are available to
avoid this weakness:
Heuns Method
The Midpoint (or Improved Polygon) Method

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

10

HEUNS METHOD
Predictor-corrector approach.
Method to improve the estimate of the
slope involves the determination of two
derivatives for the interval:
At the initial point
At the end point

## The two derivatives are then averaged to

obtain
an: improved
Predictor
yi01 yi estimate
f ( xi , yi )h of the slope
for the entire interval.
f ( xi , yi ) f ( xi 1 , yi01 )
Corrector : yi 1 yi
h
2
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

11

Example 2
Use Heuns method to numerically integrate
dy 1 x 1

dx 4 y
from x=0 to x=2 with a step size of 0.5. The
initial condition at x=0 is y=1. Compare
the results with the true value.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

12

Figure 25.9

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

13

Figure 25.10

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

14

## The Midpoint Method

(or Improved Polygon)
Uses Eulers method to predict a value of y at
the midpoint of the interval:
yi 1/ 2

h
yi f ( xi , yi )
2

## This value is used to estimate the value of

slope over the interval:

yi 1 yi f ( xi 1/ 2 , yi 1/ 2 )h
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

15

Example 3
Use improved polygon method to
numerically integrate
dy 1 x 1

dx 4 y
from x=0 to x=2 with a step size of 0.5. The
initial condition at x=0 is y=1. Compare
the results with the true value.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

16

Figure 25.12

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

17

RUNGE-KUTTA METHODS
(RK)

## Runge-Kutta methods achieve the

accuracy of a Taylor series approach
without requiring the calculation of
higher
derivatives.
y y ( x , y , h) h
i 1

## a1k1 a2 k 2 an k n Increment function

a ' s constants
k1 f ( xi , yi )
ps and qs are constants
k 2 f ( xi p1h, yi q11k1h)
k3 f ( xi p3 h, yi q21k1h q22 k 2 h)

## k n f ( xi pn 1h, yi qn 1k1h qn 1, 2 k 2 h qn 1,n 1k n 1h)

18
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

## ks are recurrence functions. Because each k is a

functional evaluation, this recurrence makes RK
methods efficient for computer calculations.
Various types of RK methods can be devised by
employing different number of terms in the
increment function as specified by n.
Once n is chosen, values of as, ps, and qs are
evaluated by setting general equation equal to
terms in a Taylor series expansion.
First order RK method with n=1 is in fact Eulers
method.
by Lale Yurttas, Texas
A&M University

19
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Second-order RK Methods
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. Three
aevaluate
equationsa1to
four unknowns constants
2 1
A value is assumed for
are derived. 1
a 2 p1
one of the unknowns to
2
solve for the other three.
1
a2 q11

## by Lale Yurttas, Texas

A&M University

Chapter 25

Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

20

## Three of the most commonly used methods

are:
1
1with a Single Corrector (a2=1/2)
Huen
yi 1 yMethod

(
k

k 2 )h
i
1
2
k1 f ( x i , yi )

k 2 f ( xi h, yi k1h)
yi 1 Midpoint
yi k 2 h
The
Method (a2=1)
k1 f ( x i , yi )

1
1
k 2 f ( xi h, yi k1h)
2
2
1
2
y

(
k

k 2 )h (a =2/3)
i 1
i
1
Raltsons
Method
2
3
3
k1 f ( x i , yi )
3
3
k 2 f ( xi h, yi k1h)
4
4
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

21

Third-order RK Methods
1
yi 1 yi (k1 4k 2 k3 )h
6
k1 f ( x i , yi )
1
1
k 2 f ( xi h, yi k1h)
2
2
k3 f ( xi h, yi k1h 2k 2 h)

Fourth-order RK Methods
1
yi 1 yi (k1 2k 2 2k3 k 4 )h
6
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
k 4 f ( xi h, yi k3 h)
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

22

Example 4
Use the Ralstons method (2nd-order RK), 3rd-order
RK method and 4th-order RK method to numerically
integrate
dy 1 x 1

dx 4 y
from x=0 to x=2 with a step size of 0.5. The initial
condition at x=0 is y=1. Compare the results with
the true value.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

23

Figure 25.14

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

24

ADAPTIVE
RUNGE-KUTTA METHODS
For an ODE with an
abrupt changing
solution, a constant
step size can
represent a serious
limitation.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Figure 25.20

25

Step-Size Control
The strategy is to increase the step size if the error is
too small and decrease it if the error is too large.
Press et al. (1992) have suggested the following
criterion to accomplish this:

hnew h present

new
present

## Dpresent= computed present accuracy

Dnew= desired accuracy
a= a constant power that is equal to 0.2 when step
size
increased and 0.25 when step size is
decreased
by Lale Yurttas, Texas
A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

26

## Implementation of adaptive methods

requires an estimate of the local
truncation error at each step.
The error estimate can then serve as a
basis for either lengthening or decreasing
step size.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

27

Example 5
Use the adaptive 4th-order RK method to
numerically integrate

dy 1 x 1

dx 4 y

## from x=0 to x=2 with a step size of 0.5. The initial

condition at x=0 is y=1. Compare the results with
the true value.

## by Lale Yurttas, Texas

A&M University

Chapter 6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

28