numerical solution of odes-ivp

Upload: mitchg101

Post on 14-Apr-2018

233 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Numerical Solution of ODEs-IVP

    1/32

    Prof. A.A. Adesina, ChSE, UNSW 1

    NUMERICAL SOLUTION OFORDINARY DIFFERENTIAL

    EQUATIONSINITIAL VALUE PROBLEMS

  • 7/30/2019 Numerical Solution of ODEs-IVP

    2/32

    Prof. A.A. Adesina, ChSE, UNSW 2

    GENERAL CONSIDERATIONS

    The modelling

    ofunsteady-state processes

    often lead to ODEs

    with

    time as the independent variable. In other cases, the independent

    variable may be a spatial co-ordinate as in the steady-statetreatment of tubular or columnal systems

    such as plug flow and

    trickle-bed reactors, packed adsorption and absorption towers oreven tubular heat exchangers.

    In general, for an nth

    order ODE, n conditions are needed tocompletely solve the problem. If ALL these n specifications are

    provided at the same value of the independent variable, say, t orx, for all dependent variables, then the ODE is

    said to be an INITIAL

    VALUE PROBLEM. While this may imply that the value of t or x is

    supposed to be the starting point in the system (e.g. t=0 or x=0),there is no mathematical incongruity if

    the value oft or x is the end-

    point or some other physically admissible point

    in the independent

    variable range.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    3/32

    Prof. A.A. Adesina, ChSE, UNSW 3

    METHODS FOR 1ST ORDER NONLINEARODE - Euler methods

    The general 1st

    order nonlinear ODE may be written;

    The Euler method, one of the earliest techniques for solving ODE

    stipulates

    that, if we can represent the LHS of Eqn

    (7.1) by its first forward finite

    difference, then at any position, i, we have,

    0 0 0 0

    ( 7 . 1 )

    w i t h t h e i n i t i a l c o n d i t i o n t h a t

    a t ( )O

    ( ,

    R

    )

    x x y y y

    d yf x y

    d

    x y

    x

    = = =

    =

    1

    2 2 3 3

    (7.2)

    but from our previous discussion on finite difference operators, we can write,

    ..... ...2 6

    i i i

    i ii i

    y y y

    h D y h D yy hDy

    + =

    = + + + (7.3)

  • 7/30/2019 Numerical Solution of ODEs-IVP

    4/32

    Prof. A.A. Adesina, ChSE, UNSW 4

    Euler methods

    Euler assumed a truncation of the series in Eqn

    (7.3) after the 1st

    term, thus,

    In fact, replacing the term, Dyi

    with ffrom Eqn

    (7.1), we get the so-called

    explicit (forward) Euler method, written,

    It is evident that this method is only marginally accurate since

    the error is of

    order h

    2

    .

    2

    2

    1

    (7.4)so that upon substitution into Eqn (7.2), we receive,

    (7

    )

    ( ) )

    (

    .5

    i i

    i i i

    y hD y O h

    y y hD y O h+

    = +

    = + +

    21 ( , ) ( ) (7.6)i i i iy y hf x y O h+ = + +

  • 7/30/2019 Numerical Solution of ODEs-IVP

    5/32

    Prof. A.A. Adesina, ChSE, UNSW 5

    Euler methods

    If we use the backward finite difference approximation, we can write,

    But from earlier notes, we know that

    1 1

    1 1

    (7.7)so that, in terms of backward differences, we have,

    (7.8)

    i i i i

    i i i

    y y y y

    y y y

    + +

    + +

    = =

    = +

    2 2 3 3

    1 11 1

    21 1 1

    (7.9)

    so that combining with Eqns (7.1) & (7.2) we secure,

    .............2 6

    ( (7.10, ) ( ))

    i ii i

    i i i i

    h D y h D yy hDy

    y y hf x y O h

    + +

    + +

    + + +

    = +

    = + +

  • 7/30/2019 Numerical Solution of ODEs-IVP

    6/32

    Prof. A.A. Adesina, ChSE, UNSW 6

    Euler methods

    Eqn

    (7.10)

    is commonly called the implicit Euler method

    because it

    involves the calculation of the function, f, at the unknown value of

    yi+1

    . We observe that the error in Eqn (7.10) is also of the order of h2.

    In principle, implicit equations cannot be solved individually but must

    be set up as sets simultaneous algebraic equations. If these are

    linear, then we can use any of the techniques we have encounteredbefore (say, generalised inverse matrix approach) to deliver asolution. However, if they are nonlinear, we may use the Jacobian method for solving the set of nonlinear algebraic equations.Regardless, the computation may be time-consuming depending on

    how many integration steps we need to do.

    Euler simplified this problem by using Eqn

    (7.6) to predict yi+1

    and

    then employing this predicted value

    to get a corrected estimate from

    Eqn (7.10).

  • 7/30/2019 Numerical Solution of ODEs-IVP

    7/32

    Prof. A.A. Adesina, ChSE, UNSW 7

    Euler methods

    Eqns

    (7.6) and (7.10) constitute the Euler predictor-corrector pair and is more

    accurate because it has an error oforder h3

    (which can be readily shown by

    adding Eqns (7.3) & (7.9)). Thus, the

    Euler Predictor-Corrector method

    is:

    As a result, the Euler Predictor-Corrector method is preferred over the

    explicit or implicit method

    for the purpose of computation.

    ( )

    ( ) [ ]

    2

    1 Pr

    2

    1 1 1

    (7.11a( , ) ( )

    ( , ) ( , ) ( )

    )

    (7.11b2

    )

    i i i i

    i i i i i iCor

    y y hf x y O h

    hy y f x y f x y O h

    +

    + + +

    = + +

    = + + +

  • 7/30/2019 Numerical Solution of ODEs-IVP

    8/32

    Prof. A.A. Adesina, ChSE, UNSW 8

    Runge-Kutta

    Methods

    The Runge-Kutta

    methods are arguably the most widely used

    integration techniques for solving ODEs

    with initial conditions

    (IVP-ODEs). Although the formal derivation for each method issimilar to the Euler method in the sense that we take advantage of

    particular approximations of the Taylor series expansion of the

    differential operator (cf. Lecture notes on Finite Difference operators

    as recalled in Eqns (7.3) & (7.9)), we will NOT provide formalderivations here but simply summarise the necessary equations to

    be used for each RK method as displayed in the Tables below.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    9/32

    Prof. A.A. Adesina, ChSE, UNSW 9

    Table 1: Summary of Runge-Kutta integration formulas (2nd-4th order)

    Orderof theRKMethod

    Formula foryi+1 Formula for RKconstants

    Order oftheerrorinvloved

    Second

    1 1 2

    1( )

    2i iy y k k

    += + + 1

    2 1

    ( , )

    ( , )

    i i

    i i

    k hf x y

    k hf x h y k

    == + +

    O(h3)

    Third1 1 2 3

    1( 4 )

    6i i

    y y k k k+ = + + + 11

    2

    3 2 1

    ( , )

    ,2 2

    ( , 2 )

    i i

    i i

    i i

    k hf x y

    h kk hf x y

    k hf x h y k k

    = = + +

    = + +

    O(h4)

    Fourth1 1 2 3 4

    1( 2 2 )

    6i i

    y y k k k k+ = + + + + 11

    2

    23

    4 3

    ( , )

    ,2 2

    ,2 2

    ( , )

    i i

    i i

    i i

    i i

    k hf x y

    h kk hf x y

    h kk hf x y

    k hf x h y k

    = = + + = + +

    = + +

    O(h5)

  • 7/30/2019 Numerical Solution of ODEs-IVP

    10/32

    Prof. A.A. Adesina, ChSE, UNSW 10

    Table 2: Runge-Kutta-Gill integration formulas

    Orderof theRKMethod

    Formula foryi+1 Formula for RK constants Order oftheerrorinvloved

    Runge-Kutta-Gill

    1 1 2 3 41 1 12 1 2 16 2 2

    i iy y k k k k+ = + + + + +

    ( ) ( )

    ( )

    1

    12

    31 2

    4 32

    ( , )

    ,2 2

    ,2

    2 1 2 22 2

    ,

    2 2

    22

    i i

    i i

    i

    i

    i

    i

    k hf x y

    h kk hf x y

    hx

    k hf k ky

    x h

    k hf kky

    = = + + +

    = + + + = + +

    O(h5)

    The Runge-Kutta-Gill method is the most widely used 4th

    order method and the constants are

    selected to reduce the amount of storage required in the solution of a large number of

    simultaneous 1st

    order ODEs. We will discuss application of RK methods to set of ODEs later.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    11/32

    Prof. A.A. Adesina, ChSE, UNSW 11

    Table 3: Summary of Runge-Kutta integration formulas (5th order)

    Orderof theRKMethod

    Formula foryi+1 Formula for RK constants Order oftheerrorinvloved

    Fifth1 1 3 4 5 6

    1(7 32 12 32 7 )

    90i i

    y k k k k k+ = + + + + + 11

    2

    1 23

    34

    32 45

    3 51 2 46

    ( , )

    ,2 2

    3

    ,2 16 16

    ,2 2

    63 3 9,4 16 16 16

    6 84 12,

    7 7 7 7 7

    i i

    i i

    i i

    i i

    i i

    i i

    k hf x y

    h kk hf x y

    h k k

    k hf x y

    khk hf x y

    kh k k

    k hf x y

    k kk k kk hf x h y

    = = + + = + + + = + + = + + + = + + + + +

    O(h6)

  • 7/30/2019 Numerical Solution of ODEs-IVP

    12/32

    Prof. A.A. Adesina, ChSE, UNSW 12

    Comments on Runge-Kutta methodselection

    In general, the 4th

    order RK method is more commonly used

    because

    it has a good accuracy for most engineering situations. However, forstiff ODEs, it may be necessary to reduce the step-size, h, betweensuccessive integration steps. What is the criterion for implementing a

    step-size reduction to avoid error propagation through the integration

    procedure? Collatz (1960) has recommended that if,

    After each integration step, then the step-size, h, should be

    decreased

    (to probably half its current value).

    3 2

    2 1

    0 . 1 (7 .12)k k

    k k

  • 7/30/2019 Numerical Solution of ODEs-IVP

    13/32

    Prof. A.A. Adesina, ChSE, UNSW 13

    Illustrative example

    Let us find the solution to the IVP

    In this case, clearly,

    We divide the interval into 10 steps so that x0

    =0.0, x1

    =0.1..x10

    =1.0

    with h=0.1. Thus, y(x0

    0=1.0. Using the iterative formulas given on

    Table 1, we get,

    th

    (E1.1)

    with over the interval 0 x 1 usingy(0 4 order RK method)=1.0

    2

    1dy y xdx =

    +

    ( , ) 2 1x y y x+

  • 7/30/2019 Numerical Solution of ODEs-IVP

    14/32

    Prof. A.A. Adesina, ChSE, UNSW 14

    Results of the 4th

    order Runge-Kutta methods for the Illustrative Example

    xi R-K R-K-G Exact value of yi

    0.0 1.0 1.0 1.00.1 1.01034164 1.01034164 1.01034260

    0.2 1.04280472 1.04280472 1.04280663

    0.3 1.09971619 1.09971619 1.09971809

    0.4 1.18364811 1.18364811 1.18365002

    0.5 1.29744053 1.29744148 1.29744339

    0.6 1.44423485 1.44423580 1.44423676

    0.7 1.62750244 1.62750340 1.62750530

    0.8 1.85107803 1.85107994 1.85108185

    0.9 2.11920166 2.11920357 2.11920643

    1.0 2.43655777 2.43656063 2.43656349

  • 7/30/2019 Numerical Solution of ODEs-IVP

    15/32

    Prof. A.A. Adesina, ChSE, UNSW 15

    Predictor-Corrector Methods

    The Runge-Kutta

    methods are single-step

    methods and are good for

    solving IVP because they self-starting. However, they may be

    plagued with instabilities for highly stiff ODEs which require smallstep-size to overcome numerical instabilities. Predictor-Correctormethods are preferred

    for such situations because they deliver more

    stable results. They are, however, nonself-starting

    and are regarded

    as multi-step techniques.

    The most common PC methods are summarised

    below.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    16/32

    Prof. A.A. Adesina, ChSE, UNSW 16

    Table 4: Summary of commonly used Predictor-Corrector Methods

    Type of

    PC

    method

    Predictor Equation Corrector Equation Error

    involved

    Euler ( )1 Pri i iy y hf+ = + ( ) ( )1 12

    i i i iCor

    hy y f f+ ++ + O(h

    2)

    Milnes

    4thorder

    ( ) ( )1 3 1 2Pr

    42 2

    3i i i i i

    hy y f f f+ + + ( ) ( )1 1 1 14

    3i i i i i

    Cor

    hy y f f f+ + + + + O(h

    5)

    Adams-

    Moulton

    method

    ( ) ( )1 1 2 3Pr 55 59 37 924i i i i i ihy y f f f f+ + + ( ) ( )1 1 1 29 19 524i i i i i iCor hy y f f f f+ + + + + O(h5)

    Milnes

    6th order ( ) 1 21 5Pr3 4

    11 14 26310 14 11

    i i ii i

    i i

    f f fhy y

    f f +

    + = + + ( ) 1 11 2 37 32 12

    245 32 7

    i i ii iCor

    i i

    f f fhy y

    f f+ + + + = + + +

    O(h7)

    Note that: fi = f(xi, yi); fi+1 = f(xi+1, yi+1) etc, in the Table above

  • 7/30/2019 Numerical Solution of ODEs-IVP

    17/32

    Prof. A.A. Adesina, ChSE, UNSW 17

    Predictor-Corrector Methods

    How many times do we iterate on the Corrector equation? Typically, we

    employ a termination criterion to determine when to stop. For example,

    we can use:

    1, 1, 1

    1, 1

    i+1m number of iterat

    ions

    perform

    ed so far on

    is

    (7.12)

    where

    the toleranc

    indicates the

    usin

    1,2,....

    Corrector Equat e faciong the and

    y

    i m i m

    i m

    y y

    ym

    + + + =

    -4

    ,

    a small positive number,

    tor

    10typi or smcal ally, ler.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    18/32

    Prof. A.A. Adesina, ChSE, UNSW 18

    Worked Example

    Use the Milnes 4th

    order PC method to solve

    Solution

    Assume h=0.1, then let us calculate the 1st three points (y1 ,y2 ,y3 ) bythe single-step method of 4th order R-K technique since the PC isNOT self-starting. Recall that we need, yi-3

    to use the Milnes P-Cmethod.

    0.8

    y(1.0)=3.

    (E1)

    with over th ra

    0.1( )

    nge x0 =1.0 to 2

    .0e

    dy x ydx = +

    0.8( , ) 0.1( )f x y x y+

  • 7/30/2019 Numerical Solution of ODEs-IVP

    19/32

    Prof. A.A. Adesina, ChSE, UNSW 19

    Starting with the 4th order RK method and using y(1) =3.0; we have, x0=1.0and y0=3.0

    1st integration step

    0.8

    1 0 0

    0.8

    2 0 0 1

    3 0 0 2

    4 0 0 3

    1 2 3 4

    1 0

    ( , ) 0.1[0.1(1 3) ] 0.0303143( / 2, / 2 ) 0 .1[0.1(1.05 3.01516) ] 0.0307087

    ( / 2, / 2 ) 0.0307099

    ( , ) 0.0311043

    12 2 0.0307093

    63.0

    k h f x yk h f x h y k

    k h f x h y k

    k h f x h y k

    y k k k k

    y y y

    = = + == + + = + == + + == + + =

    = + + + = = + =

    11 0.1 1

    307093

    d

    1

    an

    .x = + =

    2

    nd

    integration step0.8

    1 1 1

    2 1 1 1

    3 1 1 2

    4 1 1 3

    1 2 3

    2

    2

    4

    1

    ( , ) 0.1[0.1(4.13071) ] 0.0311042

    ( / 2, / 2) 0.0314985

    ( / 2, / 2 ) 0.0314997

    ( , ) 0.0311043

    12 2 0.0314991

    6

    3.03

    and

    1.1

    149

    0.

    9

    1

    1

    1 .

    k h f x y

    k h f x h y k

    k h f x h y k

    k h f x h y k

    y k k k

    x

    k

    y y y

    = = == + + == + + == + + =

    = + + + =

    = += =

    =+

    2

    Similar repetitive steps give,

    3 31.3, 3.09449x y =

    At the 4th integration step, we now turn to the 4th order Milnes

  • 7/30/2019 Numerical Solution of ODEs-IVP

    20/32

    Prof. A.A. Adesina, ChSE, UNSW 20

    At the 4 integration step, we now turn to the 4 order Milne s

    PC. Hence,

    ( )4 0 3 2 11

    2

    3

    4 3 4 3 2

    0.8

    4 4

    ,

    4

    4

    4 0

    4Pr : 2 2

    3

    0.311042

    0.318939

    0.326834

    0.43.0 (0.622084 0.653668 0.318939) 3.127

    : ( 4 )

    3( , ) 0.1(1.4 3.12758) 0.334728

    0.13.09449 (1.961

    583

    00) 3.15983

    hC or y y f f f

    f f x y

    y

    hy y f f f

    f

    f

    f

    y

    = + + += = +

    = + +=

    = = + =

    ==

    = + + =

    4 ,1 4 ,0

    4

    0.8

    4 4 4 ,0

    4 ,1 3 4 3 2

    ,0

    -4

    1st iteration step of the Co rrector Equa tion

    f ( , ) 0.1(1.4 3.15986) 0.336636

    ( 4 )3

    Check for converge

    0.

    nc

    13.09449 (1.96291) 3.15992

    3

    e

    L et us assu m e th 1

    6

    at = 0

    f x y

    hy

    y y

    f

    y

    y f f

    = = + == + +

    += + =

    5 4st

    th

    3.15992 3.159861.8988 10 10

    3.15986

    hence convegrence was met after the 1 iteration so we cannow proceed to the 5 integration step.

    =

  • 7/30/2019 Numerical Solution of ODEs-IVP

    21/32

    Prof. A.A. Adesina, ChSE, UNSW 21

    Solution of higher order ODEs (Solution toSimultaneous 1

    st

    order ODEs)

    In principle, since it is possible to convert an nth

    order ODE

    to a set ofn 1st

    order ODEs.

    The approach to solving an nth

    order ODE

    is therefore exactly the same as solving n 1st

    order ODEs. We would 1st

    show how this conversion may be carried out and then

    proceed with a discussion of the simlutaneous

    solution of n 1st

    order ODEs.

    1 2 1

    1 2 1 01 2 1

    1

    ( , ) ( , ) .... ( , ) ( , ) ( , , ,... ) (7.13)

    Let us defi

    ne new variables as:

    (7.1z 4

    n n n n

    n nn n n n

    d y d y d y dy dy d ya x y a x y a x y a x y g x y

    dx dx dx dx dx dx

    y

    + + + =

    =1

    2 1 1 2

    2

    23 2 1 22

    2

    21 2 1 22

    ( , , , ..... )

    ( , , , .....

    )

    (7.15)

    (7.16)

    )

    ( , , , ..... )

    n

    n

    n

    nn n nn

    dz dyz f x z z z

    dx dx

    dz d yz f x z z z

    dx dx

    dz d yz f x z z zdx dx

    = = == = =

    = = =M

    1

    11 1 21

    1

    (7.17)

    (7.18)

    Introducing these equ ations into the original equation, w e receive

    ( , , , ..... )

    ( , , ,...

    n

    nn n nn

    n n

    n

    n n

    dz d yz f x z z z

    dx dx

    dz d y dy d yg x ydx dx dx dx

    = = =

    = = 1 21 )= ( , , , ..... ) (7.19)n nf x z z z

  • 7/30/2019 Numerical Solution of ODEs-IVP

    22/32

    Prof. A.A. Adesina, ChSE, UNSW 22

    Solution of higher order ODEs (Solution toSimultaneous 1

    st

    order ODEs)

    Eqns

    (7.15) to (7.19) constitute the new n 1st

    order ODEs

    we now

    need to solve. The applicable 4th

    order Runge-Kutta

    constants are:

    ( )1, 1 2 3 41 1 2

    111 122 1 2

    221 223 1 2

    12 2 1,2,...

    6

    ( , , ,.... ) 1,2,...

    , , ,.... 1,2,...2

    (7.20

    2 2 2

    , , ,.

    )

    (7.21)

    (7.22)

    ...2 2 2 2

    i j ij j j j j

    j j i i i in

    nj j i i i in

    nj j i i i in

    z z k k k k j n

    k hf x z z z j n

    kh k kk hf x z z z j n

    kh k kk hf x z z z

    + = + + + + == =

    = + + + + = = + + + +( )4 1 31 2 32 3

    1,2,...

    ,

    (7.23)

    (7, ,..... 1,2 .24. ), ..j j i i i in n

    j n

    k hf x h z k z k z k j n

    == + + + + =

  • 7/30/2019 Numerical Solution of ODEs-IVP

    23/32

    Prof. A.A. Adesina, ChSE, UNSW 23

    Comments on Runge-Kutta methodselection

    A system ODE is said to be stiff if the so-called stiffness ratio, SR, exceeds

    a particular value as indicated below, where SR is defined,

    Where i

    s

    are the eigenvalues

    of the ODE system and max |Re(i

    )| is the

    real part of the maximum eigenvalue of the system. In general, if

    a). SR is about an order of magnitude

    (10,20, etc), the system is NOT stiff.

    b). SR is about three orders of magnitude

    (1000, 2000, etc) the system is

    STIFF

    c). SR is about six orders of magnitude

    (106, etc), the system is VERY

    STIFF.

    The eigenvalues

    are obtained from the matrix of the coefficients of the set

    of ODEs.

    max Re( )

    m

    in R

    (7.e( )

    25)i

    i

    SR=

  • 7/30/2019 Numerical Solution of ODEs-IVP

    24/32

    Prof. A.A. Adesina, ChSE, UNSW 24

    Comments on Runge-Kutta methodselection

    In principle, a stiff ODE

    is one whose general solution contains an

    exponential term, e.g. e

    x

    forsome constant . When is large andnegative, the ODE is especially troublesome because it permits the solution

    to decay quickly to zero.

    For instance, the solution to:

    i

    0 0

    x

    (7.26)

    with , the may be obtained as

    (7.27)

    where

    ( , )

    eigenvalue, ,

    can vary in magnitude at each step of the in .tegration

    Eqn (7.26)

    ( )

    y x y

    f

    y

    dy

    f x ydx

    = ==

    will be at some point in the range of integration.

    Thus, the s

    stiff if i

    olution wil

    s NE

    l be

    GATIVE

    unstable.

    f

    y

  • 7/30/2019 Numerical Solution of ODEs-IVP

    25/32

    Prof. A.A. Adesina, ChSE, UNSW 25

    Real stability regions for selected solution methods

    Method Stability boundary

    Explicit Euler -2 h 0

    Implicit Euler 0 < h < , for < 0;-2 h 0, for > 0

    Euler Predictor-Corrector -1.077 h 02

    ndorder Runge-Kutta -2 h 0

    3rd order Runge-Kutta -2.5 h 04

    thorder Runge-Kutta -2.785 h 0

    5th

    order Runge-Kutta -5.7 h 0

    Adams-Moulton -1.285 h 0

  • 7/30/2019 Numerical Solution of ODEs-IVP

    26/32

    Prof. A.A. Adesina, ChSE, UNSW 26

    For a set of n simultaneous ODEs, we can obtain theeigenvalues from the Jacobian matrix of the functions, fiwritten;

    1 1 1

    1 2

    2 2 2

    1 2

    1 2

    .......

    ........

    . . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . . .

    ........

    n

    n

    n n n

    n

    f f f

    y y y

    f f f

    y y y

    J

    f f f

    y y y

  • 7/30/2019 Numerical Solution of ODEs-IVP

    27/32

    Prof. A.A. Adesina, ChSE, UNSW 27

    Comments on Runge-Kutta methodselection

    It is apparent from the foregoing considerations that implicit methods

    are recommended for handling the solution to stiff ODEs. This is

    why Predictor-Corrector methods are somewhat popular amongchemical engineers

    since we often deal with nonlinearity due to the

    Arrhenius

    or vant

    Hoff terms

    arising from modeling of non-

    isothermal tubular reactors/columns or dynamics of reactive lumped

    systems with nonlinear kinetics.

  • 7/30/2019 Numerical Solution of ODEs-IVP

    28/32

    Prof. A.A. Adesina, ChSE, UNSW 28

    Example problem

    Solve

    22 2

    2

    d yx x y y

    d x= + +

    for y at x = 2.0 ify = 4.0 at x = 1.0 and

    0.5 1.0dy at xdx

    = =

  • 7/30/2019 Numerical Solution of ODEs-IVP

    29/32

    Prof. A.A. Adesina, ChSE, UNSW 29

    Solution

    Let

    1

    22 2

    22

    ( , , )

    ( , , )

    d yz f x y z

    d xd y d z

    x x y y f x y zd x d x

    = =

    = = + + =

    Assume h = 0.5. From the initial conditions0 0 01 .0 , 4 .0 , 0 .5x y z= = =

    1st

    R-K constants

    0 0 0

    1 1 1

    0 0 0

    1 1 2

    ( , , ) 0 .5 0 .5 0 .2 5

    ( , , ) 0 .5 (1 4 1 6 ) 1 0 .5 0

    k h f x y z x

    k h f x y z

    = = =

    = = + + =

    2nd

    R-K constants

    0 0 01 1 1 22 1 1

    0

    0 1 1

    0 1 2

    2 1

    0 0 01 1 1 22 2 2

    2 2

    ( , , )2 2 2

    0 .51 1 .2 5

    2 2

    0 . 2 54 4 .1 2 5

    2 21 0 . 5

    0 .5 5 .7 52 2

    0 .5 5 .7 5 2 .8 7 5

    ( , , )2 2 2

    0 .5 [ (1 .2 5 ) 4 .1 2 5 1 .2 5 ( 4 .1 2 5 ) ]

    1 1 . 8 6 7 2

    h k kk h f x y z

    hx

    ky

    kz

    k x

    h k kk h f x y z

    x

    = + + +

    + = + =

    + = + =

    + = + =

    = =

    = + + +

    = + +

    =

    3r R-K constantsh k k

  • 7/30/2019 Numerical Solution of ODEs-IVP

    30/32

    Prof. A.A. Adesina, ChSE, UNSW 30

    0 0 02 1 2 23 1 1

    0

    0 2 1

    0 2 2

    3 1

    0 0 02 1 2 23 2 2

    2 2

    ( , , )2 2 2

    0 . 51 1 . 2 5

    2 2

    2 . 8 7 54 5 . 4 3 7 5

    2 2

    1 1 . 8 6 7 20 . 5 6 . 4 3 3 62 2

    0 . 5 6 . 4 3 3 6 3 . 2 1 6 8

    ( , , )2 2 2

    0 . 5 [ (1 . 2 5 ) 5 . 4 3 7 5 1 . 2 5 ( 5 . 4 3 7 5 ) ]

    1 8 . 9 6 2 9

    h k kk h f x y z

    hx

    ky

    kz

    k

    h k kk h f x y z

    x

    = + + +

    + = + =

    + = + =

    + = + =

    = =

    = + + +

    = + +

    =

    4th

    R-K constants0 0 0

    4 1 1 3 1 3 2

    0

    0

    3 1

    0

    3 2

    4 1

    0 0 0

    4 2 2 3 1 3 2

    2 2

    1 1 2 1 3 1 4 1

    1 2 2 2

    ( , , )

    1 . 5

    7 . 2 1 6 8

    1 9 . 4 6 2 9

    0 . 5 1 9 . 4 6 2 9 9 . 7 3 1 4 5

    ( , , )

    0 . 5 [ ( 7 . 2 1 6 8 ) 1 . 5 7 . 2 1 6 8 (1 . 5 ) ]

    3 2 . 5 7 8 7

    1[ 2 2 ] 3 . 6 9 4 1 8

    6

    1 [ 26

    k h f x h y k z k

    x h

    y k

    z k

    k x

    k h f x h y k z k

    x

    y k k k k

    z k k

    = + + +

    + =

    + =

    + =

    = =

    = + + +

    = + +

    =

    = + + + =

    = + 3 2 4 2

    ( 1 ) 0

    ( 1 ) 0

    ( 1 ) 0

    2 ] 1 7 . 4 5 6 5

    7 . 6 9 4 1 8

    1 7 . 9 5 6 5

    1 . 5

    k k

    y y y

    z z z

    x x h

    + + =

    = + =

    = + =

    = + =

    We will now usex(1), y

    (1), andz

    (1)as the starting point for the computation

    of ( 2 ) ( 2 ) ( 2 ), ,x y a n d z .

  • 7/30/2019 Numerical Solution of ODEs-IVP

    31/32

    Prof. A.A. Adesina, ChSE, UNSW 31

    2nd

    integration step

    1st

    R-K constants

    (1) (1) (1)

    11 1

    (1) (1) (1)

    11 2

    2 2

    ( , , ) 0.5 17.9565 8.97824

    ( , , )

    0.5[(7.69418) (7.69418 1.5) (1.5) ] 36.4958

    k hf x y z x

    k hf x y z

    x

    = = =

    =

    = + + =

    2

    nd

    R-K constants

    (1) (1) (1)11 1221 1

    (1)

    (1) 11

    (1) 12

    21

    (1) (1) (1)11 1222 2

    2 2

    ( , , )2 2 2

    1.752

    12.18332

    36.20442

    0.5 36.2044 18.1022

    ( , , )2 2 2

    0.5[(1.75) 1.75 12.1833 (12.1833) ]

    92.4997

    k khk hf x y z

    hx

    ky

    kz

    k x

    k khk hf x y z

    x

    = + + +

    + =

    + =

    + =

    = =

    = + + +

    = + +

    =

    3rd

    R-K constants

  • 7/30/2019 Numerical Solution of ODEs-IVP

    32/32

    Prof. A.A. Adesina, ChSE, UNSW 32

    3 R K constants

    (1 ) (1 ) ( 1 )2 1 2 23 1 1

    (1 )

    (1 ) 2 1

    (1 ) 2 2

    3 1

    ( 1 ) (1 ) ( 1 )2 1 2 23 2 2

    2 2

    ( , , )2 2 2

    1 . 7 52

    1 6 . 7 4 5 3

    2

    6 4 . 2 0 6 32

    0 . 5 6 4 .2 0 6 3 3 2 . 1 0 3 1 5

    ( , , )2 2 2

    0 .5 [(1 . 7 5 ) 1 . 7 5 1 6 .7 4 5 3 (1 6 . 7 4 5 3 ) ]

    1 5 6 . 3 8 6

    k khk h f x y z

    hx

    ky

    kz

    k x

    k khk h f x y z

    x

    = + + +

    + =

    + =

    + =

    = =

    = + + +

    = + +

    =

    4th

    R-K constants(1 ) (1 ) ( 1 )

    4 1 1 3 1 3 2

    (1 )

    (1 )

    3 1

    (1 )

    3 2

    4 1

    ( 1 ) ( 1 ) ( 1 )

    4 2 2 3 1 3 2

    2 2

    1 1 2 1 3 1 4 1

    ( , , )

    2 . 0

    3 9 . 7 9 7 3

    1 7 4 . 3 4 20 . 5 1 7 4 . 3 4 2 8 7 . 1 7 1

    ( , , )

    0 . 5 [ ( 2 ) 2 3 9 . 7 9 7 3 ( 3 9 . 7 9 7 3 ) ]

    1 6 6 7 . 4 2

    1[ 2 2 ] 3 2 .7 6

    6

    k h f x h y k z k

    x h

    y k

    z kk x

    k h f x h y k z k

    x

    y k k k k

    = + + +

    + =

    + =

    + =

    = =

    = + + +

    = + +

    =

    = + + + =

    1 2 2 2 3 2 4 2

    ( 2 ) (1 )

    ( 2 ) (1 )

    ( 2 ) (1 )

    1[ 2 2 ] 3 6 6 . 9 4 8

    6

    4 0 . 4 5 4 2

    3 8 4 . 9 0 4

    2 . 0

    z k k k k

    y y y

    z z z

    x x h

    = + + + =

    = + =

    = + =

    = + =

    at x = 2.0, y = 40.4542