Week10&11 Differential Equations

download Week10&11 Differential Equations

of 34

Transcript of Week10&11 Differential Equations

  • 8/13/2019 Week10&11 Differential Equations

    1/34

  • 8/13/2019 Week10&11 Differential Equations

    2/34

    WEEK 10 & 11

    Ordinary Differential EquationsEulersmethodsImprovements of Eulersmethods

    Runge-Kutta methods

    Adaptive Runge-Kutta methods 2

  • 8/13/2019 Week10&11 Differential Equations

    3/34

    At the end of this topic, the students will be able:

    To identify and apply the methods outlined to

    solve ordinary differential equations (ODE)

    LESSON OUTCOMES

  • 8/13/2019 Week10&11 Differential Equations

    4/34

    4

    DIFFERENTIAL EQUATION

    Equations which are composed of an unknown functionand 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 twoor 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.

  • 8/13/2019 Week10&11 Differential Equations

    5/34

    5

    Differential equations play a fundamental role in

    engineering because many physical phenomena are

    best formulated mathematically in terms of their rateof change.

    v ~ dependent variable

    t ~ independent variable

    vm

    cg

    dt

    dv

  • 8/13/2019 Week10&11 Differential Equations

    6/34

    6

    This chapter is devoted to solving ordinary differential

    equations of the form

    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 aset of new values ysand hence, trace out the trajectory of the

    solution.

    New value = old value + slope x step size

    hyy ii 1

    ),( yxfdx

    dy

  • 8/13/2019 Week10&11 Differential Equations

    7/34

    7

    The first derivative provides a direct estimate of the

    slope atxiwheref(xi, yi)is the differential equation evaluated atxiand yi.

    This estimate can be substituted into the equation:

    A new value of yis predicted using the slope (equal to the first

    derivative at the original value of x) to extrapolate linearly

    over the step size h.

    ),( ii yxf

    hyxfyy iiii ),(1

    Eulers Method

  • 8/13/2019 Week10&11 Differential Equations

    8/34

    8

    Example

    Use Eulersmethod to numerically integrate ODE:

    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+ 4x310x2+ 8.5x + 1

    5.820122 23 xxxdx

    dy

  • 8/13/2019 Week10&11 Differential Equations

    9/34

    9

    x yEuler ytrue t (%)

    0 1.000 1.000 -

    0.5 5.250 3.219 -63.11.0 5.875 3.000 -95.8

    1.5 5.125 2.219 -131

    2.0 4.500 2.000 -125

  • 8/13/2019 Week10&11 Differential Equations

    10/34

    10

    Error Analysis for Eulers Method

    Numerical solutions of ODEs involves two types of

    error: Truncation error (error cause by the nature of thetechniques employed to approximate values of y)

    Local truncation error (result from application of the method in

    question over a single step)

    Propagated truncation error (result from the approximationsproduced during previous steps)

    The sum of the two is thetotal or global truncation error

    Round-off errors (caused by limited numbers of significant

    figures)

    )(

    !2

    ),(

    2

    2

    hOE

    hyxf

    E

    a

    iia

  • 8/13/2019 Week10&11 Differential Equations

    11/34

    11

    If the function has continuous derivatives, TS can be

    expanded about a starting point (xi, yi),

    and Rnis the remainder defined as

    Now, if we substitute the derivative function f(xi,yi) then

    obtain,

    Comparison of , we conclude that the

    truncation error is due to the remaining terms in the TSE.

    hyxfyy iiii ),(1

  • 8/13/2019 Week10&11 Differential Equations

    12/34

    12

    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

  • 8/13/2019 Week10&11 Differential Equations

    13/34

    13

    The Taylor series provides a means of quantifying theerror in Eulersmethod. However;

    The Taylor series provides only an estimate of the localtruncation error-that is, the error created during a singlestep of the method.

    In actual problems, the functions are more complicated

    than simple polynomials. Consequently, the derivativesneeded to evaluate the Taylor series expansion would notalways 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 astraight line, the 2ndderivative would be zero.

  • 8/13/2019 Week10&11 Differential Equations

    14/34

    14

    a) Comparison of two numerical solutions withEulersmethod 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.

  • 8/13/2019 Week10&11 Differential Equations

    15/34

    15

    ExampleEstimate the true and the approximate local truncation

    error associated with the Eulersmethod in the first step tosolve the following initial-value problem

    from x = 0 to x = 3 with h = 0.5.

    252 23 xxxdx

    dy

  • 8/13/2019 Week10&11 Differential Equations

    16/34

    16

  • 8/13/2019 Week10&11 Differential Equations

    17/34

    17

    Improvements of Eulers method

    A fundamental source of error in Eulers method isthat 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:

    Heunsmethod

    The Midpoint (or Improved Polygon) method

  • 8/13/2019 Week10&11 Differential Equations

    18/34

    One method to improve the estimate of the slope

    involves the determination of two derivatives for theinterval:

    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.

    hyxfyxf

    yy

    hyxfyy

    iiiiii

    iiii

    2

    ),(),(:Corrector

    ),(:Predictor

    0

    111

    0

    1

    Heuns Method

  • 8/13/2019 Week10&11 Differential Equations

    19/34

    19

    Note that Corrector equation is

    in an iterative form. So, we can

    iteratively obtain the improved

    estimate of yi+1until it converge

    to prespecified tolerance.

    Note also, however, that the

    convergence is not necessarilyto the true solution.

    The termination criterion of the

    corrector equation is given by

    Refer Text Book for explanation

  • 8/13/2019 Week10&11 Differential Equations

    20/34

    20

    Comparison of the true solution with a numericalsolution using Eulers and Heuns method

  • 8/13/2019 Week10&11 Differential Equations

    21/34

    The slope at the mid-point of the interval is used toextrapolate 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 fromxito xi+1

    21

    Midpoint (Improved Polygon) Method

    hyxfyy iiii ),( 2/12/11

  • 8/13/2019 Week10&11 Differential Equations

    22/34

    22

  • 8/13/2019 Week10&11 Differential Equations

    23/34

    The Runge-Kutta methods have the accuracy of the

    Taylor series approach without having to evaluate

    the higher derivatives.

    23

    Runge-Kutta Method

    ),(

    ),(

    ),(

    ),(

    constants'

    ),,(

    11,122,1111

    22212133

    11112

    1

    2211

    1

    hkqhkqhkqyhpxfk

    hkqhkqyhpxfk

    hkqyhpxfk

    yxfk

    sa

    kakaka

    hhyxyy

    nnnnninin

    ii

    ii

    ii

    nn

    iiii

    Increment function

    ps and qs are constants

  • 8/13/2019 Week10&11 Differential Equations

    24/34

    24

    ks 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=1is in fact Eulersmethod.

    Once nis chosen, values of as,ps,and qsare 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.

  • 8/13/2019 Week10&11 Differential Equations

    25/34

    The second-order version is

    25

    Second-Order Runge-Kutta Methods

    ),(),(

    )(

    11112

    1

    22111

    hkqyhpxfkyxfk

    where

    hkakayy

    ii

    ii

    ii

    Values of a1, a2, p1, and q11 are evaluated by setting the

    second order equation to Taylor series expansion to thesecond order term.

  • 8/13/2019 Week10&11 Differential Equations

    26/34

    26

    2

    12

    1

    1

    112

    12

    21

    qa

    pa

    aa

    Three equations to evaluate four unknowns constants are

    derived.

    Three of the most commonly used methods are:

    Huen Method with a Single Corrector (a2=1/2)

    The Midpoint Method (a2=1)

    RaltsonsMethod (a2=2/3)

    A value is assumed for one of the

    unknowns to solve for the other three.

  • 8/13/2019 Week10&11 Differential Equations

    27/34

    Heun Method with a Single Corrector (a2=1/2)

  • 8/13/2019 Week10&11 Differential Equations

    28/34

    28

    The Midpoint Method (a2=1)

  • 8/13/2019 Week10&11 Differential Equations

    29/34

  • 8/13/2019 Week10&11 Differential Equations

    30/34

    30

  • 8/13/2019 Week10&11 Differential Equations

    31/34

  • 8/13/2019 Week10&11 Differential Equations

    32/34

    32

    Fourth-Order Runge-Kutta Methods

    hkkkkyy ii )22(61 43211

  • 8/13/2019 Week10&11 Differential Equations

    33/34

    33

    For an ODE with an abrupt

    changing solution, a constantstep size can represent a

    serious limitation.

    Adaptive Runge-Kutta Method

  • 8/13/2019 Week10&11 Differential Equations

    34/34

    34

    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) havesuggested the following criterion to accomplish this:

    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.

    a

    present

    newpresentnew hh

    D

    D