Chapter-8 ODE PDF
Chapter-8 ODE PDF
ORDINARY DIFFERENTIAL
EQUATIONS (ODE)
Chapter 8 : TOPIC COVERS
(ORDINARY DIFFERENTIAL EQUATIONS)
Runge-Kutta Methods
Heun’s Method
Indicate the visual representation of Euler’s, Heun’s and the midpoint methods
Clarify the relationship of Euler’s method to the Taylor series expansion
Define the basis of predictor-corrector methods and realize that the efficiency
of the corrector is highly dependent on the accuracy of the predictor
Derive second-order RK method and how it relates to the Taylor series
expansion
• Apply any of the RK methods to systems of equation
• Application in Chemical Engineering
CHAPTER 8: ORDINARY DIFFERENTIAL EQUATIONS (ODE)
8.1 Introduction
dv cV
g - - - - - - - - (1)
dt m
where; g = gravitational constant
m = mass
c = drag coefficient
dv/dt = unknown function/differential equation (rate equation)
We called as rate equation because express the rate of change of a variable.
From equation (1), V = dependent variable
t = independent variable
When function involves one independent variable, the equation is called Ordinary
Differential Equation (ODE).
Partial Differential Equation (PDE); involves two or more independent
variables.
The fundamental laws of physics, mechanics, electricity, and
thermodynamics are usually based on empirical (experimentally)
observations that explain variations in physical properties and states of
systems.
The laws are usually expressed in terms of spatial (space) and temporal
(time) changes.
As shown in Table 1: These laws define mechanisms of change. When
combined with continuity laws for energy, mass or momentum, resulting in
differentiation equation. Subsequent, by integration of these differential
equations results in mathematical functions.
For example: Recall Newton's second law of falling parachutist was used to
develop an ODE. By integrating this relationship, we obtained an equation
to predict fall velocity as a function of time (see Fig.7.1).
However, as described in previous chapter, many of differential equations of practical
significant cannot be solve using analytical methods of calculus.
Thus, in this chapters are important as Numerical approaches for solving engineering
application.
Table 1: Examples of fundamental laws in terms of rate of change of variables (t = time,
x = position)
dv F V=velocity
Newton’s 2nd
Law of motion
F=force
m=mass
dt m
q=heat flux
dT
Fourier’s heat law q k ' k’=thermal conductivity
T=temp.
dx
Fick’s law of dc J=mass flux
Diffusion J D D=diffusion coefficient
dx c=concentration
di VL=voltage drop
Faraday’s law V L L L=inductance
dt i=current
Fig. 8.1: Application of ODE’s for engineering problem solving.
F ma (Physical Law)
dv c
g v (ODE)
dt m
Analytical Numerical
gm c
v (1 e ( c / m )t ) vi 1 vi ( g vi )t
c m
SOLUTION SOLUTION
8.2 One-Step Method
f ( xi , yi ) ------- (4)
where ;
f ( xi , yi ) = differential equation evaluated at xi and yi
yi 1 yi f ( xi , yi )h ------- (5)
Solution:
From Euler’s method equation; yi 1 yi f ( xi , yi )h
Substituted all the data given;
y(0.5) = y(0) + f(0,1)0.5 equation of Euler’s method
where; y(0) = 1,
and the slope at x = 0 is,
f(0,1) = -2(0)3 + 12 (0)2 + 20(0) + 8.5 = 8.5
Thus; y(0.5) = 1.0 + 8.5(0.5) = 5.25
True solution at x = 0.5 ;
y = -0.5(0.5)4 + 4(0.5)3 – 10(0.5)2 + 8.5(0.5) + 1
= 3.21875
The true solution at x = 1.0 is 3.0, and therefore, the percentage relative
error is –95.8%.
The computation is repeated, and the results are complied in Table 2 and Fig. 8.4
Although the computation captures the general trend of the true solution, the
error is considerable.
As discussed in the next section, this error can be reduced by using a smaller step
size.
Table 2: Comparison true and approximation values
x ytrue yEuler t %Global t %Local
Note: Global error is the total differences between past and present steps.
Local error is calculated with a Taylor series expansion (shows by Example 25.2 in
the Text book)
Fig. 8.4a: Comparison of curve true
solution with numerical
solution using Euler’s Method (with
step size h = 0.5)
Fig. 8.4b: Comparison of curve
true solution with numerical
solution using Euler’s Method
with different step size (h)
0.25 and 0.5
8.4 Error Analysis for Euler’s Method
Sum of the two truncation errors is called as Global or Total Truncation Error.
f ' ( xi , yi ) 2 f ( n1) ( xi , yi )h n
yi 1 yi f ( xi , yi )h h ....... 0(h n1 ) (4)
2! n!
where; 0(hn+1) = local truncation error which is proportional to step size raised to the
(n+1)’th power
Equation (4) substituted into Euler’s Method equation (to calculate true local
truncation error for Euler Method);
f ' ( xi , yi ) 2
Et h ...... 0(h h 1 ) (5)
2!
where; Et = true local truncation error
For small of h ; (eliminated term 0(hh+1)
f ' ( xi , yi ) 2
Ea h (6)
2!
or
Ea 0(h 2 ) (7)
where; Ea = approximate local truncation error
Example 2: Taylor Series Estimate for Error of Euler's Method.
Use the true local truncation error to estimate the error of the 1st step of
Example 1. Also use it to determine the error due to each higher-order
term of the Taylor Series expansion.
Solution:
Since we have polynomial equation, we use Taylor Series to obtain exact
estimate of the errors in Euler’s Method;
From equation (5)
f ' ( xi , yi ) 2 f " ( xi , yi ) 3 f (3) ( xi , yi ) 4
Et h h h
2! 3! 4!
where; f’ (xi , yi ) = first derivative of the differential
equation (2nd derivative of the solution)
From Example 1; dy/dx = -2x3 + 12x2 –20x + 8.5
Thus; f’ (xi , yi ) = -6x2 + 24x - 20
f’’ (xi , yi ) = -12x + 24
f3 (xi , yi ) = -12
We ignore 4th and higher derivative because in this case they equal to zero.
Thus; Error due to truncation :
i. For second-order term; 1st derivative
f ' ( xi , yi ) 2
Et , 2 h
2!
6(0) 2 24(0) 20
Et , 2 (0.5) 2 2.5
2
ii. For third-order term;
f " ( xi , yi ) 3
Et ,3 h
3!
12(0) 24
Et ,3 (0.5)3 0.5
6
iii. For fourth-order term;
f (3) ( xi , yi ) 4
Et , 4 h
4!
12
Et , 4 (0.5) 4 0.03125
24
Et Et , 2 Et ,3 Et , 4
2.5 0.5 0.03125
2.03125
The value of Et = -2.03125 is exactly the error in the initial step of Example 1.
8.5 Improvements of Euler's Method
Can be divided into 2 types;
a. Huen's Method
b. Mid-point Method (Improve Polygon Method)
yi' y 'i 1
y'
2
f ( xi , yi ) f ( xi 1 , y o i 1 )
(11)
2
From an average slope of equation (11), extrapolate linearly from yi to
yi+1 using Euler’s Method: yi 1 yi f ( xi , yi )h
f ( xi , yi ) f ( xi 1 , y o i 1 )
yi 1 yi h (12)
2
j 1
y j
y
a i 1 i 1
100%
yij1
4 0.8 x 0.5 x
y (e e ) 2e 0.5 x
1.3
f ( xi , yi ) f ( xi 1 , y o i 1 )
y'
2
(3) (6.402164)
y' 4.701082
2
Step 5 : Corrector (equation 12);
f ( xi , yi ) f ( xi 1 , y o i 1 ) or
yi 1 yi h (12)
2 y1 yo h
2 4.701082(1)
6.701082
Thus; 6.1946314 6.701082
t % 100%
6.1946314
True value
8.18%
Step 6 : repeat step 3 through step 5
Step 3: f(xi+1 , yi+1) = f(1 , 6.701082)
= 4e 0.8(1) - 0.5 (6.701082)
= 5.551622714
Step 4 : slope average;
3 5.551622714
y' 4.275811357
2
Step 5: corrector equation;
y1 = yo + h
= 2 + 4.275811357(1)
= 6.275811357
Thus; 6.1946314 6.275811
t % 100%
6.1946314
1.31%
3 4e 0.8(1) 0.5(6.2758(1)
y1 2 (1)
2
6.382129
thus;
t % 3.03
t% increasing when iteration increase. It happen especially for large step
size. For small step size, the iteration coverage (directing) on a single value.
For our case, if step 3 to 5 are repeated at iteration 15;
We get y1 = 6.3608655 and εt% = 2.68
Fig. 8.7: Comparison of true
solution with numerical solution
using Euler's and Heun's method for
y' = -2x3+12x2 -20x +8.5
8.5.2 Midpoint Method (Improved Polygon Method)
y f (x ,y )
1 1 1
i i i
2 2 2
y y x 2 1.2y
for range x = 0 to 2 and h = 0.5 where y(0) = 1 (initial values).
Solution:
At, x = 0, y = 1
x = 0.5 (step size, h = 0.5)
h
(a) y 1 y i f (x i , y i )
i
2
2
0.5
y 1 1 f (0,1)
i
2
2
f (0,1) (1)(0) 2 1.2(1) 1.2
0.5
y 1 1 (1.2) 0.7
i
2
2
(b) slope:
y f (x ,y ) f (0.25,0.7)
1 1 1
i i i
2 2 2
(c) y i+1
y i1 y i f (x 1 ,y 1 )h
i i
2 2
. . . . Repeat steps (a) through (c) for a range x = 0 to 2 with step size, h = 0.5
8.6 Runge-Kutta Method (RK method)
This 2nd order RK method actually is the Heun's technique without iteration.
b. Midpoint / Improve Polygon method
(assume a2 = 1)
If a2 is assumed to be 1.0 from equation (25) and (26) can be solved;
a1 = 0 ----- (30)
p1 = q11 = 1/2 -------- (31)
Substituted into equation (15) to yield;
yi+1 = yi + k2h ----- (32)
where; k1 = f (xi , yi) ------- (32a)
k2 = f (xi + 1/2h , yi + 1/2k1h) ------ (32b)
c. Ralston's method (assume a2 = 2/3)
If a2 is assumed to be 1/2 from equation (25) and (26) can be solved;
a1 = 1/3 ----- (33)
p1 = q11 = 3/4 -------- (34)
dy1
f1 (x, y1, y 2 ,....., y n )
dx
dy 2
f 2 (x, y1, y 2 ,....., y n )
dx
dy n
f n (x, y1, y 2 ,....., y n )
dx
The solution of such a system requires that n initial conditions be known at the
starting value of x.
Example of the ODE:
Solve the following set of ODEs using Euler’s method, assuming at x = 0,
y1 = 4 and y2 = 6. Integrate to x = 2 with a step size of 0.5.
dy1
0.5 y1 Euler’s method
dx
yi 1 yi f ( xi , yi )h
dy2
4 0.3 y2 0.1 y1
dx
Solution:
Euler’s method is implemented for each variable:
Thus;
y1 (0.5) 4 [0.5(4)]0.5 3
y2 (0.5) 6 [4 0.3(6) 0.1(4)]0.5 6.9
Note that y1(0) = 4 is used in the second equation rather than the
y1(0.5) = 3 computed with the first equation. Proceeding in a like
manner gives:
x y1 y2
0 4 6
0.5 3 6.9
1.0 2.25 7.715
1.5 1.6875 8.44525
2.0 1.265625 9.094087
CASE STUDIES: Application in Chemical Engineering
Ordinary Differential Equations (ODE) : Case Study
The rate of heat flow between two points on a cylinder heated at one end is
given by:
dQ B( L x)(20 t )
A
dt 100 xt