Example:
The velocity of a free-falling bungee jumper can be described
by Newtons second law:
Eulers Method dv cd v is an unknown
g v
Error analysis for Eulers method dt m function of t
Stability of Eulers method acceleration
where g is the gravitational constant, m
Second-Order Runge-Kutta Method
is the mass, and cd is a drag coefficient.
Classical Fourth-Order Runge-Kutta Method
=> differential equations, rate equations
Eulers method
Runge-Kutta method
1. Overview
Equations which are composed of an unknown function and its
derivatives are called differential equations.
When a function involves one dependent variable, the equation
is called an ordinary differential equation (or ODE):
dy How?
f t y y is an unknown function of t
dt
A partial differential equation (or PDE) involves two or more
independent variables.
Differential equations play a fundamental role in engineering
The sequence of events in the development and solution of ODEs for engineering and
because many physical phenomena are best formulated science. The example shown is for the velocity of the free-falling bungee jumper.
mathematically in terms of their rate of change.
dv cd
g v
dt m
dy
f t y
dt
y t
Remember the finite
divided difference?
Eulers Method
Runge-Kutta Method (RK)
Differential equations are also classified as to their order: 2. Eulers method
dy
A first order equation includes a first derivative as its highest f ty
derivative; dt
A second order equation includes a second derivative. For
example, the equation describing the position x of an unforced yi yi h where the slope is called as increment function
mass-spring system is:
f ti yi the slope is estimated by the first derivative
d x dx
m c kx
dt dt
Higher order equations can be reduced to a system of first yi yi f ti yi h
order equations by redefining a variable:
Eulers method Euler-Cauchy
dx point-slope method
v
dt d x
dv c k dt v y
v x h
dt m m
2.1 Eulers method Continue:
Then, the Eulers method is implemented as
y y f
where y(0)=2 and the slope estimate at t=0 is
f e
Therefore, y(1)=2+3 1=5.
The true solution at t=1 is
y e e e
ti t t
Thus, the percent relative error is
yi yi f ti yi h t
Example-1: Continue:
y y t e t
y y f
t y
Note that the exact solution can be determined analytically as
t t t
y e e e
Solution:
ti
f ti yi e yi
Continue:
Comparison of true and numerical values of the integral of dy
ODE: f ty
y = 4e0.8t 0.5y, with the initial condition that y = 2 at t = 0. The dt
numerical values were computed using Eulers method with a step
Taylor series expansion about a starting value (ti, yi) can be
size of 1.
written as:
h n hn
yi yi f ti yi h f ti yi f ti yi O hn
n
=> Local truncation error of Eulers method is:
f xi yi
Ea h or Ea Oh
Hence, the Eulers method is a first-order method.
Error propagates
2.2 Error Analysis for Eulers Method
Some conclusions:
Numerical solutions of ODEs involves two types of errors: The global error (sum of the two error) can be reduced by
Truncation errors decreasing the step size.
: errors caused by the nature of the techniques employed to
approximate values
Local truncation error (results from a single step calculation)
Propagated truncation error (results from previous steps)
Round-off errors
: errors caused by the limited numbers of significant digits that can
be retained by a computer The method will provide error-free predictions if the underlying
function (i.e., the solution of the differential equation) is linear,
because for a straight line the second derivative would be zero.
2.3 Stability of Eulers Method
yi yi ah
The stability of a solution method is another important
consideration that must be considered when solving ODEs. The parenthetical quantity (1 ah) is called an amplification
A numerical solution is said to be unstable if errors grow factor. If its absolute value is greater than unity, the solution will
exponentially for a problem for which there is a bounded grow in an unbounded fashion;
solution. Clearly, the stability depends on the step size h. That is,
The stability of a particular application can depend on three if , i.e., , oscillates and as ;
factors:
Based on this analysis, Eulers method is said to be conditionally
the differential equation stable;
the numerical method If the errors always grow regardless of the method, the ODE is
the step size. called as ill-conditioned.
In order to have insight into the step size required for stability,
3. Runge-Kutta methods
one can study a very simple ODE: increment function yi yi h
dy Bounded if
ay
dt ak ak an kn
at
whose analytical solution is y y e when y(0)=y0. ai ki
The formula of Eulers method is k f ti yi
dyi k f ti p h yi q kh
yi yi h
dt k f ti p h yi q kh q k h
yi a yi h
yi ah kn f ti pn h yi qn k h qn k h qn n kn h
that is, k1 appears in the
yi+1
equation for k2, which appears in the equation for k3, and
f ti yi
so forth yi yi f ti yi h h
f ti yi f ti yi dy h
yi yi f ti yi h
t y dt
n=1 Eulers method.
k
n=2 second-order RK methods k f ti p h yi q k h
n=4 fourth-order RK methods f ti yi f ti yi Taylor series expansion
f ti yi ph q kh for multivariate function
t y
3.1 Second-Order Runge-Kutta Method
yi yi ak ak h
f ti yi f ti yi
yi a f ti yi a f ti yi ph q kh h
t y
yi yi ak ak h f ti yi f ti yi
yi a a f ti yi h a p a q f ti yi h
t y
k f ti yi
f ti yi f ti yi h
yi yi f ti yi h f ti yi
k f ti p h yi q kh t y
a a
=> How to determine the constants: a1, a2, p1, q11 ?
a p => undetermined : 3 equations - 4 unknowns
aq
3.2 Classical Fourth-Order Runge-Kutta Method
a2
classical fourth-order RK method
yi yi k k k k h
Heuns Method (a2=1/2)
The Midpoint Method (a2=1)
k f ti yi
Ralstons Method (a2=2/3)
k f ti h yi kh
k f ti h yi kh
k f ti h yi kh
Heuns Method
a2 1/2
a p q
yi yi k k h
k f ti yi
k f ti h yi kh
Continue:
t
y = + =
improved average slope k3 = f = e 0.5 =
k
weighted
average
y
k f e
Example-2: Continue:
y e
y t y
Solution:
= =
yRK = =
k1 = f =4e =
y
t = 0.103%
y(0.5) = 2 + =
k2 = f = 4e =
4. System of equations Example-3:
t x v
dy t s s
f t y y yn
dt
dy
f t y y yn
dt
dyn gm gcd m gcd
fn t y y yn vt t xt t
dt cd m cd m
n
t
cd m g
4.1 Eulers method ( for systems of equations) Solution:
dx
v
dt
dv cd
g v
dt m
t
dx dv
dt dt
t
xEuler =x = , vEuler v =
x v
Continue: Example-4:
t
xEuler
dx
f t xv v
vEuler dt
dv cd
f t xv g v
dt m
Solution:
k f
k f
ki, j i- k j
Continue :
4.2 Runge-Kutta Methods ( for systems of equations)
x v
h
xrk x k
k
h
k vrk v k
k f
k k f
k
h
k xrk x k
k h
vrk v k
k
k k f
k f
Continue :
Questions:
1) What is the ordinary differential equations (ODEs)?
xrk x k h
2) How to transfer a higher-order differential equations into a system of
vrk v k h first-order equations?
3) How to use Eulers method for calculating the ordinary differential
k f equations?
4) How to analyze the stability of Eulers method?
k f
5) What is the Runge-Kutta method and its difference with Eulers method?
k 6) What is the Heun Method?
7) How to use classical fourth-order Runge-Kutta method for solving
xRK
ODEs?
8) How to use Eulers method to solve a system of equations?
vRK
9) How to employ Runge-Kutta method to solve a system of equations?
Continue :
Reference:
pp. 323
(pp. 335)
pp. 339
In contrast to the results obtained with Eulers method, the fourth-
order RK predictions are much closer to the true values.
A highly accurate, nonzero value is computed for distance on the
first step.