5 Nu Mint

Embed Size (px)

Citation preview

  • 8/6/2019 5 Nu Mint

    1/4

    Numerical Integration

    Introduction To integrate a given function f(x) between limits [a,b], the general methodis to identify f(x) as the derivative of another function g(x) and then applying thefundamental theorem of calculus; ie,

    I = ab f(x) dx = ab [ dg(x)/dx] dx =g(b)-g(a)

    Handbooks of tables of integrals are available for this purpose. Commercial softwares arealso available for performing symbolic computations that include evaluation of commonderivatives and integrals. However, in many cases, close-form expression for integrationdoes not exist, particularly when f(x) is generated from experimental measurements.Even when an analytical expression for f(x) is available, there is no guarantee that aclosed form expression for the integral exists. In such cases, numerical methods areemployed to find the integral.

    To find an estimate for the integral I = a

    b

    f(x) dx the interval [a,b] is sampled at m+1equally spaced points, xo, x1, x2, ..,xm with xo = a and xm+1 = b. The step size is h= (b-a)/mand the following data table of x vs f(x) may be generated:

    x = xo x1 x2 Xmf(x)= f o f1 f2 fm

    Where, xk = xo + k.h and fk= f(xk)

    The basic approach to find the integral is to approximate f(x) by an interpolatingpolynomial pn(x) of degree n and integrate it between the specified limits. The resulting

    expression for the integral would be a weighted sum of values of f(x).Newton-Cotes Integration Formulae

    In Newton-Cotes Integration Formulae, the interpolating polynomials are obtainedthrough Newtons forward interpolation formula which expresses f(x) as a polynomial inp, where, x= (xo+ ph), in terms of fo and forward differences of higher orders at fo as :

    f(x) = f(xo+ ph) = fo + p.fo + p.(p-1). 2fo / 2! +p.(p-1)(p-2). 3fo/ 3! + ..+ p.(p-1).(p-2).(p-n+1) nfo / n! + En+1(p)

    Where, En+1(p) p.(p-1).(p-2).(p-n).

    n+1

    f0/(n+1)!it may be shown that, n+1 f0 f(n+1)().hn+1/(n+1)!

    is the remainder after nth order difference term in f(xo+ ph). Thus, if the above series isterminated after nth order term, the error shall be of the order of hn+1, written as O(hn+1), being a point in [a,b]

  • 8/6/2019 5 Nu Mint

    2/4

    Thus, f(x) pn(x)= fo + p.fo + p.(p-1). 2fo / 2! +p.(p-1)(p-2). 3fo/ 3! + + p.(p-1).(p-2).(p-n+1) nfo / n!

    The Trapezoidal Rule:

    The simplest of the Newton-Cotes integration formula, the Trapezoidal Rule may be

    derived by truncating the above infinite series after the first-order difference term. Thus,f(x) = f(xo+p.h) f(xo) + p.fo

    where, x = xo+ p.h, dx = h.dp and when x = xo,p=0 and when x=x1, p=1

    Therefore, the integral xo x1 f(x) dx = o 1{fo + p.fo}h.dp= h( fo + fo/2) = h/2(fo +f1)

    The error in the approximation is E = o 1E2(p).h.dp = o 1p(p-1).f(2)( ) dp.h3/2!= (1/3 1/2) f(2)( ).h3 /2! = - 1/12h3. f(2)( )

    Thus the error in a single step of trapezoidal formula is O(h3), of the order of h3 and maybe significant, if h is large. h may be made smaller by splitting the interval [a,b] into mequally spaced panels, each of width h=(b-a)/m. With this modification,

    a b f(x) dx = xo x1 f(x) dx+ x1 x2 f(x) dx+.+ x m-1 xm f(x) dx= h/2{ fo +2( f1 + f2 ++fm-1) +fm }

    There shall be some error in integration of each panel and the overall error for m suchpanels becomes - m/12h3. f(2 )( ), where, f(2 )( ) represents average of f(2)( ) over mintervals. Since m = (b-a)/h, the overall error in the result shall be

    E2= - h2(b-a). f(2 )( )/12, which is of the order of h2.

    Simpsons Rules

    Simpsons rules are based on approximating f(x) by higher degree interpolating polynomials. This improves accuracy of the formula. Thus, Simpsons 1/3rd rule isderived by retaining up to third order differences of the interpolation formula, and

    integrating over 2 panels

    f(x) = f(xo+ ph) fo + p.fo + p.(p-1). 2fo / 2! +p.(p-1)(p-2). 3fo/ 3!

    The error involved in the process is E4(p) = p.(p-1).(p-2)(p-3). f(4)().h4/4!Now integrating above approximate expression of f(x) over 2-panels, we have,

    xo x2 f(x) dx = 0 2 f(xo+ ph) h.dp= h. 0 2 { fo + p.fo + p.(p-1). 2fo / 2! +p.(p-1)(p-2). 3fo/ 3!}.dp= h.{2.f0 + 4/2.fo + ( 8/3 - 4/2).2fo / 2 + (16/4 3.8/3 + 2.4/2) . 3fo/ 6}

  • 8/6/2019 5 Nu Mint

    3/4

    = h{ 2fo + 2.fo + 1/3.2fo}= h{ 2fo +2(f1 f0) +1/3(f2- 2f1 +fo)}= h/3(fo + 4f1 +f2)

    The error involved in the process may be estimated as

    E= o 2

    E4(p) h.dp = o 2

    {p.(p-1).(p-2)(p-3). f(4)

    ().h4

    /4!}h.dp= h5/24. o 2{p4 6p3 +11p2 6p} f(4)()= h5/24{ 32/5 6. 16/4 +11.8/3 6.4/2}= -1/90 f(4)().h5

    The formula truncation error in 2-panels is of the order of h5. Dividing the interval [a,b]of integration into even no of panels, m, the composite formula for the integral and theerror shall be respectively,

    xo xm f(x) dx = h/3 { (fo+fn) + 4(f1+f3++fm-1) + 2(f2 +f4 + fm-2)}

    and E4 = -1/180.(b-a) f

    (4)

    () .h

    4

    , which is of the order of h

    4

    .

    Simpsons 3/8th rule may be derived by using a cubic polynomial, once again, but

    integrating over 3 panels instead of 2.

    xo x3 f(x) dx = 0 3 f(xo+ ph) h.dp= h. 0 3 { fo + p.fo + p.(p-1). 2fo / 2! +p.(p-1)(p-2). 3fo/ 3!}.dp= h{3fo + 9/2.fo + (27/3-9/2) 2fo/2+(81/4-3.27/3+2.9/2) 3fo/ 6}= h{ 3fo+9/2(f1-fo) +9/4.(f2-2f1+fo) +3/8.(f3-3f2+3f1-f0)}

    = 3/8.h{fo+ 3f1+3f2 +f3}The formula truncation error involved in the process may be estimated as

    E= o 3 E4(p) h.dp = o 3 {p.(p-1).(p-2)(p-3). f(4)().h4/4!}h.dp= h5/24. o 3{p4 6p3 +11p2 6p} f(4)()= h5/24{ 243/5 6.81/4 +11.27/3 6.9/2}= -1/90 f(4)().h5= -3/80 f(4)().h5

    Here again, the local error in integrating over 3-panels is of the order of h

    5

    as in1/3

    rd

    rule.More generally, if there are multiple of 3 no. of panels, the above formulae may bemodified to

    xo xm f(x) dx = 3/8.h{(fo + fm) +3.(f1+f2+f4+f5+fm-2+fm-1) + 2(f3+f6+f9 ++fm-3)}

    and the composite truncation error shall be E4 = -3/80.(b-a) f(4)() .h4

    Example:

  • 8/6/2019 5 Nu Mint

    4/4

    To illustrate the relative accuracies Newton-Cotes integration formula of the differentorder, consider integration

    I= a b ex .dx /(eb ea)

    The exact value of the above integral is 1.

    The results obtained by the above methods for a= 0 and b=1, using different values of mare given in following table:

    For m=2:

    x= 0 3/6 1

    f(x)= 0.5819767 0.9595173 1.5819767

    No. ofpanels

    Trapezoidalrule

    Simpsons1/3 rd. rule

    2 1.0207470 1.0003371

    For m=6

    x= 0 1/6 2/6 3/6 4/6 5/6 1f(x)= 0.581976

    70.687524

    20.812213

    90.959517

    31.33535

    91.339114

    41.5819767

    No. ofpanels

    Trapezoidal

    Simpsons1/3 rd. rule

    Simpsons3/8 rd. rule

    6 1.0023137 1.000004

    3

    1.0000122