Top Banner
9/11/2012 1 WEEK 1 Introduction to Numerical Methods Mathematical modeling Approximation and round off errors Truncation errors and Taylor Series 2 At the end of this topic, the students will be able: To describe numerical techniques as compared to analytical methods To use Taylor series expansion to approximate a function To perform error analysis associated with numerical methods LESSON OUTCOMES
16
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 9/11/2012

    1

    WEEK 1

    Introduction to Numerical Methods Mathematical modeling

    Approximation and round off errors

    Truncation errors and Taylor Series 2

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

    To describe numerical techniques as

    compared to analytical methods

    To use Taylor series expansion to approximate

    a function

    To perform error analysis associated with

    numerical methods

    LESSON OUTCOMES

  • 9/11/2012

    2

    4

    Why Numerical Method?

    Could handle large systems of equations, nonlinearity and complex geometries that is not

    common

    It provide approximate solutions to many of the engineering problems.

    Powerful analysis tool in problem solving and understanding problem in mathematical language

    Techniques by which mathematical problems are formulated, so that they can be solved with

    arithmetic operations

    The role of numerical method in solving engineering problem:

    5

    What is Numerical Method

    PROBLEM

    FORMULATION

    Fundamental laws are used to

    develop mathematical

    equations that can represent

    the specific problem

    SOLUTION

    Suitable numerical methods

    are then selected to solve

    the mathematical equations

    INTERPRETATION

    The results obtained can

    then be used to

    predict/analyze/understand

    the specific problem better

    6

    Is the use of mathematics to

    Describe real world phenomena

    Investigate important questions about the observed world

    Explain real world phenomena

    Test ideas

    Make predictions about the real world

    The real world refers to Engineering Physics

    Physiology Ecology

    Wildlife management Chemistry

    Economics Sports

    Etc

    Mathematical modeling

  • 9/11/2012

    3

    A mathematical model is represented as a functional relationship of the form

    7

    Dependent variable

    Observed behaviour/state/phenomenon of a system

    Characteristic that reflects behaviour or state of the system i.e. y, f(x), f(t)

    Independent variable

    Dimension that determine a system i.e. time, t , x

    Parameter

    Quantity that serves to relate to functions and variables Reflective of the systems properties or composition

    Forcing functions

    External influence that acts on system i.e. acceleration gravity, g

    8

    Example

    9

    Apply Newtons second law, F = ma

    And also can write as

    Fdt

    xdm

    or

    Fdt

    dvm

    2

    2

    Eq. relates a linear position x (dependent variable) to the applied

    force, F (forcing function) and the time, t (independent variable). The mass, m is the only parameter in the above model.

  • 9/11/2012

    4

    Example of mathematical modeling

    10

    11

    Example

    Assume that interested to predict the velocity of the falling parachutist with time

    Use fundamental knowledge to find a mathematical equation correlates the velocity

    to the various forces acting on the parachutist

    Newtons 2nd law of Motion

    the time rate change of momentum of a body is equal to the resulting force acting on

    it.

    The model is formulated as

    F = ma

    F=net force acting on the body (N)

    m=mass of the object (kg)

    a=its acceleration (m/s2)

    12

    m

    F

    dt

    dv

    dt

    dv

    aon accelerati

    resistanceair of force upward

    gravity of force downward

    UF

    DF

    UFDFF

    cvUF

    mgDF

    vm

    cg

    m

    cvmg

    dt

    dv

    Model relates acceleration of falling

    object to the forces acting on it,

    (differential equation)

  • 9/11/2012

    5

    13

    Exact or analytical solution: it exactly satisfies the original equation

    dependent variable

    independent variable

    forcing functions

    parameter

    t,s v,(m/s)

    0 0.00

    2 16.40

    4 27.77

    6 35.64

    8 41.10

    10 44.87

    12 47.87

    53.39

    Analytical solution of the parachutist

    14

    Unfortunately, there are many mathematical

    models that cannot be solved exactly.

    Numerical solution that approximates the exact solution

    15

    )(1

    )()1

    (

    1

    )()1

    (

    it

    ii

    it

    it

    ii

    it

    it

    vm

    cg

    tt

    vv

    tt

    vv

    t

    v

    dt

    dv

    vm

    cg

    m

    cvmg

    dt

    dv

    )( 1)()()( 1 iittt ttvm

    cgvv

    iii

    The use of finite difference to approximate the

    first derivative of v with respect to t

    Approximate or

    numerical solution

  • 9/11/2012

    6

    16

    t,s v,(m/s)

    0 0.00

    2 19.60

    4 32.00

    6 39.85

    8 44.82

    10 47.97

    12 49.96

    53.39

    Numerical solution

    )( 1)()()( 1 iittt ttvm

    cgvv

    iii

    Comparison between the exact and

    numerical solution

    Approximation and Roundoff Errors

    Significant figures

    98

    98.09

    0.0098

    Numbers to be used in confidence

    2 significant figures

    4 significant figures

    2 significant figures

    17

    18

    Important of significance figures in numerical methods:

    Numerical methods yield approximate results, therefore, need to develop criteria to specify the confident in

    approximate result.

    Although quantities such as , e, or 7 represent specific quantities, they cannot be expressed exactly by a limited

    number of digits. Computers retain only a finite number of

    significant figures.

    = 3.141592653589793238462643

  • 9/11/2012

    7

    Accuracy and Precision

    19

    Inaccurate & imprecise

    accurate & precise Inaccurate & precise

    accurate & imprecise

    Increasing accuracy In

    cre

    as

    ing

    pre

    cis

    ion

    How closely a computed

    or measured value agree

    with the true value

    How closely individual

    computed or measured

    values agree with each

    other

    Error definitions

    True value

    Approximation

    value

    Error

    True value = Error + Approximation value

    20

    Truncation errors ~ result

    when approximations are

    used to represent exact

    mathematical procedures

    Round-off errors ~ result

    when numbers having a

    limited significant figures

    are used to represent

    exact numbers

    t designates true percent relative error

    True value = error + approximation value

    True error (Et)= true value approximation

    21

    (1)

    (2)

    (3)

  • 9/11/2012

    8

    Calculation of errors

    True value of length of a bridge is 10,000 cm.

    When you measure, the length recorded is

    9,999 cm. Compute the true error and true

    percentage relative error of the bridge.

    Answer: 1 cm and 0.01%

    22

    However, in actual situation, true value is rarely available. Therefore, need to estimate the true value approximation

    In numerical method, iterative approach is used to compute answer, in which error is estimated as the

    difference between previous and current approximations.

    The signs of error can be negative or positive,

    Absolute value of error, |a| need to be lower than prespecified percent tolerance, s

    n is significant figures. 23

    (4)

    (5)

    Error estimates for iterative method

    Suppose that we have exponential function as,

    Starting with the simplest version, ex=1, add terms to estimate e0.5. Compute true (t) and approximate error (a) after each term is added until |a| falls below s , conforming to 3 significant figures. Note that true value of e0.5

    is 1.648721.

    24

  • 9/11/2012

    9

    Answer

    25

    Round-off errors

    ln 2 = 0.693 147 180 559 945 309 41...

    A device only shows 8

    significant numbers, so

    round-off error is discrepancy

    introduced by omission of

    significant figures.

    Round-off error for this case is

    0.00000000055994530941

    26

    Results when numbers having limited significant

    figures are used to represent exact numbers

    Other example of roundoff error

    27

  • 9/11/2012

    10

    Truncation errors and Taylor series

    28

    Truncation errors

    Truncation error is the discrepancy introduced by the fact that numerical methods may employ approximations to represent exact

    mathematical operations and quantities.

    Truncation error are errors resulted from using an approximation in place of an exact mathematical procedure.

    The difference between the calculated value using exact mathematical equation and approximation mathematical equation.

    Zero order

    First order

    Second

    order

    nth order

    29

    Provides a means to predict a function value at one point in terms of the

    function value and its derivative at another point

    Taylor series

    30

    (6)

    (7) 1

    )1(

    )!1(

    )(

    n

    n

    n hn

    fR

    Taylor series by defining a step size h = xi+1 - xi

  • 9/11/2012

    11

    31

    32

    Let say we truncated the Taylor series expansion after zero-order term to yield

    Remainder term, Rn for zero order version

    Let truncate the remainder itself,

    This result is still inexact because neglected second and higher order terms.

    )()( 1 ii xxff

    ...!3!2

    ''' 3

    )(3

    2)(

    )(0 hf

    hf

    hfR iii

    xx

    x

    hfRix )(0

    '

    Remainder term, Rn, accounts for all terms from (n+1) to infinity.

    It also usually expressed as:

    )( 1 nn hOR

    1)1(

    )!1(

    )(

    n

    n

    n hn

    fR

    Remainder for the Taylor series Expansion

    33

    Alternative simplification that tranforms the approximation into an equivalence based on graphical insight

    derivative mean-value theorem states that if a function f(x) and its derivative are continous over interval from xi to xi+1, there exist at least one point on the function that has a slope, designated by f(), parallel to line joining f (xi) and f(xi+1)

    Thus,

    So,

    Zero order version

    First order version

  • 9/11/2012

    12

    Numerical differentiation

    Forward finite divided difference

    Backward finite divided difference

    Centered finite divided difference

    34

    35

    Forward finite divided difference approximation of first derivative

    Backward finite divided difference approximation of first derivative

    Centered finite divided difference approximation of first derivative

    Where, (14)

    (15)

    (16)

    (17)

    O(h)h

    f)f'(x

    h

    R

    h

    )f(x)f(x)f'(x

    ii

    iii

    111 ii xxhWhere,

    11 iiii xxxxhWhere,

    36

    Use forward and backward difference approximations of O(h) and a centered

    difference approximation of O(h2) to estimate the first derivative of

    2.125.05.015.01.0f 234 xxxx)(xi

    at x = 0.5 using a step size h = 0.5. Repeat using h = 0.25. Also calculate the

    true percent relative error for each approximation.

    Example

  • 9/11/2012

    13

    37

    Exercise

    Use forward and backward and a centered difference to estimate the first

    derivative of the function

    7.08.01.05.0f 23 xxx)(xi

    at x = 0.5 using a step size h=0.5. Repeat using h = 0.25. Also calculate the

    true percent relative error for each approximation.

    Ans:

    h=0.5

    FDM:1.525 41.9%

    BDM:0.875 18.60%

    CDM:1.200 11.63%

    h=0.25

    FDM:1.26875 18.02%

    BDM:0.94375 12.21%

    CDM:1.10625 2.91%

    38

    Second forward finite difference approximation of higher derivatives

    Second backward finite difference approximation of higher derivatives

    Second centred finite difference approximation of higher derivatives

    Higher derivatives

    39

    Error propagation This section is to study how errors in numbers can

    propagate through mathematical functions. If we multiply

    two numbers that have errors, we would like to estimate

    the error in the product.

    If a function f is dependent on

    (a) a single independent variable x : f(x)

    (b) two independent variables x and y : f(x, y)

    (c) several independent variables x1, x2, x3, ... ,xn : f(x1 , x2 ,..., xn ).

  • 9/11/2012

    14

    40

    Function of a single variable.

    Let x be the true value and

    x* be an approximate value of x

    Then, TSE for f(x) computed near f(x*) is given by

    ...*)(

    2

    *)(''*)(* 2 xx

    xfxx)f'(xf(x*)f(x)

    Truncating after the first derivative term and rearranging the remaining terms

    to give

    where

    **)'

    *)*)('

    x(xff(x*)

    xx(xff(x*)f(x)

    xxxx

    xfxf(xf

    t variableindependen oferror theof estimatean is **

    function theoferror theof estimatean is *)()(*)'

    Eq.(21) provides 2 capabilities:

    1. to approximate the error in f(x) knowing its derivative.

    2. to approximate the error in the independent variable x.

    (21)

    41

    Example

    Given a value of x* = 2.5 with an error of x* = 0.01, estimate the

    resulting error in the function, f(x)=x3.

    Solution

    187506251552

    atpredict thcan it ,625.15)5.2( Because

    1875.0)01.0()5.2(3

    So,

    **)'

    2

    . .).f(

    f

    f(x*)

    x(xff(x*)

    Or the true value lies between 15.4375 and 15.8125. In fact, if x ~2.49,

    f(x) could be 15.4382 and if x ~ 2.51, it would be 15.8132.

    The first order error analysis provides a fairly close estimate of the true error.

    42

    Exercise

    Knowing a value of x* = 2.0 with an error of x* = 0.01, estimate the resulting error in the function

    f(x) = 0.5x3-0.1x2+0.8x-0.7

    Ans: f(2.0)=4.5 0.064

  • 9/11/2012

    15

    43

    Function of a more than One variable.

    (22)

    (23)

    Refer section 4.2.2

    for examples

    44

    Relative error

    Condition number

    Refer section 4.2.3

    for example

    =

    =

    Condition no equals 1 indicates that functions relative error is identical to the relative error in

    x

    Condition no greater than 1 indicates relative error is amplified.

    Condition no less than 1 indicates relative error is attenuated.

    Function with very large values are said to be ill-conditioned.

    45

  • 9/11/2012

    16

    Total numerical errors = truncation error + round off error

    46

    Roundoff error by increase no. of significant figures or

    reduce no. of computation in analysis

    Truncation error by decreasing step size (h) or increase

    no. of computation in analysis

    Total Numerical Error

    Control numerical error

    avoid subtract 2 nearly equal numbers to avoid loss of significance

    Use Taylor series for truncation and roundoff error analysis

    Perform numerical experiments

    - repeat computation with different step size or method and compare results

    47