lecture11 - initial value problem eulers method

Upload: na2ry

Post on 29-May-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    1/17

    Numerical Solutions of Ordinary

    Differential Equations

    Lecture 11:

    Initial Value Problem: Eulers Method

    MTH2212 Computational Methods and Statistics

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    2/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 22

    Objectives

    Introduction

    Eulers Method

    Convergence analysis

    Error analysis

    Error estimate

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    3/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 33

    Introduction

    Differential equations: equations composed of an unknown

    function and its derivatives.

    Differential equations play a fundamental role in engineeringbecause many physical phenomena are best formulated

    mathematically in terms of their rate of change.

    )()( tvmcg

    dttdv

    ! v- dependent variable

    t- independent variable

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    4/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 44

    Introduction

    Fundamental laws of physics, mechanics, electricity andthermodynamics are written in terms of the rate of changeof variables (t = time and x = position):

    Newtons second law of motion

    Fouriers heat law

    Lapalce equation (steady state)

    Heat conduction

    etc.

    mF

    dd !

    dx

    dTkq '

    02

    2

    2

    2

    x

    x

    x

    x

    y

    T

    x

    T

    2

    2

    '

    x

    Tk

    t

    T

    x

    x!

    x

    x

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    5/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 55

    Introduction

    One independent variable Ordinary Differential Equation

    (ODE)

    Two or more independent variables Partial DifferentialEquation (PDE)

    Order of a differential equation is determined by the highest

    derivative.

    Higher order equations can be reduced to a system of first

    order equations, by redefining a variable.

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    6/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 66

    Introduction

    An ODE is accompanied by auxiliary conditions. Theseconditions are used to evaluate the integral that resultduring the solution of the equation. An nth order equationrequires n conditions.

    If all conditions are specified at the same value of theindependent variable, then we have an initial-value problem.

    If the conditions are specified at different values of theindependent variable, usually at extreme points orboundaries of a system, then we have a boundary-value

    problem.

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    7/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 77

    Eulers Method

    Solve ordinary

    differential equations

    of the form

    With initial condition

    The estimate of thesolution is

    ),( yxfdx

    dy!

    ii yxy !)(

    hyy ii J1

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    8/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 88

    is the

    estimate of slope at xi

    is thedifferential equation

    evaluated at xi and yi

    The estimate is given by

    This is Eulers method

    (Euler-Cauchy, Point-slope)

    ),( ii yxf!J

    ),( ii yxf

    hyxfyy iiii ),(1 !

    Eulers Method

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    9/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 99

    Error Analysis for Eulers Method

    The numerical solution ofODE involves 2 types of error:

    1. Round-off errors: this caused by limited numbers of

    significant digits that can be retained by a computer.

    2. Truncation errors:a) Local truncation error: due to the application of the

    method over a single step.

    b) Propagated truncation error: due to approximation

    produced during previous steps.

    Total or global truncation error = local truncation error +

    propagated truncation error.

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    10/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1010

    Error Estimate for Eulers Method

    The general form of the differential equation being integrated:

    Taylors series expansion of y about a starting value (xi

    ,yi

    ):

    (1) into (2) gives

    Subtract Eulers method equation from (3) gives the truncationerror

    ),(' yxfydx

    dy!!

    )(!

    ...!2

    1)(

    2''

    '

    1

    !

    nnn

    iiiii hOh

    n

    yh

    yhyyy

    )(!

    ),(

    ...!

    ),(

    ),(

    )('

    !

    nnii

    n

    ii

    iiii n

    yxfyxf

    yxfyy

    )(!

    ),(...

    !2

    ),(1

    )1(

    2

    '

    !nnii

    nii

    t hOhn

    yxfh

    yxfE

    (1)

    (2)

    (3)

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    11/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1111

    Example 1

    1. Use Eulers method to integrate numerically the ODE:

    from x = 0 to x = 4 with a step size of 0.5 and an initialcondition at x = 0 is y = 1?

    2. Estimate and tabulate the errors

    5.82012223

    ! xxxdx

    dy

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    12/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1212

    Example 1 - Solution

    1. Using Eulers method

    Evaluate the first prediction y(0.5)

    Evaluate the second prediction y(1)

    hyxfyy iiii ),(! 1)0( !y 5.0!h

    5.258.5)(0.5)(1)()5.0( !!y

    5.85.8)0(20)0(12)0(2)1,0( 23 !!f

    0.5)()1,0()0()5.0( fyy

    875.5)( .5)(5.25)()( y

    !! 5.8)5.(2)5.(2)5.(2),(23f

    .5)()25.5,5.()5.()( fyy !

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    13/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 1313

    Example 1 - Solution

    Evaluate the third prediction

    5.125-1.5)(0.5)(5.875)5.1( !!y

    0.5)()875.5,()()5.( fyy x yEuler

    0.0 1.000

    0.5 5.2501.0 5.875

    1.5 5.125

    2.0 4.500

    2.5 4.750

    3.0 5.875

    3.5 7.125

    4.0 7.000

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    14/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1414

    Example 1 - Solution

    2. Estimate the truncation error

    For the first step

    4)3(

    3'''

    !4

    )(

    !3

    )(

    !

    )(h

    yxfh

    yxfh

    yxfE iiiiiit !

    12)1,012),

    2)1,0212),

    20)1,02026),

    )3()3(

    ''''

    '2'

    !!

    !!

    !!

    fyxf

    fxyxf

    fxxyxf

    ii

    ii

    ii

    03 5.)5.0(4

    )5.0(6

    4)5.0(

    0 43

    t

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    15/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1515

    Example 1 - Solution

    x yEuler Et

    0.00000 1.00000 0.00000

    0.50000 5.25000 -2.03125

    1.00000 5.87500 -2.87500

    1.50000 5.12500 -2.90625

    2.00000 4.50000 -2.50000

    2.50000 4.75000 -2.03125

    3.00000 5.87500 -1.87500

    3.50000 7.12500 -2.40625

    4.00000 7.00000 -4.00000

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    16/17

    Dr. M. HrairiDr. M. Hrairi MTHMTH22122212 -- Computational Methods and StatisticsComputational Methods and Statistics 1616

    Remarks about Eulers Method

    The Taylor series provides only an estimate of the localtruncation error. It does not give a measure of the globaltruncation error.

    The global truncation error is O(h), that is, it is proportionalto the step size.

    The error can be reduced by decreasing the step size.

    If the underlying function, y(x), is linear, the method provideerror-free predictions. This is because for a straight line thesecond derivative would be zero.

  • 8/9/2019 Lecture11 - Initial Value Problem Eulers Method

    17/17

    Dr. M. HrairiDr. M. Hrairi MTH2212MTH2212 -- Computational Methods and StatisticsComputational Methods and Statistics 1717

    Effect of step size - example 1