1. intro_rev

Embed Size (px)

Citation preview

  • 8/11/2019 1. intro_rev

    1/44

    TEKNIK KOMPUTASI

    (TEI 116)3 SKS

    Oleh: Husni Rois Ali, S.T., M.Eng.

    Noor Akhmad Setiawan, S.T., M.T., Ph.D.

    Email : [email protected] or

    [email protected]

    Personal web: husniroisali.staff.ugm.ac.id

  • 8/11/2019 1. intro_rev

    2/44

    Grading

    First Half (tentative)

    Midterm (80%)

    Homework, quiz, etc. (20%)

    Second Half (?)

  • 8/11/2019 1. intro_rev

    3/44

    References:

    Numerical Methods for Engineers, Sixth Edition

    by Steven Chapra(Author), Raymond

    Canale(Author)

    http://numericalmethods.eng.usf.edu

    http://www.amazon.com/s/ref=dp_byline_sr_book_1?ie=UTF8&field-author=Steven+Chapra&search-alias=books&text=Steven+Chapra&sort=relevancerankhttp://www.amazon.com/s/ref=dp_byline_sr_book_2?ie=UTF8&field-author=Raymond+Canale&search-alias=books&text=Raymond+Canale&sort=relevancerankhttp://www.amazon.com/s/ref=dp_byline_sr_book_2?ie=UTF8&field-author=Raymond+Canale&search-alias=books&text=Raymond+Canale&sort=relevancerankhttp://numericalmethods.eng.usf.edu/http://numericalmethods.eng.usf.edu/http://www.amazon.com/s/ref=dp_byline_sr_book_2?ie=UTF8&field-author=Raymond+Canale&search-alias=books&text=Raymond+Canale&sort=relevancerankhttp://www.amazon.com/s/ref=dp_byline_sr_book_2?ie=UTF8&field-author=Raymond+Canale&search-alias=books&text=Raymond+Canale&sort=relevancerankhttp://www.amazon.com/s/ref=dp_byline_sr_book_1?ie=UTF8&field-author=Steven+Chapra&search-alias=books&text=Steven+Chapra&sort=relevancerankhttp://www.amazon.com/s/ref=dp_byline_sr_book_1?ie=UTF8&field-author=Steven+Chapra&search-alias=books&text=Steven+Chapra&sort=relevancerank
  • 8/11/2019 1. intro_rev

    4/44

    What are we going to learn?

    Finding the root of the equations i.e. solve for

    Linear algebraic equation i.e. given and solve

    ( ) 0f x x

    2 3 2 0x x

    'a s 'b s

  • 8/11/2019 1. intro_rev

    5/44

    What are we going to learn? (2)

    Curve fitting

    Integration

  • 8/11/2019 1. intro_rev

    6/44

    What are we going to learn? (3)

    Ordinary differential equations (ODE)

    Partial differential equation

  • 8/11/2019 1. intro_rev

    7/44

    Analytic vs Numerical Approach

    Analytic

    You obtain the exact

    solution

    It is single step There is no error (since it is

    exact)

    Normally used for simple

    problem This is how you work

    Numerical

    You obtain approximate

    solution

    It is an iterative approach The error is a crucial factor

    Used for complex problems

    This is how your computer

    and all computationalsoftware works

  • 8/11/2019 1. intro_rev

    8/44

    Analytic vs. Numerical Approach (2)suppose you want to find the roots of 2

    Analytic

    Formulate to mathematical

    equation

    Factorize

    Then

    Numerical

    Formulate to mathematical

    equation

    Start from an arbitrary initial

    value of , e.g.

    You update the value of to

    better approximation, until you

    close enough

    How you move from one point to

    another depends on the theal orithm

    2( ) 2 0f x x

    ( 2)( 2) 0x x

    2x

    2( ) 2 0f x x

    x0 1x

    x

  • 8/11/2019 1. intro_rev

    9/44

    Introduction

    Mathematical Modeling and Engineering Problem solving

    Requires understanding of

    engineering systemsBy observation and experimentTheoretical analysis and

    generalization

    Computers are great tools,

    however, without fundamentalunderstanding of engineering

    problems, they will be useless.

  • 8/11/2019 1. intro_rev

    10/44

    1-11

    A mathematical model is represented as a functional

    relationship of the form

    Dependent independent forcing

    Variable =f variables, parameters, functions

    It ranges from a simple equation to very complex ones

    Dependent variable: Characteristic that usually reflects thestate of the system

    Independent variables: Dimensions such as time and spacealong which the systems behavior is being determined

    Parameters: reflect the systems properties or composition

    Forcing functions: external influences acting upon the system

  • 8/11/2019 1. intro_rev

    11/44

    Newtons 2ndlaw of Motion

    The model is formulated as

    F = m a

    F=net force acting on the body (N)a forcing

    function

    m=mass of the object (kg)a parameter

    a=its acceleration (m/s2) -> the dependent variable

  • 8/11/2019 1. intro_rev

    12/44

    Formulation of Newtons 2ndlaw has several

    characteristics that are typical of mathematical

    models of the physical world:

    It describes a natural process or system in

    mathematical terms

    It represents an idealization and simplification of

    reality Finally, it yields reproducible results,

    consequently, can be used for predictive purposes.

  • 8/11/2019 1. intro_rev

    13/44

    1-14

    Some mathematical models of physical phenomena

    may be much more complex.

    Complex models may not be solved exactly or

    require more sophisticated mathematical techniques

    than simple algebra for their solution

    Example, modeling of a falling parachutist:

  • 8/11/2019 1. intro_rev

    14/44

    with , andD U D U

    dv F

    dt m

    F F F F mg F cv

    dv mg cv

    dt m

    dv c

    g vdt m

    This is a differential equation and is written in

    terms of the differential rate of change dv/dt

    of the variable that we are interested in

    predicting.

    If the parachutist is initially at rest (v=0 at t=0),using calculus

    tmcec

    gmtv )/(1)(

    Independent

    variable

    Dependent

    variable

    Parameters

    Forcingfunction

  • 8/11/2019 1. intro_rev

    15/44

  • 8/11/2019 1. intro_rev

    16/44

    Write the velocity equation as

    We may obtain

    Rearranging yields

  • 8/11/2019 1. intro_rev

    17/44

  • 8/11/2019 1. intro_rev

    18/44

    Computer software

    Excel

    Matlab

    Scilab Fortran 90 (IMSL)

    C++

  • 8/11/2019 1. intro_rev

    19/44

    20

    Approximations Errors

    For many engineering problems, we cannot obtain analyticalsolutions.

    Numerical methods yield approximate results, results that areclose to the exact analytical solution. We cannot exactlycompute the errors associated with numerical methods.

    Only rarely given data are exact, since they originate frommeasurements. Therefore there is probably error in the inputinformation.

    Algorithm itself usually introduces errors as well, e.g., unavoidableround-offs, etc

    The output information will then contain error from both of thesesources.

    How confident we are in our approximate result? The question is how much error is present in our calculation

    and is it tolerable?

  • 8/11/2019 1. intro_rev

    20/44

    21

    Accuracy.How close is a computed or

    measured value to the true value

    Precision (or reproducibility).How close is a

    computed or measured value to previously

    computed or measured values. Inaccuracy(or bias).A systematic deviation

    from the actual value.

    Imprecision(or uncertainty).Magnitude ofscatter.

  • 8/11/2019 1. intro_rev

    21/44

    22

  • 8/11/2019 1. intro_rev

    22/44

    Significant Figures

  • 8/11/2019 1. intro_rev

    23/44

    24

    Significant Figures (2)

    Number of significant figures indicates precision. Significant digits of anumber are those that can be usedwith confidence, e.g.,the number ofcertain digits plus one estimated digit.

    53,800 How many significant figures?

    5.38 x 104 3

    5.380 x 104 4

    5.3800 x 104 5

    Zeros are sometimes used to locate the decimal point not significantfigures.

    0.00001753 4

    0.0001753 4

    0.001753 4

  • 8/11/2019 1. intro_rev

    24/44

    Significant Figures (3)

    Implication :

    1. Numerical methods yield approximate results. We must develop

    criteria to specify how confident we are in our approximate result.

    One way to do this is in terms of significant figures.

    2. Although quantities such as , e, or 7 represent specific quantities,they cannot be expressed exactly by a limited number of digits.

    Because computers retain only a finite number of significant figures,

    such numbers can never be represented exactly. The omission of the

    remaining significant figures is called round-off error.

  • 8/11/2019 1. intro_rev

    25/44

    26

    Error Definitions

    True Value = Approximation + Error

    Et= True valueApproximation (+/-)

    valuetrue

    errortrueerrorrelativefractionalTrue

    %100valuetrue

    errortrueerror,relativepercentTrue

    t

    True error

    F i l th d th t l ill b

  • 8/11/2019 1. intro_rev

    26/44

    27

    For numerical methods, the true value will be

    known only when we deal with functions that can

    be solved analytically (simple systems). In real

    world applications, we usually not know the answera priori. Then

    Iterative approach, example Newtons method

    %100

    ionApproximat

    erroreApproximat

    a

    %100ionapproximatCurrent

    ionapproximatPrevious-ionapproximatCurrenta (+ / -)

  • 8/11/2019 1. intro_rev

    27/44

    28

    Use absolute value.

    Computations are repeated until stopping criterion issatisfied.

    If the following criterion is met

    you can be sure that the result is correct to at least nsignificant figures.

    sa Pre-specified % tolerance based on

    the knowledge of your solution

    )%10(0.5n)-(2

    s

  • 8/11/2019 1. intro_rev

    28/44

  • 8/11/2019 1. intro_rev

    29/44

  • 8/11/2019 1. intro_rev

    30/44

    31

    Two sources of numerical error

    1) Round off error

    2) Truncation error

  • 8/11/2019 1. intro_rev

    31/44

    32

    Round-off Error

  • 8/11/2019 1. intro_rev

    32/44

    33

    Round off Error

    Caused by representing a number approximately

    It is due to the limited sources of computer in

    representing the number

    10.333333

    3 2 1.4142...

  • 8/11/2019 1. intro_rev

    33/44

    34

    Problems created by round off error

    28 Americans were killed on February 25,

    1991 by an Iraqi Scud missile in Dhahran,

    Saudi Arabia.

    The patriot defense system failed to track and

    intercept the Scud. Why?

  • 8/11/2019 1. intro_rev

    34/44

    35

    Problem with Patriot missile

    Clock cycle of 1/10 seconds was

    represented in 24-bit fixed point

    register created an error of 9.5 x 10-8

    seconds.

    The battery was on for 100

    consecutive hours, thus causing an

    inaccuracy of

    1hr

    3600s100hr

    0.1s

    s109.5 8

    s342.0

  • 8/11/2019 1. intro_rev

    35/44

    36

    Problem (cont.)

    The shift calculated in the ranging system of

    the missile was 687 meters.

    The target was considered to be out of range

    at a distance greater than 137 meters.

  • 8/11/2019 1. intro_rev

    36/44

    37

    Truncation Error

  • 8/11/2019 1. intro_rev

    37/44

    38

    Truncation error

    Error caused by truncating or

    approximating a mathematical procedure.

  • 8/11/2019 1. intro_rev

    38/44

    39

    Example of Truncation Error

    Taking only a few terms of a Maclaurin series to

    approximate

    ....................!3!2

    132

    xxxex

    xe

    If only 3 terms are used,

    !21

    2

    xxeErrorTruncation x

  • 8/11/2019 1. intro_rev

    39/44

    40

    Another Example of Truncation Error

    Using a finite x to approximate )(xf

    x

    xfxxfxf

    )()()(

    P

    Q

    secant line

    tangent line

    Figure 1. Approximate derivative using finite x

  • 8/11/2019 1. intro_rev

    40/44

    41

    Another Example of Truncation Error

    Using finite rectangles to approximate an

    integral.

    y = x2

    0

    30

    60

    90

    0 1.5 3 4.5 6 7.5 9 10.5 12

    x

  • 8/11/2019 1. intro_rev

    41/44

    42

    Example 1 Maclaurin series

    Calculate the value of2.1e with an absolute

    relative approximate error of less than 1%.

    ...................!3

    2.1

    !2

    2.12.11

    322.1

    e

    n

    1 1 __ ___

    2 2.2 1.2 54.545

    3 2.92 0.72 24.658

    4 3.208 0.288 8.9776

    5 3.2944 0.0864 2.6226

    6 3.3151 0.020736 0.62550

    aE %a2.1e

    6 terms are required.

  • 8/11/2019 1. intro_rev

    42/44

    43

    Example 2 Differentiation

    Find )3(f for2)( xxf using

    x

    xfxxfxf

    )()()(

    and 2.0x

    2.0

    )3()2.03(

    )3(' ff

    f

    2.0

    )3()2.3( ff

    2.0

    32.3 22

    2.0

    924.10

    2.0

    24.1 2.6

    The actual value is

    ,2)(' xxf 632)3(' f

    Truncation error is then, 2.02.66

    Can you find the truncation error with 1.0x

  • 8/11/2019 1. intro_rev

    43/44

    44

    Example 3 Integration

    Use two rectangles of equal width to approximate

    the area under the curve for2)( xxf over the interval ]9,3[

    y = x2

    0

    30

    60

    90

    0 3 6 9 12

    x

    9

    3

    2dxx

  • 8/11/2019 1. intro_rev

    44/44

    Integration example (cont.)

    )69()()36()(6

    2

    3

    2

    9

    3

    2 xx xxdxx

    3)6(3)3( 22 13510827

    Choosing a width of 3, we have

    Actual value is given by

    9

    3

    2

    dxx

    9

    3

    3

    3

    x

    2343

    3933

    Truncation error is then

    99135234