Professional Documents
Culture Documents
CE 205: Numerical Methods: Odi Diff Til Ordinary Differential Equations Equations
CE 205: Numerical Methods: Odi Diff Til Ordinary Differential Equations Equations
Ordinary
O di Diff
Differential
ti l
Equations
Motion of a swinging pendulum
d 2θ g
2
+ sin θ = 0
dt l
Bungee‐jumper
j
Equation
dv cd 2
= g− v
dt m
dv
d cd 2
= g− v ODE
dt m
Analytical Numerical
⎛ gc ⎞ ⎡ 2⎤
Solution
v(ti +1 ) = v(ti ) + ⎢ g − d v(ti ) ⎥ (ti +1 − ti )
gm c
v(t) = tanh⎜ d
t⎟
cd ⎝ m ⎠ ⎣ m ⎦
Independent variable: spatial or temporal
CE 205: Numerical Methods Dr. Tanvir Ahmed
Initial value and boundary value problems
Boundary Value problems: Solve
General Solution
Applying B.C.
Initial Value problems: Solve
General Solution
Applying I.C.
l
Techniques:
‐ Euler
‐ Heun
‐ Midpoint
Fourth‐Order
‐ Fourth Runge‐Kutta
Order Runge Kutta
CE 205: Numerical Methods Dr. Tanvir Ahmed
Euler’s Method
The first derivative provides a direct estimate of the
slope at ti:
slope at t
dy
= f (t i , yi )
dt ti
Euler method uses that
Euler method uses that
estimate as the increment
function:
φ = f (t i , yi )
yi+1 = yi + f (t i , yi )h
The numerical solution of ODEs involves two types of
yp
error:
‐ Truncation errors, caused by the nature of the techniques employed
‐Roundoff
Roundoff errors, caused by the limited numbers of significant digits that can
errors caused by the limited numbers of significant digits that can
be retained
The total, or global truncation error can be further split
into:
‐ local truncation error that results from an application method in question
over a single step, and
‐ propagated truncation error that results from the approximations
produced during previous steps.
Global error can be reduced by decreasing the step size
CE 205: Numerical Methods Dr. Tanvir Ahmed
Improvement of Euler’s Method
Main limitation: the derivative at the beginning of the
interval is assumed to apply across the entire interval
Two modifications can be made:
(1) Heun’s method
(2) Mid‐point method
CE 205: Numerical Methods Dr. Tanvir Ahmed
Heun’s Method (Predictor‐corrector approach)
Determine derivatives at the beginning and predicted
ending of the interval and average them to obtain an
i
improved estimate of the slope
d i f h l
The increment function φ can be generally written as
φ = a1k1 + a2 k2 +L+ an kn
k1 = f (t i , yi )
k2 = f (t i + p1h, yi + q11k1h)
k3 = f (t i + p2 h, yi + q21k1h + q22 k2 h)
M
kn = f (t i + pn−1h,
h yi + qn−1,1k1h + qn−1,2 k2 h +L+ qn−1,n−1kn−1h)
a’s, p’s
, p and q’s
q are constants
where
k1 = f (t i , yi )
⎛ 1 1 ⎞
k2 = f ⎜t i + h, h yi + k1h ⎟
⎝ 2 2 ⎠
⎛ 1 1 ⎞
k3 = f ⎜t i + h, h yi + k2 h ⎟
⎝ 2 2 ⎠
k4 = f (t i + h, yi + k3h)
n initial conditions be known at the starting value of t.
One‐step method is applied for every equation at each
step before proceeding to the next step
step before proceeding to the next step
‐Euler’s method
‐4th order R‐K
Adaptive algorithms can
change step‐size depending
on the region
‐Step‐halving
S h l i
‐Performing two RK predictions of
different order
Conditions are not
C di i
known at a single point
but rather are given at
but rather are given at
different values of the
independent variable
independent variable
Boundary Conditions:
y
‐values of variables
‐values of derivatives of variables
d 2T
2
+ h′(T∞ − T ) = 0
dx
Bo ndar conditions
Boundary conditions: T (0) = T1 = 40, T ( L) = T2 = 200
L = 10m Ta = 20 h′ = 0.01m −2
Analytical solution:
FFor linear ODEs, only two “shots” are required ‐
li ODE l t “h t” i d the
th
proper initial condition can be obtained as a linear
interpolation of the two guesses
interpolation of the two guesses.
CE 205: Numerical Methods Dr. Tanvir Ahmed
Numerical solution: the shooting method
Solution using RK method:
dT T1 − T−11 ⎛ dT ⎞
= ⇒ T−1 = T1 − 2Δx
2Δ ⎜ ⎟
dx 0 2Δx ⎝ dx 0 ⎠
T−1 + (2 + h′Δx 2 )T0 − T1 = h′Δx 2T∞
−T
⎡ ⎛ dT ⎞⎤
−⎢T1 − 2Δx⎜ ⎟ (
⎥ + + ′Δx ) − = ′Δx
2 2
2 h T0 T1 h T∞
⎣ ⎝ dx
d 0 ⎠⎦
⎛ dT ⎞
(2 + h′Δx )T0 − 2T1 = h′Δx T∞ − 2Δx⎜⎝ dx ⎟⎠
2 2
0
CE 205: Numerical Methods Dr. Tanvir Ahmed