lecture 4 - taylor series expansion and finite difference method

Upload: irfan-momin

Post on 07-Apr-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    1/41

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    2/41

    Errors and Approximations

    Analytical solutions are exact

    Numerical solutions are approximate

    Real-life models are so complex that analyticalsolutions may not be possible

    Numerical methods provide an alternative route

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    3/41

    Error in the numerical solution

    A formal definition:Given a mathematical model,

    Error = |Exact Approximate|

    = |Analytical Numerical|

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    4/41

    Determination of errors

    Evidently, a good numerical methodshould have small errors!

    To minimize error, we must understand

    > the source of errors

    > how the numerical method isconstructed

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    5/41

    Round-off error

    In a computer, numbers are represented as (eg.)1.63 = 0.163E+01, or +0.8352167E+15(single precision)

    Single precision: 10-38 to 10+37 with 7 decimalplaces

    Double precision: 10-308 to 10+309 with 14 decimal

    places

    Irrational numbers such as 1/7 and will alwayshave round-off errors.

    3

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    6/41

    Truncation error: an example

    ....

    !

    ........

    !32

    132

    ++++++=

    n

    xxxxe

    nx

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    7/41

    Truncation error

    33.3

    7.69

    1.27

    0.158

    0.0158

    39.3

    9.02

    1.44

    0.175

    0.0172

    0.00142

    1

    1.5

    1.625

    1.645833333

    1.648437500

    1.648697917

    1

    2

    3

    4

    5

    6

    a(%)t(%)Result (x=0.5)Terms

    ...!

    ...........!32

    132

    ++++++=n

    xxxxe

    nx

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    8/41

    Relative error

    Definition 1:

    Definition 2:

    Definition 3:

    %100valuetrue

    errortruet =

    %100

    ionapproximat

    errorionapproximata =

    %100.

    ..

    approxcurrent

    approxpreviousapproxcurrent

    a

    =

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    9/41

    Terminology

    Round-off error

    Truncation error

    Discretization error

    Relative error

    Propagation of error

    Condition number

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    10/41

    Taylor Series Expansion

    ........)(!

    )(....

    )(!3

    )()(

    !2

    )(''))((')()(

    )(

    3)3(

    2

    ++

    ++++=

    n

    n

    axn

    af

    axaf

    axaf

    axafafxf

    Taylor series approximation

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    11/41

    Taylor series with remainder term

    dttfn

    txR

    asdefinedisRremainderthewhere

    Raxn

    af

    axaf

    axaf

    axafafxf

    n

    x

    a

    n

    n

    n

    n

    n

    n

    )(!

    )(

    )(!

    )(....

    )(

    !3

    )()(

    !2

    )(''))((')()(

    )1(

    )(

    3)3(

    2

    +

    =

    ++

    ++++=

    t is a dummy variable

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    12/41

    Properties of Taylor Series

    Infinite series

    Uniformly convergent if all derivatives exist

    Note that the infinite series for exp(x), cos(x)

    are special cases of Taylor series expansion.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    13/41

    Zero order approximation

    First order approximation

    Second order approximation

    Truncation of Taylor series

    )()( 1 ii xfxf +

    ))((')()( 11 iiiii xxxfxfxf + ++

    2

    111 )(!2

    )(''

    ))((')()( iii

    iiiii xx

    xf

    xxxfxfxf ++ +++

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    14/41

    Example

    Use zero-through fourth-order Taylor seriesexpansions to approximate the function

    fromxi = 0 with h =1. That is, predict the

    functions value atxi+1 = 1

    2.125.05.015.1.0)(

    234 +=xxxxxf

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    15/41

    An example

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    16/41

    A one dimensional grid

    1ix ix

    h

    i-1 i i+1

    1+ix

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    17/41

    Taylor series on a grid

    Consider a set of pointsx(i) separated by adistance h.

    1)1(

    )(

    3)3(

    2'

    1

    )!1(

    )(

    )(

    !

    )(....

    !3

    )(

    !2

    )('')()()(

    ++

    +

    +=

    =

    ++

    ++++=

    nn

    n

    i

    n

    ni

    n

    iiiii

    hn

    fR

    nowistermremainderthewhere

    xix

    Rhn

    xf

    hxf

    hxf

    hxfxfxf

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    18/41

    Useful estimates

    Note that powers ofh are much smaller than

    h.

    Hence, for small values ofh, the infinite

    series can be truncated.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    19/41

    Order of approximation

    If the nth order derivative is included in the

    Taylor series, the approximation is said be

    of order n.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    20/41

    Applications of TSE

    Extrapolation Numerical Differentiation

    Error estimates

    Error propagation

    Condition number

    Root finding

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    21/41

    Finite difference Formulas

    forward difference

    backward difference

    central difference

    where: h is the step size

    O(h) and O(h2) are the truncation errors

    )()()(

    )(1

    1' hOxx

    xfxfxf

    ii

    iii +

    =

    +

    +

    )()()(

    )( 1' hO

    h

    xfxfxf iii +

    =

    )(2

    )()()( 211' hO

    h

    xfxfxf ii +

    = +

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    22/41

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    23/41

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    24/41

    A structured grid

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    25/41

    Unstructured grid

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    26/41

    Complex geometry

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    27/41

    Solving a partial differential equation

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    28/41

    Construction of a system of algebraicequations

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    29/41

    Time dependent problems

    Subjected to initial and

    boundary conditions

    One dimension

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    30/41

    Explicit and implicit approaches

    explicit

    Crank-Nicolson

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    31/41

    Implementation of an implicit technique

    Matrix equation is solved

    sequentially in time.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    32/41

    Consistency

    In the limit of the mesh size and time step

    approaching zero, the algebraic equation

    approaches the partial differential equation.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    33/41

    Stability

    The numerical algorithm does not amplifysmall errors in initial or boundary

    conditions.

    Von Neumann analysis: Look for conditionsunder which a periodic disturbance grows

    exponentially fast.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    34/41

    Stability of explicit and implicit schemes

    Implicit schemes areunconditionally stable.

    Explicit schemes are only

    conditionally stable. Fourier number criterion:

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    35/41

    Pure advection equation

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    36/41

    Stability of an explicit scheme for theadvection equation

    Courant number

    criterion (also called theCFL condition)

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    37/41

    Advection-diffusion equation

    Stability: Both Fourierand Courant number

    conditions apply.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    38/41

    Upwinding

    Consider the solution of

    the advection-diffusion

    equation by the method fo

    finite differences.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    39/41

    Artificial diffusion

    Upwinding increases effective viscosity(conductivity in transport problems).

    Oscillations in the numerical solution are

    damped.

    Need to find a compromise between a

    damped solution and an accurate solution.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    40/41

    Closure

    Finite difference method stems from the Taylorseries expansion.

    It converts a differential equation to a difference(algebraic) equation.

    Several numerical issues need to be addressed:errors,

    consistency,

    stability,oscillations,

    computational effort.

  • 8/6/2019 Lecture 4 - Taylor Series Expansion and Finite Difference Method

    41/41

    THANK YOU!