Uploaded by Irsyad Faris

Week1011 Differential Equations

advertisement
WEEK 10 & 11
Ordinary Differential Equations
 Euler’s methods
 Improvements of Euler’s methods
 Runge-Kutta methods
 Adaptive Runge-Kutta methods
2
LESSON OUTCOMES
At the end of this topic, the students will be able:
 To identify and apply the methods outlined to
solve ordinary differential equations (ODE)
DIFFERENTIAL EQUATION
• Equations which are composed of an unknown function
and its derivatives are called differential equations.
• 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.
4
• 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
5
• This chapter is devoted to solving ordinary differential
equations of the form
dy
 f ( x, y )
dx
• The estimated slope  is used to predict the new value yi+1
using the old value yi over a distance h.
• The procedure can be implemented step by step to compute a
set of new values y’s and hence, trace out the trajectory of the
solution.
New value = old value + slope x step size
yi 1  yi  h
6
 Euler’s 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
• A new value of y is predicted using the slope (equal to the first
derivative at the original value of x) to extrapolate linearly
over the step size h.
7
Example
Use Euler’s method to numerically integrate ODE:
dy
 2 x 3  12 x 2  20 x  8.5
dx
From x = 0 to x = 2 with a step size of 0.5. The
initial condition at x = 0 is y = 1.
The exact solution is:
y = – 0.5x4 + 4x3 – 10x2 + 8.5x + 1
8
x
yEuler
ytrue
εt (%)
0
1.000
1.000
-
0.5
5.250
3.219
-63.1
1.0
5.875
3.000
-95.8
1.5
5.125
2.219
-131
2.0
4.500
2.000
-125
9
Error Analysis for Euler’s Method
• Numerical solutions of ODEs involves two types of
error:
– Truncation error (error cause by the nature of the
techniques employed to approximate values of y)
• Local truncation error (result from application of the method in
question over a single step)
f ( xi , yi ) 2
Ea 
h
2!
Ea  O ( h 2 )
• Propagated truncation error (result from the approximations
produced during previous steps)
– The sum of the two is the total or global truncation error
– Round-off errors (caused by limited numbers of significant
figures)
10
If the function has continuous derivatives, TS can be
expanded about a starting point (xi , yi),
and Rn is the remainder defined as
Now, if we substitute the derivative function f(xi,yi) then
obtain,
Comparison of yi 1  yi  f ( xi , yi )h , we conclude that
truncation error is due to the remaining terms in the TSE.
the
11
Therefore, the true local truncation error is given by
For sufficiently small h, higher-order terms would
decrease appreciably.
The approximate local truncation error can then be
written as
12
• 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 of the differential equation is linear, the
method will provide error free predictions because for a
straight line, the 2nd derivative would be zero.
13
a) Comparison of two numerical solutions with
Euler’s method using step size of 0.5 and 0.25
b) Comparison of true and estimated local truncation
error for the case where the step size is 0.5.
14
Example
Estimate the true and the approximate local truncation
error associated with the Euler’s method in the first step to
solve the following initial-value problem
dy
 2 x3  x 2  5x  2
dx
from x = 0 to x = 3 with h = 0.5.
15
16
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
17
 Heun’s Method
• 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 :
0
i 1
y
 yi  f ( xi , yi )h
f ( xi , yi )  f ( xi 1 , yi01 )
Corrector : yi 1  yi 
h
2
Refer Text Book for explanation
Note that Corrector equation is
in an iterative form. So, we can
iteratively obtain the improved
estimate of yi+1 until it converge
to prespecified tolerance.
Note also, however, that the
convergence is not necessarily
to the true solution.
The termination criterion of the
corrector equation is given by
19
Comparison of the true solution with a numerical
solution using Euler’s and Heun’s method
20
 Midpoint (Improved Polygon) Method
• The slope at the mid-point of the interval is used to
extrapolate the solution at the end of the interval.
• The value of the unknown function at the mid-point of the
interval is
• This value is used to estimate the value of the slope over the
interval,
• This slope is then used to extrapolate linearly from xi to xi+1
yi 1  yi  f ( xi 1/ 2 , yi 1/ 2 )h
21
22
 Runge-Kutta Method
• The Runge-Kutta methods have the accuracy of the
Taylor series approach without having to evaluate
the higher derivatives.
yi 1  yi   ( xi , yi , h)h
  a1k1  a2 k 2    an k n
Increment function
a' s  constants
k1  f ( xi , yi )
k 2  f ( xi  p1h, yi  q11k1h) p’s and q’s are constants
k3  f ( xi  p3h, yi  q21k1h  q22k 2 h)

k n  f ( xi  pn 1h, yi  qn 1k1h  qn 1, 2 k 2 h    qn 1,n 1k n 1h)
23
• 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.
• Thus, at least for the lower-older version, the number of
terms, n usually represent the order of approach.
24
 Second-Order Runge-Kutta Methods
• The second-order version is
yi 1  yi  (a1k1  a2 k 2 )h
where
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.
25
• Three equations to evaluate four unknowns constants are
derived.
a1  a2  1
1
a 2 p1 
2
1
a2 q11 
2
A value is assumed for one of the
unknowns to solve for the other three.
• Three of the most commonly used methods are:
– Huen Method with a Single Corrector (a2=1/2)
– The Midpoint Method (a2=1)
– Raltson’s Method (a2=2/3)
26
Heun Method with a Single Corrector (a2=1/2)
The Midpoint Method (a2=1)
28
Ralston’s Method (a2=2/3)
29
30
 Third-Order Runge-Kutta Methods
1
yi 1  yi  (k1  4k2  k3 )h
6
31
 Fourth-Order Runge-Kutta Methods
1
yi 1  yi  (k1  2k2  2k3  k4 )h
6
32
 Adaptive Runge-Kutta Method
For an ODE with an abrupt
changing solution, a constant
step size can represent a
serious limitation.
33
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:
D new
hnew  h present
D present
a
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
• 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.
34
Download