01 Numerical Integration

Embed Size (px)

Citation preview

  • 8/6/2019 01 Numerical Integration

    1/44

    Numerical integration

    Joko Wintoko

    Matematika Teknik Kimia 2JTK/FT/UGM/2011

  • 8/6/2019 01 Numerical Integration

    2/44

    Numerical integration

    There are two main reasons to do numerical

    integration:

    analytical integration may be impossible or infeasible,

    or

    you may wish to integrate tabulated data rather than

    known functions.

    Methods:

    Trapezoidal rule

    Simpson's rule

    Gauss quadrature

  • 8/6/2019 01 Numerical Integration

    3/44

    Manual method

    Manual method for determining integral by superimposing a grid on a graph of the

    integrand. The boxes indicated in grey are counted.

  • 8/6/2019 01 Numerical Integration

    4/44

    Newton-Cotes Integration

  • 8/6/2019 01 Numerical Integration

    5/44

    Trapezoidal rule

  • 8/6/2019 01 Numerical Integration

    6/44

    Trapezoidal rule

  • 8/6/2019 01 Numerical Integration

    7/44

  • 8/6/2019 01 Numerical Integration

    8/44

  • 8/6/2019 01 Numerical Integration

    9/44

  • 8/6/2019 01 Numerical Integration

    10/44

  • 8/6/2019 01 Numerical Integration

    11/44

  • 8/6/2019 01 Numerical Integration

    12/44

  • 8/6/2019 01 Numerical Integration

    13/44

  • 8/6/2019 01 Numerical Integration

    14/44

  • 8/6/2019 01 Numerical Integration

    15/44

    Simpsons Rule

  • 8/6/2019 01 Numerical Integration

    16/44

    Basis of Simpsons 1/3rd RuleTrapezoidal rule was based on approximating the

    integrand by a first order polynomial, and then

    integrating the polynomial in the interval of

    integration. Simpsons 1/3rd rule is an extension of

    Trapezoidal rule where the integrand is approximatedby a second order polynomial.

    Hence

    }!b

    a

    b

    a

    dx)x(fdx)x(fI2

    Where is a second order polynomial.)x(f2

    2

    2102xaxaa)x(f !

  • 8/6/2019 01 Numerical Integration

    17/44

    Basis of Simpsons 1/3rd Rule

    }!b

    a

    b

    a

    dx)x(fdx)x(fI2

    f(x)

    f2(x)

    2

    2102xaxaa)x(f !

  • 8/6/2019 01 Numerical Integration

    18/44

    Basis of Simpsons 1/3rd Rule

    Choose

    )),a(f,a( ,ba

    f,ba

    22))b(f,b(and

    as the three points of the function to evaluate a0, a1 and a2.

    2

    2102aaaaa)a(f)a(f !!

    2

    2102 2222

    !

    !

    ba

    a

    ba

    aa

    ba

    f

    ba

    f

    2

    2102babaa)b(f)b(f !!

  • 8/6/2019 01 Numerical Integration

    19/44

    Basis of Simpsons 1/3rd Rule

    Solving the previous equations for a0, a1 and a2 give

    22

    22

    0 2

    24

    baba

    )a(fb)a(abfba

    abf)b(abf)b(fa

    a

    !

    221

    2

    2433

    24

    baba

    )b(bfba

    bf)a(bf)b(afba

    af)a(af

    a

    !

    222

    2

    222

    baba

    )b(fba

    f)a(f

    a

    !

  • 8/6/2019 01 Numerical Integration

    20/44

    Basis of Simpsons 1/3rd Rule

    Then

    }b

    a

    dx)x(fI2

    !b

    adxxaxaa

    2

    210

    b

    a

    xa

    xaxa

    !32

    3

    2

    2

    10

    32

    33

    2

    22

    10

    aba

    aba)ab(a

    !

  • 8/6/2019 01 Numerical Integration

    21/44

    Basis of Simpsons 1/3rd Rule

    Substituting values of a0, a1, a 2 give

    !

    )b(f

    baf)a(f

    abdx)x(f

    b

    a 2

    4

    62

    Since for Simpsons 1/3rd Rule, the interval [a, b] isbroken

    into 2 segments, the segment width

    2

    abh

    !

  • 8/6/2019 01 Numerical Integration

    22/44

    Basis of Simpsons 1/3rd Rule

    ! )b(f

    baf)a(f

    hdx)x(f

    b

    a 2

    4

    3

    2

    Hence

    Because the above form has 1/3 in its formula,it is called Simpsons 1/3rd Rule.

  • 8/6/2019 01 Numerical Integration

    23/44

  • 8/6/2019 01 Numerical Integration

    24/44

  • 8/6/2019 01 Numerical Integration

    25/44

  • 8/6/2019 01 Numerical Integration

    26/44

  • 8/6/2019 01 Numerical Integration

    27/44

  • 8/6/2019 01 Numerical Integration

    28/44

  • 8/6/2019 01 Numerical Integration

    29/44

    Gaussian Quadratures

    Newton-Cotes Formulae

    use evenly-spaced functional values

    Gaussian Quadratures

    select functional values at non-uniformly distributed

    points to achieve higher accuracy

    change of variables so that the interval of integration

    is [-1,1]

    Gauss-Legendre formulae

  • 8/6/2019 01 Numerical Integration

    30/44

    Gaussian Quadratures

    Trapezoidal rule Gaussian quadrature

  • 8/6/2019 01 Numerical Integration

    31/44

    Gaussian QuadratureQuadrature onon [[--1, 1]1, 1]

    Choose (c1, c2, x1, x2) such that the method

    yields exact integral forf(x) = x0, x1, x2,x3

    )x(fc)x(fc)x(fc)x(fcdx)x(f nn2211i1

    1

    n

    1i

    i !} ! .

    )f(xc)f(xc

    f(x)dx:2n

    2211

    1

    1

    !

    !

    x2x1-1 1

  • 8/6/2019 01 Numerical Integration

    32/44

    Gaussian Quadrature onGaussian Quadrature on [[--1, 1]1, 1]

    Exact integral forf = x0, x1, x2, x3

    Four equations for four unknowns

    )f(xc)f(xcf(x)dx:2 2211

    1

    1 !!

    !

    !

    !!

    !!!

    !!!

    !!!

    !!!

    31x

    3

    1x

    1c1c

    xcxc0dxxxf

    xcxc

    3

    2dxxxf

    xcxc0xdxxf

    cc2dx11f

    2

    1

    2

    1

    3

    22

    3

    1

    1

    11

    33

    2

    22

    2

    1

    1

    11

    22

    221

    1

    11

    2

    1

    11

    )

    3

    1(f)

    3

    1(fdx)x(fI

    1

    1!!

  • 8/6/2019 01 Numerical Integration

    33/44

    Gaussian Quadrature onGaussian Quadrature on [[--1, 1]1, 1]

    Choose (c1, c2, c3, x1, x2, x3) such that

    the method yields exact integral for

    f(x) = x0

    , x1

    , x2

    ,x3

    ,x4

    , x5

    )x(fc)x(fc)x(fcdx)x(f:3 3322111

    1 !!

    x3x1-1 1x2

  • 8/6/2019 01 Numerical Integration

    34/44

    Gaussian Quadrature onGaussian Quadrature on [[--1, 1]1, 1]

    5

    33

    5

    22

    5

    11

    1

    1

    55

    4

    33

    4

    22

    4

    11

    1

    1

    44

    3

    33

    3

    22

    3

    11

    1

    1

    33

    2

    33

    2

    22

    2

    11

    1

    1

    22

    332211

    1

    1

    321

    1

    1

    0

    0

    5

    2

    0

    3

    2

    0

    21

    xcxcxcdxxxf

    xcxcxcdxxxf

    xcxcxcdxxxf

    xcxcxcdxxxf

    xcxcxcxdxxf

    cccdxxf

    !!!

    !!!

    !!!

    !!!

    !!!

    !!!

    !

    !

    !

    !

    !

    !

    5/3

    0

    5/3

    9/5

    9/8

    9/5

    3

    2

    1

    3

    2

    1

    x

    x

    x

    c

    c

    c

  • 8/6/2019 01 Numerical Integration

    35/44

    Gaussian Quadrature onGaussian Quadrature on [[--1, 1]1, 1]

    Exact integral forf = x0, x1, x2, x3,x4, x5

    )5

    3(f

    9

    5)0(f

    9

    8)

    5

    3(f

    9

    5dx)x(fI

    1

    1!!

  • 8/6/2019 01 Numerical Integration

    36/44

    Gaussian Quadrature onGaussian Quadrature on [a, b][a, b]

    Coordinate transformation from [a,b] to [-1,1]

    t2t1a b

    !

    !1

    1

    1

    1

    b

    adx)x(gdx)

    2

    ab)(

    2

    abx

    2

    ab(fdt)t(f

    !!

    !!

    !

    bt1x

    at1x2

    abx

    2

    abt

  • 8/6/2019 01 Numerical Integration

    37/44

    Example: Gaussian QuadratureExample: Gaussian Quadrature

    Evaluate

    Coordinate transformation

    Two-point formula

    33.34%)(543936.3477376279.3468167657324.9

    e)3

    44(e)

    3

    44()

    3

    1(f)

    3

    1(fdx)x(fI 3

    44

    3

    441

    1

    !!!

    !

    !!

    I

    926477.5216dtteI4

    0

    t2 !!

    !!!

    !!

    !

    1

    1

    1

    1

    4x44

    0

    t2 dx)x(fdxe)4x4(dtteI

    2dxdt;2x2

    2

    abx

    2

    abt

  • 8/6/2019 01 Numerical Integration

    38/44

    Example: Gaussian QuadratureExample: Gaussian QuadratureThree-point formula

    Four-point formula

    4.79%)(106689.4967

    )142689.8589(95)3926001.218(

    98)221191545.2(

    95

    e)6.044(9

    5e)4(

    9

    8e)6.044(

    9

    5

    )6.0(f9

    5)0(f

    9

    8)6.0(f

    9

    5dx)x(fI

    6.0446.04

    1

    1

    !!

    !

    !

    !!

    I

    ? A? A

    %)37.0(54375.5197

    )339981.0(f)339981.0(f652145.0

    )861136.0(f)861136.0(f34785.0dx)x(fI1

    1

    !!

    !!

    I

  • 8/6/2019 01 Numerical Integration

    39/44

  • 8/6/2019 01 Numerical Integration

    40/44

    Contoh

    Kerja yang dilakukan oleh sebuah proses termodinamis

    dengan suhu tetap dapat dihitung dengan persamaan:

    dengan W = kerja, p = tekanan, dan V = volume.

    Hitunglah kerja yang dilakukan dengan data sebagai

    berikut:

    ! pdVW

    Tekan

    an,

    kPa

    336 494.4 266.4 260.8 260.5 249.6 193.6 165.6

    Volu

    me,

    m3

    0.5 2 3 4 6 8 10 11

  • 8/6/2019 01 Numerical Integration

    41/44

    Memakai aturan trapezoidal

    P V (V Pi+1 + Pi Ii = (V/2*(Pi+1 + Pi)

    336 0.5

    294.4 2 1.5 630.4 472.8

    266.4 3 1 560.8 280.4

    260.8 4 1 527.2 263.6

    260.5 6 2 521.3 521.3

    249.6 8 2 510.1 510.1

    193.6 10 2 443.2 443.2

    165.6 11 1 359.2 179.6

    I 2671

  • 8/6/2019 01 Numerical Integration

    42/44

    Memakai aturan trapezoidal

    Jadi kerja yang dilakukan adalah 2671 kJ

  • 8/6/2019 01 Numerical Integration

    43/44

    Memakai aturan Simpson 1/3

    V P (V

    Faktor utk

    P

    (Simpson'

    s rule)

    Faktor * P Pi+1 + Pi Ii Metode

    0.5 336Trapz

    2 294.4 1.5 630.4 472.8

    2 294.4 1 294.4

    540.2667 Simps3 266.4 1 4 1065.6

    4 260.8 1 1 260.8

    4 260.8 1 260.8

    1034.933 Simps6 260.5 2 4 10428 249.6 2 1 249.6

    8 249.6

    Trapz10 193.6 2 443.2 443.2

    11 165.6 1 359.2 179.6

    I 2670.8

  • 8/6/2019 01 Numerical Integration

    44/44

    Memakai aturan Simpson 1/3

    Jadi kerja yang dilakukan adalah 2670,8

    kJ