Вы находитесь на странице: 1из 14

Numerical

Integration

Md. Mehedi Hasan


Lecturer @ DIU
Numerical Integration
There are two main reasons for you to need to do numerical integration: analytical integration
may be impossible or infeasible, or you may wish to integrate tabulated data rather than known
functions. In this section, we outline the main approaches to numerical integration.

Numerical integration is the approximate computation of integral using numerical techniques. The
numerical computation of an integral is sometimes called quadrature. Therefore, the basic problem in
numerical integration is to compute an approximate value to a definite integral
b

 f ( x) dx
a
to a given degree of accuracy.

Numerical Integration consists of finding numerical approximations for the value S.

b
Meaning of  f ( x) dx :
a

b b
The definite integral  f ( x) dx   y dx represents the area between the curve
a a
y  f (x) , the x-axis and the lines

x  a and x  b .

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


Numerical Integration:
b
Numerical integration is the process by which we can find the value of definite integral  f ( x) dx
a

numerically by using some well-established formulae or rules. The exact value of a definite integral
b

 f ( x) dx can be computed only when the function


a
f (x) is integrable in finite terms, whenever the function

y  f (x) cannot be exactly integrated in finite terms or the evaluation of its integral is too cumbersome,
integration can be more conveniently performed by numerical method. Various methods have been derived
to find the above area approximately, in this case when f (x) is not easily integrable. Hence these methods of
approximating an area are essential methods for approximating a definite integral. The developed
approximating methods are as follows:

i) Trapezoidal Rule
1
ii) Simpson’s Rule
3
3
iii) Simpson’s Rule
8
iv) Weddle’s Rule
v) Romberg’s Integration Rule
vi) Boole’s Rule etc.

General Formula for Numerical Integration:


b
Let us consider an integral I   ydx where y  f (x) is continuous on [a,b] and be given for certain
a

equidistant values of x.

Let the equidistant values of x is, a  x0 , x0  h, x0  2h, x0  3h,.........., x0  nh  b


b x0  nh

I   ydx
a  x0
------------------ (1)

From Newton’s Forward Interpolation formula, we have,


u (u  1) 2 u (u  1)(u  2) 3 x  x0
y  y0  uy0   y0   y0   where u 
2! 3! h
From (1) we get,
x0  nh
u (u  1) 2 u (u  1)(u  2) 3
I  
x0
[ y0  uy0 
2!
 y0 
3!
 y0  ]dx ------------- (2)

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


Now we know,
x  x0
u  x  x0  uh  dx  hdu
h
Limit Change:
When x  x0 then u  0
When x  xn then u  n

Therefore, above equation (2) takes the form,

 u (u  1) 2 u (u  1)(u  2) 3 
n
I    y 0  uy 0   y0   y 0    upto (n  1)terms  hdu
0 
2! 3!
 u (u  1) 2 u (u  1)(u  2) 3 
n
 h   y 0  uy 0   y0   y 0    upto (n  1)terms  du
0 
2! 3!
n
 (u 2  u ) 2 (u 2  u )(u  2) 3 
 h   y 0  uy 0   y0   y 0    upto (n  1)terms  du
0 
2! 3!
n
 (u 2  u ) 2 (u 3  3u 2  2u ) 3 
 h   y 0  uy 0   y0   y 0    upto (n  1)terms  du
0 
2! 3!
n
 u2 1  u3 u2  1  u4  
 h  y0 u  y 0    2 y 0    u 3  u 2 3 y 0    upto (n  1)terms
 2 2!  3 2  3!  4  0
x0  nh
b
 n 2
n 3
n   y0  n
2 2 4
  y0
3

 I   ydx   ydx  h  ny 0  y 0        n 3  n 2     upto (n  1)terms 
a x0  2  3 2  2!  4  3! 

This Formula is known as general quadrature formula or General formula for numerical integration and also
known as General Gauss -Legendre integration formula for equidistant ordinates.

Note:
b
1. This formula is used to compute  f ( x) dx
a

2. Putting n  1in above equation we obtain Trapezoidal rule


1
3. Putting n  2 in above equation we obtain Simpson’s Rule
3
3
4. Putting n  3 in above equation we obtain Simpson’s Rule
8
5. Putting n  4 in above equation we obtain Boole’s Rule
6. Putting n  6 in above equation we obtain Weddle’s Rule

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


Rule:
Trapezoidal Rule:
Trapezoidal
The general integration formula is
x0  nh
b
 n2  n 3 n 2  2 y 0  n 4 2   y0
3

I   ydx  x ydx  h  ny
 0 2 y 0  
 3  
  
  n 3
 n 
    upto (n  1)terms 
a 0   2  2!  4  3! 
Setting n  1 in above equation and neglecting the second and higher order, we get
x0  h
 1 
 ydx  h  y
x0
0 
2
y 0 

     1 1  1 1 
 h  y 0   y1  y 0   h  y 0   y1  y 0   h  y0  y1  y0   h  y 0  y1 
1 1
 2   2   2 2  2 2 
x0  h

  ydx   y 0  y1 
h
x0
2

Similarly, we can get,


x0  2 h

 ydx 
h
 y1  y2 
x0  h
2
x0  3 h

 ydx  2  y  y3 
h
2
x0  2 h




x0  nh

 ydx  2  y  yn 
h
n 1
x0  ( n 1) h

Adding these n integrals, we get

x0  nh

 ydx  2  y  y1    y1  y 2   h  y 2  y3     h  y n1  y n 


h h
0
x0
2 2 2
x0  nh

 ydx  2  y  y1  y1  y 2  y 2  y3    y n1  y n 


h
0
x0
x0  nh

 ydx  2  y  y n   2 y1  y 2  y3    y n1 


h
0
x0

The above formula is known as the trapezoidal rule for numerical integration.
Shortly we can write,

x0  nh
h n 1

x ydx  2  y 0  y n   2
k 1
yk 

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU
0
Simpson’s1 Rule:
Simpson’s 3
Rule: 1
3
The general integration formula is
x0  nh
b
 n2  n 3 n 2  2 y 0  n 4 2   y0
3

I   ydx  x ydx  h 
 ny 0  y 0  
 3  
 2!  
 4  n 3
 n 
 3!    upto ( n  1)terms 

a 0  2  2    

Setting n  2 in above equation and neglecting the third and higher order, we get

x0  2 h
 22  2 3 2 2  2 y 0 
 ydx  h  2 y
 0 2  y 0    
 3 2  2!


x0  

 2 y 0 
  h  2 y0  2 y1  y0   y1  y0 
 8   y0
2
 1
 h  2 y 0  2y 0    2    h  2 y 0  2y 0  
3  2   
   3  3

   
 h  2 y0  2 y1  y0    y2  y1    y1  y0   h  2 y0  2 y1  2 y0   y2  2 y1  y0 
1 1
 3   3 


h
6 y0  6 y1  6 y0   y2  2 y1  y0 
3
x0  2 h

 ydx  3  y  4 y1  y 2 
h
 0
x0

Similarly, we can write,


x0  4 h

 ydx  3  y  4 y3  y 4 
h
2
x0  2 h
x0  6 h

 ydx  3  y  4 y5  y6 
h
4
x0  4 h

x0  nh

 ydx  3  y  4 y n 1  y n 
h
n2
x0  ( n  2 ) h

Now adding the n integrals, we can write

x0  nh

 ydx  3  y  4 y1  y 2    y 2  4 y3  y 4   h  y 4  4 y5  y 6     h  y n2  4 y n1  y n 


h h
0
x0
3 3 3
h
y0  4 y1  y 2  y 2  4 y3  y 4  y 4  4 y5  y6    y n2  4 y n1  y n 

3
x0  nh

  ydx   y0  yn   4 y1  y3  y5    yn 1   2 y2  y4  y6    yn  2 


h
x0
3
The above formula is known as the Simpson’s 1/3 rule for numerical integration.
Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU
Shortly we can write,

x0  nh
h n1 n2

x ydx  
 0y  y n   4  y k  2  y k
0
3  k 1, 3, 5 , k  2 , 4 , 6 ,  

Note:
This formula is used only when the number of partitions of the interval of integration is even.

Simpson’s3 Rule:
3
Simpson’s 8Rule: 8
The general integration formula is
x0  nh
b
 n2  n3 n 2  2 y 0  n 4  3 y 0 
I   ydx  x ydx  h  ny
 0 2 y 0        n 3  n 2     upto (n  1)terms 
a 0   3 2  2!  4  3! 
Setting n  3 in above equation and neglecting the fourth and higher order, we get
x0  3 h
 32  33 3 2  2 y 0  3 4 2   y0
3

              
3
ydx h 3 y y  3 3 3
 0 2 2  2!  4  3! 
0
x0     

 9 9 3
 h  3 y0  y0  2 y0  3 y0   0 0 
 3h 8 y  12y  62 y  3 y
0 0 
 2 4 8  8

3h
8 y0  12 y1  y0   6y1  y0   y1  y0 
8


3h
8 y0  12 y1  y0   6 y2  2 y1  y0   y2  2y1  y0 
8


3h
8 y0  12 y1  y0   6 y2  2 y1  y0    y3  y2  2 y2  y1   y1  y0 
8


3h
8 y0  12 y1  12 y0  6 y2  12 y1  6 y0  y3  3 y2  3 y1  y0 
8
x0  3 h

 ydx  8  y  3 y1  3 y 2  y 3 
3h
 0
x0

Similarly, we can write,


x0  6 h

 ydx  8  y  3 y 4  3 y5  y6 
3h
3
x0  3 h
x0  9 h

 ydx  8  y  3 y 7  3 y8  y 9 
3h
6
x0  6 h

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


x0  nh

 ydx 
3h
 y n3  3 y n2  3 y n1  y n 
x0  ( n  3 ) h
8

Adding all these above integrals, we can write

x 0  nh

 ydx  8  y  3 y1  3 y2  y3    y3  3 y4  3 y5  y6  3h  y6  3 y7  3 y8  y9    3h  yn 3  3 yn  2  3 yn 1  yn 
3h 3h
0
x0 8 8 8
3h
y0  3 y1  3 y2  y3  y3  3 y4  3 y5  y6  y6  3 y7  3 y8  y9    yn3  3 yn2  3 yn1  yn 

8
x0  nh

  ydx   y0  yn   3 y1  y2  y4  y5  y7  y8    yn  2  yn 1   2 y3  y6  y9    yn 3 


3h
x0
8
The above formula is known as the Simpson’s 3/8 rule for numerical integration.

Shortly we can write,

x0  nh  n 1 n 3

3h  
x ydx  8  y 0  y n   3k 3,6,9,y k  2k 3, yk 
 6, 9, 
0
 k 1 

Note: This formula is used only when the number of partitions of the interval of integration is a multiple of
the number 3.

Weddle’s Rule:

Similarly if we put n=6 in general integration formula then we get Weddle’s formula

x0  nh
3h
 ydx 
x0
10
[ y 0  5 y1  y 2  6 y3  y 4  5 y5  2 y 6  5 y 7  y8  ............]

Shortly we can write,

x0  nh
3h  n n 1 n 3

 10 k 0,2,4,6,......k k 1
x0
ydx  y  5
,3,5,
y k   k y
k 3, 6,9 

Note:
1.This formula requires at least seven consecutive values of the function.
2. This formula is used only when the number of partitions of the interval of integration is a multiple of the
number 6.
Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU
Mathematical Problems

2
Problem 01: Compute  x 2 dx by Simpson’s one third rule and compare with exact value.
1

Solution:
2

 x dx
2
Given that the function is,
1

Here upper limit is b  2 , lower limit is a  1 and number of subintervals n  4 and let y  f ( x)  x 2
Now,
b  a 2 1 1
h    0.25
n 4 4

The values of the function y at each subinterval are given in the tabular form:

x x0  1 x1  1.25 x2  1.50 x3  1.75 x4  2


y  f ( x)  x 2 y0  1 y1  1.5625 y 2  2.25 y3  3.0625 y4  4
1
From Simpson’s Rule we have,
3
x0  nh

 ydx  3  y  y n   4 y1  y 3  y 5    y n 1   2 y 2  y 4  y 6    y n  2 


h
 0
x0

Now for n  4 the above formula reduces to the following form,

 x dx  3  y  y 4   4 y1  y 3   2 y 2 
2 h
0
1


0.25
1  4  41.5625  3.0625  2  2.25
3
2
7
  x 2 dx 
1
3
2
 x3  1 3 3 7
Now exact value is  x dx     2  1  
2
2

1  3 1 3 3
1
It is shown that exact result and Simpson’s Rule’s result are exactly same so there is no error between two
3
results.

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


5.2
Problem 02: Determine  ln x dx
4
by Simpson’s 3/8 rule and Weddle’s rule considering the number of

intervals six. Find true value and then compare and comment on it.

Solution:
5.2
Given that the function is,  ln x dx
4
Here upper limit is b  5.2 , lower limit is a  4 and No. of subintervals n  6 and let y  f ( x)  ln x
Now,
5.2  4 1.2
h   0.2
6 6
The values of the function y at each subinterval are given in the tabular form:
x x0  4 x1  4.2 x2  4.4 x3  4.6 x4  4.8 x5  5.0 x6  5.2
y  f ( x)  ln x y 0  1.3862 y1  1.4350 y 2  1.4816 y3  1.5260 y 4  1.5686 y5  1.6094 y 6  1.6486

Simpson’s 3/8 rule:


We know that
x0  nh

 ydx  8  y  yn   3 y1  y2  y4  y5  y7  y8    yn  2  yn 1   2 y3  y6  y9    yn 3 


3h
0
x0

Now for n  6 the above formula reduces to the following form,

3  0.2
b

 f ( x) dx  8
 y0  y6   3  y1  y2  y4  y5   2 y3 
a

3  0.2
b

 f ( x) dx  8
1.3862  1.6486  3 1.4350  1.4816  1.5686  1.6094  2 1.5260
a

3  0.2
5.2

 ln x dx  3.0348  3  6.0946  2 1.5260  1.827795


4
8

Weddle’s Rule:
We know that
x0  nh
3h  n n 1 n 3

 10 k 0,2,4,6,......k k 1
x0
ydx  y  5
,3,5,
y k   k y
k 3, 6,9 

Now for n  6 the above formula reduces to the following form,


3  0.2  6 
5.2 5 3

4 ln x dx    k y  5  yk   yk 
10 k 0, 2, 4,6,...... k 1,3,5, k  3, 6,9 

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


Or,  ln x dx  3  0.2 y0  y2  y4  y6  5 y1  y3  y5   y3
5.2

4 10
3  0.2
5.2
Or,  ln x dx  6.085  5 4.5704  1.5260 
4 10
5.2

 ln x dx  1.82778
4
5.2 5.2
d 
Exact value is 4 ln x dx  x ln x 5.2
4
 4  dx ln x  dx dx
1  5.2

 x ln x4    . x  dx
5.2

4 x 
5.2

 x ln x4   dx
5.2

 x ln x4  x4
5.2 5.2

 5.2 ln 5.2  4 ln 4  5.2  4


 1.827847409
Result on Simpson’s 3/8 rule and Weddle rule are closer to one another and also to the true value. That
means both methods work well.

1.4

  sin x  ln x  e  dx by using various rules using 6 equidistant


x
Problem 03: Compute the definite integral
0.2
sub-intervals correct up to three decimal places.
Solution:
1.4

  sin x  ln x  e  dx
x
Given that the function is,
0.2

Here upper limit is b  1.4 , lower limit is a  0.2 and No. of subintervals n6 and let
y  f ( x)  sin x  ln x  e . x

Now,
1.4  0.2
h  0.2
6
The values of the function y at each subinterval are given in the tabular form:

x x0  0.2 x1  0.4 x2  0.6 x3  0.8 x4  1.0 x5  1.2 x6  1.4


y y 0  3.0295 y1  2.7975 y 2  2.8975 y3  3.1660 y 4  3.5597 y5  4.0698 y 6  4.7041

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


 Trapezoidal Rule:
We know that
x0  nh

x ydx  2  y0  yn   2 y1  y2  y3    yn1 


h
0

Now for n  6 the above formula reduces to the following form,

 
1.4

 sin x  ln x  e dx 
h
 y x
0  y6   2 y1  y 2  y3  y 4  y5 
0.2
2


0.2
3.0295  4.7041  22.7975  2.8975  3.1660  3.5597  4.0698
2
0.2
  40.7136
2

 
1.4
  sin x  ln x  e x dx  4.07136
0.2

1
 Simpson’s Rule:
3
We know that
x0  nh

 ydx  3  y  y n   4 y1  y 3  y 5    y n 1   2 y 2  y 4  y 6    y n  2 


h
0
x0

Now for n  6 the above formula reduces to the following form,

 sin x  ln x  e dx  3  y
1.4
 y 6   4 y1  y 3  y 5   2 y 2  y 4 
h x
0
0.2


0.2
3.0295  4.7041  42.7975  3.1660  4.0698  22.8975  3.5597
3

 
1.4
  sin x  ln x  e x dx 
0.2
7.7336  40.1332  12.9144   4.05208
0.2
3

3
Simpson’s Rule:
8
We know that
x0  nh

 ydx  8  y  yn   3 y1  y2  y4  y5  y7  y8    yn  2  yn 1   2 y3  y6  y9    yn 3 


3h
0
x0

Now for n  6 the above formula reduces to the following form,

3  0.2
b

 f ( x) dx  8
 y0  y6   3  y1  y2  y4  y5   2 y3 
a

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


3  0.2
b

 f ( x) dx  8
 3.0295  4.7041  3  2.7975  2.8975  3.5597  4.0698  2  3.1660
a

3  0.2
b

 f ( x) dx 
a
8
 54.0391

3  0.2
1.4

  sin x  ln x  e  dx   54.0391  4.0529


x

0.2
8

Weddle’s Rule:
We know that
b
3h  n n1 n 3

a f ( x ) dx    y  5 
10 k 0, 2, 4,6,...... k 1,3,5,
k y k   y k
k 3, 6 , 9 

Now for n  6 the above formula reduces to the following form,

 sin x  ln x  e dx  3 100.2   y 


1.4 6 5 3
x
k 5  yk  y  k
0.2  k 0, 2, 4, 6,...... k 1,3,5, k 3, 6,9 
3  0.2
 y0  y2  y4  y6  5 y1  y3  y5   y3 
10

3  0.2
 3.0295  2.8975  3.5597  4.7041  52.7975  3.1660  4.0698  3.1660 
10

3  0.2
 sin x  ln x  e dx  10  67.5233  4.051398
1.4
x

0.2

6
Example 04: Evaluate  f ( x) dx
0
by using trapezoidal rule where the values of f ( x) are given by the

following table:
x 0 1 2 3 4 5 6
Y=f(x) 0.146 0.161 0.176 0.190 0.204 0.217 0.230
Solution:
Here upper limit is b  6 , lower limit is a  0 and No. of subintervals n  6 .
Now,
60
h 1
6
The values of the function y at each subinterval are given in the tabular form:

x x0  0 x1  1 x2  2 x3  3 x4  4 x5  5 x6  6
Y=f(x) y 0  0.146 y1  0.161 y 2  0.176 y3  0.190 y 4  0.204 y5  0.217 y 6  0.230

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU


From trapezoidal rule we have
b

 f ( x) dx  2  y  y6   2 y1  y2  y3  y4  y5 
1
0
a
b

 f ( x) dx  2 0.146  0.230  20.161  0.176  0.190  0.204  0.217


1
a
6

 f ( x) dx  1.136
0

Try Yourself
1. Derive newton’s general quadrature formula for numerical integration.
2. Obtain the formula for Simpson’s one-third rule from general quadrature formula.
3. Obtain the formula for Simpson’s rule and Weddle’s rule from general quadrature formula to find
b

 f ( x) dx .
a
3

e
2 x
4. Using Simpson’s 3/8 th rule find the value of sin 4 x dx taking six sub-intervals.
0
1.8
 1
5. Calculate the value of   x  x  dx , correct up 5D taking six sub-intervals by Simpson’s 3/8 th
1.2

rule. Also, find the percentage errors and compare to the exact solution.
1
ln(1  x 2 )
6. Using Simpson’s 3/8 th rule find the value of 0 1  x 2 dx
2
7. Evaluate  e 2 x sin 3x dx , using Simpson’s rule and Weddle’s rule.
0

 sin x  e  dx
1.4
8. Using Simpson’s three-eight rule evaluate the integrals 2x
and hence find the errors.
0.2

9. Discuss the necessity of numerical techniques of integration.


1
x dx
10. Calculate the value of the integral I   by taking seven equidistant ordinates, using the
0
1  x 2

Simpson’s 1/3 rule and trapezoidal rule. Find the exact value of I and then compare and comment on
it.
1
dx
11. Find  1 x
0
2
by using Simpson’s 1/3 and 3/8 rules. Hence obtain the approximate value of π in

each case.

Md. Mehedi Hasan, Lecturer (Mathematics) @ DIU

Вам также может понравиться