25
Numerical Integration Institute of Lifelong Learning, University of Delhi pg. 1 Paper: Numerical Methods Lesson :Numerical Integration Lesson Developer : Akash Varshney College/Department : Sri Venkateswara College, University of Delhi

Numerical Integration

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 1

Paper: Numerical Methods

Lesson :Numerical Integration

Lesson Developer : Akash Varshney

College/Department : Sri Venkateswara College, University of

Delhi

Page 2: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 2

Table Of Contents:

Chapter: Numerical Integration

1. Learning Outcome

2. Introduction

3. General Newton – Cotes Formula

3.1. Some Closed Newton – Cotes Formulas

3.1.1.Trapezoidal Rule

3.1.2.Simpson’s Rule

3.1.3.For n = 3 we have Simpson’s three – eighth rule

3.1.4.For n = 4 we have Boole’s Rule

3.1.5.For n = 6 we have Weddle’s Rule

3.2. Some Open Newton – Cotes Formulas

3.2.1. Mid – Point Rule

3.3. Error Analysis

3.4. Rate of Convergence

4. Weighted Mean – Value Theorem for Integrals

5. Composite Newton – Cotes Quadrature Method

6. Composite Trapezoidal Rule

7. Composite Simpson’s Rule

8. Exercise

9. Summary

10. References

Page 3: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 3

1. Learning Outcomes:

After studying this chapter you will learn that

(1) How we use Interpolation techniques (methods) to approximate the value of the

integral for the functions whose antiderivative can’t be found,

(2) Lagrange’s and Newton Interpolation formulae are used is Numerical

Integration.

(3) Effect of choice of method and number of subpartitions of interval for the

approximation of Integral is studied.

(4) Error analysis is done to see the accuracy of approximation.

(5) Comparison of the rate of convergence of different numerical formulas

like Trapezoidal Rule and Simpson’s Rule is explained.

2. Introduction:

The fundamental problem of numerical integration (which is also called numerical

quadrature) is that given a function, ‘f ’ continuous on [a, b] approximate its integral

b

aI f f x dx

Following cases arise when we try to find Integral of a function.

(i) If for the function f x its antiderivative F x exists such that F x f x

,then with the help of Fundamental Theorem of Calculus we can find

I f F b F a

(ii) In some cases for the function ,f x its antiderivative can’t be expressed in

terms of standard function (or simply can’t be found)

For example, for 2

( ) xf x e , 2

b

x

ae dx is not easy to find exactly.

Page 4: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 4

(iii) Functions used in practice are often defined in terms of discrete data, not a

formulae so methods of integration are not directly applicable.

Numerical quadrature is the process of finding or evaluating the value of a definite

integral from a set of numerical values of the integrand. The problem of numerical

integration is solved by first approximating the integrand by polynomial with the help

of an interpolation formulae and than integrating this approximation between the

smaller limits between which the entire interval is divided.

The areas are than added up to obtain the integral for the entire range.

Quadrature Formula generally is of the form

0

n

n i i

i

I f I f w f x

nI f is Newton –Cotes Approximation Integral , xi are known as the quadrature

points or abscissas and the wi are called the quadrature weights.

Value addition:

In f is a linear operator just like I f that is

In f g = In f nI g

n nI cf c I f

I.Q.1

I.Q.2

3. General Newton – Cotes Formula:

In Newton Cotes Quadrature formula xi are taken as equally spaced points from within

the intervals [a, b] and the weights wi are computed by fitting a function to the f(xi)

data and integrating the resulting function exactly.

The basic procedure for developing Newton – Cotes quadrature rules is to first fix the

abscissas 0 1 2, , ,..., ,nx x x x a b .

Page 5: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 5

Next interpolate the integrand, f, at the abscissas by the polynomial nP x . Finally we

integrate the interpolating polynomial and set

I f nI f nI P

Real value of integral of

original integrand

Newton Cotes

formula

Real value of integral of

interpolating polynomial.

Because we want the final quadrature rule to show a clear dependence on the data

values if x , the Lagrange’s form of interpolating polynomial will be used

,

0

n

n n i i

i

P x L x f x

=

0 1 1 1

0 0 1 1 1

... ...

... ...

ni i n

i

i i i i i i i i n

x x x x x x x x x xf x

x x x x x x x x x x

Newton – Cotes Quadrature formulae will take the form

,

0

nb

n n i ia

i

I f L x f x dx

,

0

n b

n i ia

i

L x dx f x

0

n

i i

i

w f x

where ,

b

i n ia

w L x dx

We have two forms of Newton – Cotes formulas which differs in their choice of the

abscissas within the interval [a, b]

(i) Closed Newton – Cotes formulas which include the end points of the

integration interval x a and x b

Here for a given ‘n’ we take /x b a n

and ix a i x 0,1,2,...,i n

Page 6: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 6

(ii) Open Newton – Cotes formulas which do not include the end points of the

integration interval

Here we take / 2x b a n

and then 1ix a i x 0,1,2,...,i n .

3.1. Some Closed Newton – Cotes Formulas:

3.1.1. Trapezoidal Rule:

In the closed Newton – Cotes formulae

We take n = 1

Then x b a and 0x a 1x b

Lagrange’s Polynomial associated with these points are

1,0

b xL x

b a, 1,1

x aL x

b a

Quadrature weights are

0

b

a

b xw dx

b a and

1

b

a

x aw dx

b a

Put x a t x dx xdt

when x a , a a t x 0t x b a

( ) ( ) 1 x b b a t x b a t b a t

1

00 2

xw x t dt =

( )

2

b a = 1w

Closed Newton – Cotes Quadrature formula for n = 1 is

Page 7: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 7

1,closed2 2

b axI f I f f a f b f a f b

Figure 1: The Trapezoidal Rule

Geometrically, this quadrature rule approximate the value of the definite integral as

the area of a trapezoid, so this rule is known as the trapezoidal rule.

3.1.2. Simpson’s Rule:

When n = 2, the quadrature formulae produces a well known formulae that is,

Simpson’s Rule.

Here

,2

b ax 0 ,x a 1 / 2 x a x a b

2 2 x a x b

Weights are calculated as

1 2

0 2,0

0 1 0 2

b b

a a

x x x xw L x dx dx

x x x x

Put x a t x dx xdt where ( )

2

b ax

when 0 x a a a t x t

when x b , 2

b ab a t

2

b ab a t

2

b at

b a

Page 8: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 8

t = 2

2

00

2

2

a t x a x a t x a x

w xdta a x a a x

=

32

20

1 2

2

t t x

x

22

03 2

2

xt t dt

2

x2

3 2

0

32

3 2

t tt

8 2

6 42 3 2 3 3

x x x

Similarly

2

1 2,10

42

3

b

aw L x dx x t t dt x

2

2 2,20

12 3

b

a

x xw L x dx t t dt

2,closed 43 2

x a bI f I f f a f f b

46 2

b a a bf a f f b

which is known as Simpson’s Rule.

3.1.3. For n = 3 we have Simpson’s three – eighth rule:

3 3 28

b aI f f a f a x f a x f b

where

3

b ax

3.1.4. For n = 4 we have Boole’s Rule:

Page 9: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 9

7 32 12 2 32 3 790

b aI f f a f a x f a x f a x f b

where / 4 x b a

3.1.5. For n = 6 we have Weddle’s Rule:

5 18 27 2 24 36

b aI f f a f a x f a x f a x

123 33 41

4 5 610 10 140

f a x f a x f a x

3.2. Some Open Newton – Cotes Formulas:

3.2.1. Mid – Point Rule:

The simplest open Newton – Cotes formulae corresponds to n = 0

/ 2

2 0 2

b a b ax b a

n

and the only abscissa is 0 / 2 x a b

The quadrature weight is

0 0,0 b b

a aw L x dx dx b a

Open Newton – Cotes Quadrature formulae is

0,open2

a bI f I f b a f (1)

The formulae given by (1) is known as Mid – Point Rule

3.2.2. For n = 1, 2

b ax

n =

3

b a

and the abscissa are 0 x a x

Page 10: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 10

1 2 x a x

Quadrature weights are

1

0 1.0

0 1

2

2

b b b

a a a

x a xx xw L x dx

x x a x a x

2

b

a

a x x

x Put x a t x , dx xdt

3

23

00

2 22

tx t dt x t

9

62 2

xx

when x = a, t = 0

x = b = t =

3

b ab a

b ax = 3

0

3

2

xw

Similarly

0

1 1,1

1 0 2

b b b

a a a

x x x a xw L x dx dx dx

x x a x a x

3

2

b

a

x a x xdx

x

Here also we put x a t x

we have

( )

3

b ax

Page 11: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 11

For n = 1 Open Newton Cotes formulae is

0,open 22

b aI f I f f a x f a x

I.Q.3

I.Q.4

3.3. Error Analysis :

Approximation of Integrals involve some error.

The error term associated with a quadrature rule provides two information's.

(i) The error term indicates precisely how the error depends on the length of the

integration interval.

(ii) The error term allows us to determine the degree of precision, which

characterizes the class of polynomials for which quadrature formulae produces

exact result.

Definition: The degree of accuracy (precision) of a quadrature rule nI f is the

positive integer m s.t.

nI P I P for every polynomial P of degree m

nI P I P for some polynomial P of degree 1m

Based on this definition, a quadrature rule that integrates every constant polynomial,

every linear polynomial and every quadratic polynomial exactly but fails to integrate

at least one cubic polynomial exactly would be said to have degree of precision equal

to 2.

3.4. Rate of Convergence:

Page 12: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 12

Let f be a function defined on the interval (a, b) that contains x = 0 and suppose that

0lim ( )

x

f x L . If there exists a function g(x) for which 0

lim ( ) 0

x

g x and a positive

constant K such that

| ( ) | | ( ) | f x L K g x

for all sufficiently small values of x, then f (x) is said to converge to L with rate of

convergence ( ( ))O g x .Generally ( )g x is of the form ax , we replace x by h in our

discussion.

A powerful tool for deriving error terms associated with quadrature formulas is

the following theorem.

4. Weighted Mean – Value Theorem for Integrals:

Statement : If f is continuous on [a, b], g is integrable on [a, b] and g(x) does not

change sign on [a, b], then there exists a number , a b such that

b b

a af x g x dx f g x dx

As a first example to show the error associated with a Newton – Cotes formulae, let’s

consider the trapezoidal rule

Using Interpolation

1 , , f x P x f a b x x a x b (1)

where 1P x is the unique linear polynomial that interpolates the integrand at

x = a and x = b

Integrating both sides of (1)

1,closed , , b

aI f I f f a b x x a x b dx (2)

We observe that 0 , x a x b x a b

Applying weighted mean value theorem for Integrals in equation (2)

Page 13: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 13

1,closed , , b

aI f I f f a b x a x b dx

=

3

, ,6

b af a b

=

3

12

b af where a < < b

Since second derivative of every constant and every linear polynomial is zero.

Trapezoidal rule integrates a constant and linear polynomial exactly.

Degree of precision of trapezoidal rule is 1.

Value Addition : Note

When the error term for a quadrature rule involves the n-th derivative of the

integrand, the rule has degree of precision (n – 1).

I.Q.5

Example 1: Verification of Trapezoidal Rule Degree of Precision

The following table demonstrates explicitly that the trapezoidal rule integrates 1 and x

exactly, but fails to integrate x2 exactly; hence, the degree of precision is 1.

( )f x ( )b

af x dx [ ( ) ( )]/ 2 h f a f a h

1 b a b a

x 2 2( ) / 2b a 2 2( ) / 2b a

x2 3 3( ) /3b a 3 3 2 2( ) / 2 b a ba ab

Example 2: Verification of Simpson's Rule Degree of Precision

( )f x ( )b

af x dx [ ( ) 4 ( ) ( 2 )]/3 h f a f a h f a h

Page 14: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 14

1 b a b a

x 2 2( ) / 2b a 2 2( ) / 2b a

x2 3 3( ) /3b a 3 3( ) /3b a

x3 4 4( ) / 4b a 4 4( ) / 4b a

x4 5 5( ) /5b a 5 4 3 2 2 3 4 5(5 2 2 5 ) / 24 a b a b a b a ba a

Clearly this example shows degree of precision of Simpson's rule is 3.

5. Composite Newton – Cotes Quadrature Method.

Methods of Interpolation suggests us that since we are dealing with polynomial

interpolation at equally spaced points, the sequence of approximation by increasing n

(number of f nodal points) may not converge to value of exact integral.

An alternative approach for improving the accuracy of an approximation is to

subdivide the integration interval [a, b] into pieces and than apply

Newton – Cotes formulae on each sub – interval. Numerical integration performed in

this manner is referred to as composite Newton – Cotes integration formula

6. Composite Trapezoidal Rule:

We know that

1,closed error I f I f

=

3

2 12

b a b af a f b f (1)

If the integration interval [a, b] is split into n subintervals by defining

/ h b a n and ; jx a jh 0 j n , and then the trapezoidal rule is applied on

each subinterval 1,j jx x .

We get

11

j

j

n x

xj

I f f x dx

Page 15: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 15

3

1 1

1

1 12 12

n nj j j j

j j j

j j

x x x xf x f x f

31

0

1 1

22 12

n n

j n j

j j

h hf x f x f x f

Composite trapezoidal rule Error

1 j jh x x for each j and 1 j j jx x (2)

6.1. Error Analysis:

Suppose f has two continuous derivatives then the Extreme Value Theorem guarantees

that there exist two constants

, ,c d a b such that

min ,

a x b

f c f x

max

a x bf d f x

for each j

jf c f f d

Summing over each subinterval 1, j jx x

We find that

1

n

j

j

n f c f n f d

1

1

n

j

j

f c f f dn

(3)

Page 16: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 16

Using Intermediate Value Theorem on relation (1) there exists , a b such

that 1

1

n

j

j

f fn

(4)

Error for the composite traperiodal rule can be written using relation (2) and (4)

as

23 3

1

[ ( )]12 12 12

n

j

j

b a hh nhf f f nh b a

Hence

21

0

1

22 12

nb

j na

j

b a hhf x dx f x f x f x f

Note 1: Extreme Value Theorem (Statement)

If : [ , ] f a b R is continuous on [a, b], then there exist points c and d

in [a, b] such that

( ) ( ) ( ) f c f x f d for all [ , ]x a b

that is

( ) min{ ( )}, ( ) max{ ( )}

a x b a x b

f c f x f d f x

Note 2: Intermediate Value Theorem (Statement)

Suppose that f : [a, b] R is continuous on [a, b]. If v is a number

between f(a) and f(b), then there is a point c (a, b) such that f (c) = v.

Note 3: If the integrand has two continuous derivatives the composite

trapezoidal rule has rate of convergence 20 h .

Page 17: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 17

Example 3: Numerical Verification of Rate of Convergence.

Consider the integral

0

sin

I f xdx (Exact value of integral = 2)

The composite trapezoidal rule approximation hT f to I f computed using a

subinterval size of h (h changing).

We observe that the sequence is converging with rate of convergence 2O h

n h hT f h hI f T f 2 /h h

1 0.000000 2.0000000

2 /2 1.5707963 0.4292036 4.659792

4 /4 1.8961188 0.1038811 4.131681

8 /8 1.9742316 0.0257683 4.0.31337

16 /16 1.9935703 0.0064296 4.007741

32 /32 1.9983933 0.0016066 4.001929

64 /64 1.9995983 0.0004016 4.000482

128 /128 1.9998996 0.0001004 4.000120

7. Composite Simpson’s Rule:

Since the basic Simpson’s rule divides the interval [a, b] into two pieces

For Simpson’s composite rule, we divide the interval [a, b] into even no. of

subinterval

Page 18: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 18

Let n = 2m, define

b a

hn

= 2

b a

m

0 2 ix a ih i m

and apply Simpson’s rule m times once over each subinterval

2 2 2 , 1,2,..., j jx x j m

2

2 21

j

j

m x

xj

I f f x dx

5

2 2 2 2 2 2 4

2 2 2 1 2

1 1

46 2880

m mj j j j

j j j j

j j

x x x xf x f x f x f

1

0 2 1 2

1 1

4 23

m m

j m

j j

hf x f x f x

3

4

190

m

j

j

hf

2 2 2 2 j jx x h

Provided f has four continuous derivatives.

Similar to composite Trapezoidal Rule

We can find a number , a b such that 44

1

1

m

j

j

f fm

Error Term is

454

90 180

b a hh mf

where hm = / 2b a

Hence the composite Simpson’s rule is

1

0 2 1 2 2

1 1

4 23

m m

j j m

j j

hI f f x f x f x f x

4

4

180

b a hf

Note: The composite Simpson’s Rule has rate of convergence 4O h .

Page 19: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 19

I.Q.6.

Example 4: Numerical Verification of Rate of Convergence of Composite Simpson's

Rule

Reconsider the integral 0

( ) sin 2I f xdx

.

We calculate a sequence of ( )hS f values where ( )hS f is the composite Simpson's

rule approximation to I(f) for several values of h (h = size of subinterval) observe that

we double the number of subintervals n and subinterval size is reduced by a factor of

two

n h ( )hS f | ( ) ( ) | h he I f S f 2 /h he e

2 /2 2.09439510239 0.09439510239

4 /4 2.00455975498 0.00455975498 20.701792

8 /8 2.00026916995 0.00026916995 16.940059

16 /16 2.00001659105 0.00001659105 16.223806

32 /32 2.00000103337 0.00000103337 16.055292

64 /64 2.00000006453 0.00000006453 16.013782

128 /128 2.00000000403 0.00000000403 16.003442

The ratio 2 /h he e shows that rate of convergence is 4( )O h that is the error ratio in the

last column is approaching 4

216

h

h.

I.Q.7

Example 5: Evaluate 1

0

1

1

I dxx

correct to three decimal places.

Solution: We solve this example by both the Trapezoidal and Simpson’s rules with

x = 0.5, 0.25, 0.125

Page 20: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 20

1

1

f x

x

(i) x = 0.5 the values of x and f (x) are

x 0 0.5 1.0

f (x) 1.0000 0.6667 0.5

(a) Trapezoidal rule give

1

1.0000 2 0.6667 0.5 0.70844

I

(b) Simpson’s rule gives

1

1.0000 4 0.6667 0.5 0.69456

I

(ii) 0.25 the tabulated values of x and f (x) are

x 0 0.25 0.50 0.75 1.0

f (x) 1.0000 0.8000 0.6667 0.5714 0.5

(a) Trapezoidal rule gives

1

1.0 2 0.8000 0.6667 0.5714 0.58

I = 0.6970

(b) Simpson’s rule gives

1

1.0 4 0.8000 0.5714 2 0.6667 0.52

I = 0.6932

(iii) Finally we take 0.125 x

The tabulated values of x and f (x) are

x 0 0.125 0.250 0.375 0.5 0.625 0.750 0.875 1

Page 21: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 21

f (x) 1 0.8889 0.8000 0.7273 0.6667 0.6154 0.5714 0.5333 0.5

(a) Trapezoidal rule gives

1

1.0 2(0.8889 0.8000 0.7273 0.6667 0.615416

I

0.5714 0.5333) 0.5

= 0.6941

(b) Simpson’s rule gives

1

1.0 4 0.8889 0.7273 0.6154 0.533324

I

2 0.8000 0.6667 0.5714 0.5]

= 0.6932

The exact value of Integral I = loge (2) = 0.693147

Approximate value can be taken = 0.693

This example demonstrates that in general Simpson’s rule yields more accurate results

than the Trapezoidal rule.

Page 22: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 22

Exercise:

Q.1 Approximate the value of each of the following integrals using

(i) Trapezoidal Rule (ii) Simpson’s Rule

(a) 2

1

1 dx

x (b)

1

0

xe dx

(c) 1

20

1

1 dxx

(d) 1

0tan x dx

Q.2 (a) Determine values for the coefficient A0, A1, and A2 so that the quadrature

formulae

1

0 1 21

1 11

3 3

I f f x dx A f A f A f

has degree of precision at least 2.

(b) Once the values of A0, A1, and A2 have been computed determine the overall

degree of precision for the quadrature rule.

Q.3 (a) Derive the closed Newton – Cotes formula with n = 3

3,closed 3 3 28

b aI f I f f a f a x f a x f b

(b) Verify that this formulae has degree of precision equal to 3.

(c) Derive the error term associated with this quadrature rule.

Q.4 Verify for the following that the composite traperiodal rule has rate of

convergence 2O h , composite Simpson’s rule has rate of convergence 4O h

by approximating the value of the indicated definite integral

(a) 2

1

1 dx

x (b)

1

0

xe dx (c)

1

0tan

x x dx

Q.5 Derive the composite mid-point rule with error

Page 23: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 23

2

1

( )( ) 2 ( ) ( )

6

nb

ja

j

b a hf x dx h f x f

where ( ) / 2 , (2 1) and [ , ] jh b a h x a j h a b .

Q.6 Approximate the value of the indicated definite integral using

(a) Composite trapezoidal rule

(b) Composite midpoint rule

(c) Composite Simpson's rule

(i) 1

2

0

xe dx (ii)

2

1

sin

xdx

x (iii)

12

01 x dx

Page 24: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 24

Summary:

Numerical quadrature (Integration) is a procedure that helps us in finding the

approximate integral value of a function whose exact antiderivative is either not

possible or very difficult to find.First we approximate the integrand by a

polynomial(polynomial interpolation) and then integrating that polynomial between

the limits. The general formulae used is Newton-Cotes Quadrature rule then we

derived some closed formulaes like Trapezoidal rule and Simpsons rule and open

formulaes like Mid-Point method.

During the approximation of integral we are faced with some error as different

formulaes have different level of accuracy. Estimation of error and the bounds on the

error is shown for all the Quadrature formulaes.

Page 25: Numerical Integration

Numerical Integration

Institute of Lifelong Learning, University of Delhi pg. 25

References:

1. A Friendly Introduction to Numerical Analysis by Brian Bradie, Sixth

Impression, Pearson Prentice Hall.

2. Introductory Methods of Numerical Analysis by S.S. Sastry, Prentice Hall of

India.

3. Finite Differences and Numerical Analysis by H.C. Saxena, S. Chand &

Company Ltd.

4. Numerical Methods for Scientific and Engineering Computation by M.K. Jain,

S.R.K. Iyengar, R.K. Jain Sixth Edition, New Age International Publishers.

5. Applied Numerical Analysis, Seventh Edition, Curtis F. Gerald, Patrick O.

Wheateley, Pearson.