You are on page 1of 33

Ordinary Differential Equations (ODEs)

© McGraw Hill 1
Ordinary Differential Equations (ODEs)

• Equations which are composed of an unknown function


and its derivatives are called differential equations.
• 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 v = dependent variable
g v
dt m t = independent variable

© McGraw Hill 2
Mathematical Background
When a function involves one independent variable, the
equation is called an ordinary differential equation (or
ODE). A partial differential equation (or PDE)
involves two or more independent variables.
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.

© McGraw Hill 3
ODEs and Engineering Practice 1

The Swinging Pendulum

Figure PT7.1
Access the text alternative for slide images

© McGraw Hill 4
ODEs and Engineering Practice 2

ENGINEERING: MASS-SPRING SYSTEM

Access the text alternative for slide images

© McGraw Hill 5
CONVERTING HIGHER ORDER ODEs
INTO SYSTEM OF FIRST-ORDER ODEs 1

d 2 x1
m1 2  k x1  k ( x2  x1 )
dt
d 2 x2
m2 2  k ( x2  x1 )  k x2
dt
Define:
dx1 dx2
 v1  v2
dt dt

d 2 x1 dv1 d 2 x2 dv2
2
 2

dt dt dt dt

© McGraw Hill 6
CONVERTING HIGHER ORDER ODEs
INTO SYSTEM OF FIRST-ORDER ODEs 2

dx1
 v1
dt
d 2 x1 dx2
m1 2  k x1  k ( x2  x1 )  v2
dt dt
d 2 x2
m2 2  k ( x2  x1 )  k x2 dv1 k x1  k ( x2  x1 )
dt 
dt m1
dv2 k ( x2  x1 )  k x2

dt m2

© McGraw Hill 7
The Falling Parachutist Problem from
Chapter 1

Figure pt7.2
Access the text alternative for slide images

© McGraw Hill 8
Runga-Kutta Methods Chapter 25

dv cd v v
g
dt m

dv
 f (t , v, g , cd , m)
dt
dv
 f (t , v)
dt

© McGraw Hill 9
RK (RUNGE-KUTTA) METHODS

dy
 f (t , y )
dt

yi 1  yi   h

INCREMENT
FUNCTION

Access the text alternative for slide images

© McGraw Hill 10
Euler’s Method 1

For Euler’s method, the differential equation provides


a direct estimate of the slope at xi (recall Chapter 1)
yi 1  yi  f (ti , yi )h

Figure 25.2
Access the text alternative for slide images

© McGraw Hill 11
Euler’s Method 2

Figure 25.2
Access the text alternative for slide images

© McGraw Hill 12
Euler’s Method 3

• 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
• A new value of y is predicted using the slope to
extrapolate linearly over the step size h.

© McGraw Hill 13
Euler’s Method 4

Figure 25.3
Access the text alternative for slide images

© McGraw Hill 14
Error Analysis for Euler’s Method 1

Numerical solutions of ODEs involves two types of


error:
• Truncation errors.
• Local truncation error. The error incurred on an each step.
f ( xi , yi ) 2
Ea  h
2!
Ea  O(h 2 )
• Propagated truncation error. Errors carried over from step to
step.
• The sum of the two is the total or global truncation error.

• Round-off errors.
© McGraw Hill 15
Error Analysis for Euler’s Method 2

The Taylor series provides a means of quantifying the error in


Euler’s method. However;
• The Taylor series provides only an estimate of the local truncation
error-that is, the error created during a single step of the method.
• In actual problems, the functions are more complicated than
simple polynomials. Consequently, the derivatives needed to
evaluate the Taylor series expansion would not always be easy to
obtain.
In conclusion,
• 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.
© McGraw Hill 16
Error Analysis for Euler’s Method 3

Figure 25.4
(a) Comparison of two
numerical solutions with
Euler’s method using step
sizes of 0.5 and 0.25.

Access the text alternative for slide images

(b) Comparison of true and


estimated local truncation
error for the case where the
step size is 0.5. Note that the
“estimated” error is based
on Equation (E25.2.5).

Access the text alternative for slide images

© McGraw Hill 17
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.
Two simple modifications are available to circumvent this
shortcoming:
• Heun’s Method.
• The Midpoint (or Improved Polygon) Method.

© McGraw Hill 18
Heun’s method 1

One 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 estimate of the slope for the entire interval.

Predictor: yi01  yi  f ( xi , yi )h

f ( xi , yi )  f ( xi 1 , yi01 )
Corrector: yi 1  yi  h
2
© McGraw Hill 19
Heun’s method 2

• Predictor

• Corrector

Figure 25.9
Access the text alternative for slide images

© McGraw Hill 20
Heun’s Method Iteration

Figure 25.10
Access the text alternative for slide images

© McGraw Hill 21
The Midpoint (or Improved Polygon)
Method 1

• Uses Euler’s method to


predict a value of y at the
midpoint of the interval.
• This value is substituted
into the ODE to generate
an improved slope which is
then used to project from
the beginning to the end of
the interval.

Figure 25.12
Access the text alternative for slide images

© McGraw Hill 22
The Midpoint (or Improved Polygon)
Method 2

h
yi 1/2  yi  f (ti , yi )
2

yi 1  yi  f (ti 1/2 , yi 1/2 )h

Access the text alternative for slide images

© McGraw Hill 23
Runge-Kutta Methods (RK) 1

• Runge-Kutta methods achieve the accuracy of a Taylor series


approach without requiring the calculation of higher derivatives.
yi 1  yi   ( xi , yi , h)h

Increment function
  a1k1  a2 k2   an kn
where a’s = constants
k1  f ( xi , yi )
k2  f ( xi  p1h, yi  q11k1h)
k3  f ( xi  p3 h, yi  q21k1h  q22 k2 h)

kn  f ( xi  pn 1h, yi  qn 1k1h
 qn 1,2 k2 h   qn 1,n 1 kn 1 h)
© McGraw Hill 24
Runge-Kutta Methods (RK) 2

• k’s 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.
• First order RK method with n=1 is in fact Euler’s method.
• Once n is chosen, values of a’s, p’s, and q’s are evaluated by setting
general equation equal to terms in a Taylor series expansion.

yi 1  yi  (a1k1  a2 k2 )h
k1  f ( x i , yi )

k2  f ( xi  p1h, yi  q11k1h)
© McGraw Hill 25
Derivation of a Second-order RK Method 1

• Values of a1, a2, p1, and q11 are evaluated by setting the
second-order equation to a second-order Taylor series
expansion. Comparing like terms leads to the following
3 equations to evaluate the 4 unknowns constants.


a1  a2  1
 A value is assumed for one
1
a 2 p1   of the unknowns to solve
2
for the other three.
1
a2 q11  
2
© McGraw Hill 26
Derivation of a Second-order RK Method 2

Because 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).
Three of the most commonly used methods are:
• Heun Method with a Single Corrector (a2=1/2).
• The Midpoint Method (a2=1).
• Ralston’s Method (a2=2/3).
© McGraw Hill 27
Derivation of a Second-order RK Method 3

Figure 25.14

Access the text alternative for slide images

© McGraw Hill 28
Systems of Equations
• Many practical problems in engineering and science require the
solution of a system of simultaneous ordinary differential
equations rather than a single equation:
dy1
 f1  x, y1 , y2 , , yn 
dx
dy2
 f 2  x, y1 , y2 , , yn 
dx

dyn
 f n  x, y1 , y2 , , yn 
dx
• Solution requires that n initial conditions be known at the starting
value of x.
© McGraw Hill 29
Adaptive Runge-Kutta Methods
• For an ODE with an
abrupt changing
solution, a constant
step size can
represent a serious
limitation.

Figure 25.20
Access the text alternative for slide images

© McGraw Hill 30
Step-Size Control of Runge-Kutta
Methods 1

• 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:

 new
hnew  hpresent
 present

Δpresent = computed present accuracy


Δnew = desired accuracy
α = a constant power that is equal to 0.2 when step size increased
and 0.25 when step size is decreased

© McGraw Hill 31
Step-Size Control of Runge-Kutta
Methods 2

• 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.

© McGraw Hill 32
The Results of Adaptive Step-Size Control

Figure (a) A bell-shaped forcing function that induces an abrupt change in the solution of an ODE
[Eq. (E25.14.1)]. (b) The solution. The points indicate the predictions of an adaptive
step-size routine.
© McGraw Hill 33

You might also like