You are on page 1of 10

Numerical Integration

The process of evaluating a definite integral from a set of tabulated values of the integrand
f (x ) , which is not known explicitly is called Numerical Integration. Using numerical
methods we can obtain the approximated value of the integration.
b

∫ f ( x)dx
There are following three numerical methods to evaluate the definite integrals a .
1. Trapezoidal rule (n=1)
1
2. Simpson’s 3 Rule (n=2)
rd

3
3. Simpson’s 8 Rule (n=3)
th

Here n= Number of intervals


Numerical Methods for Integration
Let y=f ( x ) takes the values f (x 0 )= y 0 , f ( x1 )= y 1 ,⋯, f ( x n )= y n at the equispaced points
x=x 0 , x 1 ,⋯, x n respectively, where x n= x0 +nh , n=0 , 1 ,⋯, n . The step size between two
consecutive points is h.
Trapezoidal Rule
b

∫ f ( x)dx
We can evaluate a by Trapezoidal Rule as follows:
Let’s divide the given interval [a , b] into n number of subintervals
a=x 0 , x 1 ,⋯, b=x n of step
size h.
b x1 x2 xn

⇒∫ f ( x )dx=∫ f ( x )dx +∫ f ( x )dx +⋯+ ∫ f ( x )dx


a x0 x1 x n−1

In the interval
[ x0 , x1 ]
x
At 0 and x 1 the corresponding functional values are f (x 0 )= y 0 and f ( x 1 )= y 1 respectively.
By Lagrange’s formula
x−x 1 x−x 0 y y
f (x )= f ( x 0 )+ f ( x 1 )=− 0 ( x−x 1 )+ 1 ( x−x 0 )
x 0 −x 1 x 1 −x 0 h h
x1 x x
y0 1 y1 1 y 0 ( x−x 1 )2 x=x 1 y 1 ( x−x 0 )2 x= x1
⇒∫ f ( x )dx =− ∫ ( x−x 1 )dx + ∫ ( x−x 0 )dx =− |x=x 0 + |x= x 0
x h x h x h 2 h 2
0 0 0
x1
h
⇒∫ f ( x )dx = ( y 0 + y 1 )
x 2
0 , This is equivalent to the area of a Trapezium. Thus this is called
Trapezoidal Rule.
x1

∫ f ( x)dx = h2 ( y 0 + y 1 )
Hence in the interval
[ x0 , x1 ] , x0
x2

∫ f ( x )dx= h2 ( y 1 + y 2 )
Similarly, in the interval [ x 1 , x 2 ] , x1
xn

∫ f ( x )dx = h2 ( y n−1 + y n )
Continuing in this way, in the interval
[ x n−1 , xn ] , x n−1
b= xn x1 x2 xn

∫ f ( x )dx=∫ f ( x )dx +∫ f ( x )dx +⋯+ ∫ f ( x)dx


a=x0 x0 x1 x n−1
Since
b
h
⇒∫ f ( x )dx≃ [ y 0 + y 1 + y 1 + y 2 +⋯+ y n−1 + y n ]
a 2
b
h
⇒∫ f ( x )dx≃ [( y 0 + y n )+2( y 1 + y 2 +⋯+ y n−1 )]
a 2 , This is called Composite Trapezoidal
Rule.
Note: If there are two points with number of interval n=1 then by Trapezoidal rule
b

∫ f ( x)dx= b−a
2
[ f (a )+f (b )]
a .
1

∫ 1+dxx2
Example: Evaluate 0 using Trapezoidal rule with h=0 .2 . Hence determine the value of
π.
1
f (x )=
Solution: Given 1+ x 2 and h=0 .2 . The interval is [0, 1] . The values of y=f ( x ) for
each point of subdivision with h=0 .2 are got and tabulated as
x 0 0.2 0.4 0.6 0.8 1
y=f ( x ) 1 0.961 0.8621 0.7353 0.609 0.5
5 8

By Trapezoidal rule
b

∫ f ( x )dx≃ h2 [( y 0 + y n )+2( y 1+ y 2+⋯+ y n−1 )]


a
1
dx 0. 2
⇒∫ ≃ [( y 0 + y 5 )+2( y 1 + y 2 + y 3 + y 4 )]
0 1+x 2 2
1
dx
⇒∫ ≃0.1 [(1+0 . 5)+2(0 . 9615+0 . 8621+0 .7353+0.6098 )]=0 .7837
0 1+x 2
Exact Value of the Integration
1 x=1
∫ 1+ x2 =tan x| =tan−1(1)= π4
dx −1

0 x=0
π
⇒ ≃0 .7837
4
Hence by Trapezoidal rule, the value of π ≃4×0. 7837=3. 1348 .
0.5

∫ f (x )dx
Example: Apply Trapezoidal rule to evaluate 0 using f (0)=1 and f (0. 5)=0 .8.
Solution: Here a=0 , b=0 .5 and h=b−a=0 . 5 .
b

∫ f ( x)dx= b−a
2
[ f (a )+f (b )]
By Trapezoidal rule a
0 .5
0. 5
⇒ ∫ f ( x)dx≃ [1+0. 8]=0.25×1.8=0. 45
0 2
Simpson’s one third Rule
b

∫ f ( x)dx 1
rd
We can evaluate a by Simpson’s 3 rule as follows:
Let’s divide the given interval [a , b] into n number of subintervals 0 1 n of step a=x , x ,⋯, b=x
size h . We have to divide the range [a , b] in such way that the number of subintervals will be
multiple of 2 or even.
x, x
For n=2 , there are three points 0 1 and x 2 . The corresponding functional values are 0 1
y, y
and y 2 respectively.
In the interval 0 2 :
[x , x ]
By Lagrange’s formula the polynomial is
( x−x 1 )( x−x 2 ) (x −x 0 )( x−x 2 ) ( x−x 0 )( x−x 1 )
y ( x )= y ( x0 )+ y (x 1 )+ y ( x3 )
( x 0 −x 1 )( x 0 −x 2 ) ( x 1 −x 0 )( x 1 −x 2 ) ( x 2−x 0 )( x 2−x 1 )
In between two consecutive points the step size is h .
y0 y1 y3
⇒ y ( x )= 2 ( x−x 1 )( x−x 2 )− 2 ( x−x 0 )( x−x 2 )+ 2 ( x−x 0 )( x−x 1 )
2h h 2h
x2 x2 x2 x2
y0 y1 y3
⇒∫ y ( x )dx = ∫ ( x−x 1 )( x−x 2 )dx− h2 ∫ ( x−x 0 )( x−x 2 )dx + 2 h2 ∫ ( x−x 0 )( x−x 1 )dx
x0 2h 2 x 0 x0 x0

After integration and simplification we get


x2

∫ y ( x )dx = h3 [ y 0 +4 y 1 + y 2 ] 1
rd
x0
, This is called Simpson’s 3 rule.
x4

∫ y ( x )dx = h3 [ y 2 +4 y 3 + y 4 ]
Similarly, in the interval [ x 2 , x 4 ] , x2

Continuing in this way, in the interval we get


[ x n−2 , x n ]
xn
h
∫ y ( x )dx = [ y n−2 +4 y n−1 + y n ]
3
x n−2
b =x n x2 x4 xn

⇒ ∫ f ( x )dx=∫ f ( x )dx +∫ f ( x )dx +⋯+ ∫ f ( x )dx


a= x 0 x0 x2 x n−2
b
h
⇒∫ y ( x )dx≃ [( y 0 + y n )+4( y 1 + y 3 +⋯+ y n−1 )+2( y 2 + y 4 +⋯+ y n−2 )]
a 3
1
rd
This is called Composite Simpson’s 3 rule.

Note:
1
rd
1. Simpson’s 3 rule can be written as
b

∫ y( x)dx≃ h3 [(First Value+Last value )+4 (odd functional values)+2( even functional values )]
a
1
rd
2. Simpson’s 3 rule can be applied only when number of intervals is multiple of 2 or
there are even number of intervals i. e. n=2n .
1
3. If there are three points a, c , b with n=2 then by Simpson’s 3 rule
rd

[ ]
b

∫ f ( x )dx= h2
a
f (a )+4 f ( )
a+b
2
h
+f (c ) = [ f ( a)+4 f (c )+f (b)]
2 , h=c−a=b−c .

Simpson’s three by eight Rule


b

∫ f ( x)dx 3
th
We can evaluate a by Simpson’s 8 rule as follows:
Let’s divide the given interval [a , b] into n number of subintervals 0 1 a=x , x ,⋯, b=x
n of step

size h . We have to divide the range [a , b] in such way that the number of subintervals will be
multiple of 3.
x, x, x x
For n=3 , there are three points 0 1 2 and 3 . The corresponding functional values are
y 0 , y 1 , y 2 and y 3 respectively.
[x , x ]
In the interval 0 3 :
Integrating the Lagrange’s polynomial in the interval
[ x 0 , x 3 ] we get
x3

∫ y ( x )dx = 38h [ y 0 +3 y 1 +3 y 2 + y 3 ] 3
th
x0
, This is called Simpson’s 8 rule.
x6

∫ y ( x )dx = 38h [ y 3 +3 y 4 +3 y 5 + y 6 ]
[ x 3 , x 6 ] we get x3
Similarly, in the interval
[x , x ]
Continuing in this way, in the interval n−3 n we get
xn
3h
∫ y ( x )dx= [ y +3 y n−2 +3 y n−1 + y n ]
8 n−3
x n−3
b =x n x3 x6 xn

⇒ ∫ f ( x )dx=∫ f ( x )dx +∫ f ( x )dx +⋯+ ∫ f ( x )dx


a= x 0 x0 x3 x n−3
b
3h
⇒∫ y ( x )dx≃ [( y 0 + y n )+3( y 1 + y 2 + y 4 + y 5 +⋯)+2( y 3 + y 6 + y 9 ⋯)]
a 8
3
th
This is called Composite Simpson’s 8 rule.
3
th
Note: Simpson’s 8 rule is applicable only when number of intervals is multiple of 3, i. e.
n=3 n.
1

∫ 1+dxx
Example: Evaluate 0 by using Simpson’s rule with step size h=1/6 . Compare the result
with actual value of the integration.
1
y=f ( x )=
Solution: Here h=1/6 and 1+x .
1
y=
The values of 1+x for the points of subdivisions are as follows:
x 0 1/6 2/6 3/6 4/6 5/6 1
y 1 0.8571 0.75 0.6667 0.6 0.5455 0.5

1
rd
Simpson’s 3 rule
1
rd
Here number of interval n=6 , so we can apply Simpson’s 3 rule.
1
rd
By Simpson’s 3 rule
b

∫ y( x )dx≃ h3 [(First Value+Last value )+4 (odd functional values)+2( even functional values )]
a
1
dx h
⇒∫ ≃ [( y + y )+4( y 1 + y 3 + y 5 )+2( y 2 + y 4 )]
0 1+x 3 0 6
1
dx 1
⇒∫ ≃ [(1+0. 5 )+4 (0 .8571+0 .6667+0 . 5455)+2(0 . 75+0 .6 )]=0. 6932
0 1+x 18
3
th
Simpson’s 8 rule
3
th
Here number of interval n=6 , so we can apply Simpson’s 8 rule.
3
th
By Simpson’s 8 rule
b

∫ y ( x )dx≃ 38h [( y 0+ y n )+3( y 1+ y 2+ y 4 + y 5+⋯)+2( y 3+ y 6 + y 9⋯)]


a
1
dx 3 h
⇒∫ ≃ [( y 0 + y 6 )+3( y 1 + y 2 + y 4 + y 5 )+2( y 3 )]
0 1+x 8
1
dx 1
⇒∫ ≃ [(1+0 .5 )+3(0 .8571+0. 75+0 . 6+0 . 5455)+2(0 .6667 )]=0.6932
0 1+x 16

Actual Integration
1

∫ 1+dxx =ln(1+x )|x=1


x=0 =ln 2=0 .6931
0
Error
1
rd
In case of Simpson’s 3 rule: 0.6931-0.6932=-0.0001
3
th
In case of Simpson’s 8 rule: 0.6931-0.6932=-0.0001
Error in Numerical Methods
Error in Trapezoidal rule
x
The Taylor’s series of y=f ( x ) about 0 is given by
2 3
( x−x 0 ) ( x−x 0 ) '''
y=f ( x−x 0 + x 0 )= y 0 +( x−x 0 ) y ′ + y ″+ y 0 +⋯
0 2! 0 3! (1)
The actual value of integration in the interval
[ x 0 , x1 ] :

[ ]
x 1= x0 +h x1 =x 0+h
( x−x 0 )2 '' ( x−x 0 )3 '''
∫ ydx = ∫ y 0 +( x−x 0 ) y +
'
0
2!
y0+
3!
y 0 +⋯ dx
x0 x0

x1
(
= y0 x +
(x−x0 )2
2
( x−x 0 )3
y'0 +
6
y ''0 +
(x −x0 )4
24 ) x=x +h
y '''0 +⋯ |x =x0
0

2 3
h ' h ''
∫ ydx =hy 0 + 2! y 0 + y 0 +⋯
3!
x0
(2)
[x , x ]
Value of integration by Trapezoidal rule in the interval 0 1 :
x1

∫ y ( x )dx = h2 ( y 0 + y 1 )
x0
(3)
The Taylor’s series of y 1 = y (x 1 )= y ( x 0 +h) is
2
h
y 1 = y 0 +hy ′ + y ″ +⋯
0 2! 0
Using it in (3) we get
x1

( )
2 2 3

∫ y ( x )dx = h2 y 0 + y 0 +hy '0 + 2!


h '' h ' h ''
y 0 +⋯ =hy 0 + y 0 + y 0 +⋯
2 4
x 0 (4)
This is the approximated value of the integration by Trapezoidal rule
Error in the interval 0 1 :
[x , x ]
Error=Actual value in (2)-Approximated value in (4):
3
h
⇒ E=− y ''0 +⋯
12
3
h ''
[x , x ] E=− y
The principal part of error in the interval 0 1 is 12 0
3
h ''
E=− y
Similarly, in the interval [ x 1 , x 2 ] , error is 12 1 and so on.
Hence total error in the interval 0 n is
[x , x ]
h 3 '' ''
E≃− ( y 0 + y 1 +⋯+ y ''n−1 )
12
3
nh
⇒|E|≤
12 , 0 1 {
M M=max |y ''|, |y ''|,⋯,|y '' |
n−1 }
2
⇒|E|≤
(b−a )h
12
M (
∵ x n =x 0 + nh , ⇒b=a+nh ⇒ h=
b−a
n )
2
Hence the absolute error in the Trapezoidal rule is of order h .
Error in Simpson’s rule
1 (b−a )h 4
rd |E|≤ M , ∵2 nh=b−a.
1. Absolute error in Simpson’s 3 rule is 180
4
3 (b−a )h
th |E|≤ M , ∵3 nh=b−a .
2. Absolute error in Simpson’s 8 rule is 240
Note:
1. Trapezoidal rule gives exact value of the integration for the linear polynomial.
2. Simpson’s rule gives exact value of the integration for a polynomial of degree at most
2.

∫ e− x dx
2

Example: Evaluate 0 by dividing the range into 4 equal parts using Trapezoidal rule.
2
−x
Solution: It is given that y=e , x 0 =0 , x n =1 , n=4
xn −x 0 1−0
⇒h= = =0 . 25
n 4
− x2
The values of y=e for each point of subdivision are as follows:
x 0 0.25 0.5 0.75 1
y 1 0.9394 0.7788 0.5698 0.3679
By Trapezoidal rule
1

∫ dx = h2 [( y 0 + y4 )+2( y 1 + y 2 + y 3 )]= 18 [(1.3679)+2(2 .288 )]=0.7430 .


e− x2

0
0.7

∫ e−x √ x dx
Example: Calculate 0.5 , taking 5 ordinates by Simpson’s rule.
−x
Solution: It is given that y( x )=e √ x , x0=0. 5 , x n =0 .7 , n+1=5
x n −x 0 0 .7−0 .5
⇒n=4 , ⇒ h= = =0 .05
n 4
−x
The values of y( x)=e √ x at equispaced points are as follows:
x 0.5 0.55 0.6 0.65 0.7
y 0.4289 0.4279 0.4251 0.4209 0.4155
1
rd
The number of interval is n=4 , so we can apply Simpson’s 3 rule.
1
rd
By Simpson’s 3 rule
0. 7

∫ e− x √ x dx≃ h3 [( y 0 + y4 )+4( y 1+ y 3 )+2( y2)]


0. 5
0 .7
0 .05
⇒ ∫ e−x √ xdx≃ [(0 .4289+0. 4155 )+4 (0 .4279+0 .4209 )+2( 0.4251 )]=0 .08483
0 .5 3
1
x2
1/3
∫ 1+ x3 dx
Example: Find the value of ln 2 from 0 using Simpson’s rule with h=0 .25 .
x2
y ( x )=
Solution: It is given that 1+x 3 and h=0 .25 .
2
x
y ( x )=
The values of 1+x 3 corresponding to the subdivision points are as follows:
x 0 0.25 0.5 0.75 1
y 0 0.0615 0.2222 0.3956 0.5
1
rd
Here the number interval is n=4 , so we can apply Simpson’s 3 rule.
1
rd
By Simpson’s 3 rule
1
x2
∫ 1+ x3 dx≃ h3 [( y 0+ y 4 )+4 ( y 1+ y 3 )+2( y 2 )]
0
1
x2 0 . 25
⇒∫ dx ≃ [(0+0 .5)+4 (0. 0615+0.3956 )+2(0.2222 )]=0 . 2311
0 1+x
3 3
Actual Value of the Integration
1
x2
∫ 1+ x3 dx= 13 ln(1+x 3 )|xx =1=0=ln21 /3
0
1
1/3 1/3
Hence the value of ln 2 by Simpson’s 3 rule is ln 2 ≃0 .2311 .
rd

Example: The velocity v (km /min) of a moped which starts from rest, is given at fixed
intervals of time t( min) as follows:
t( min) 2 4 6 8 10 12 14 16 18 20
v(km /min ) 10 18 25 29 32 20 11 5 2 0
Estimate approximately the distance covered in 20 minutes.
Solution: If s(km) be the distance covered in time t( min ) , then
ds
=v
dt
20
⇒|s|t=20
t=0 = ∫ v dt
0

Here
h=2, v =0 , v =10 , v =18 , v =25⋯, v =0
0 1 2 3 10

There are 11 number of points, so number of interval is n=10 , so we can apply Simpson’s
1
3 rd rule.
1
rd
By Simpson’s 3 rule
20
|s|t=20
t=0 = ∫ v dt= h3 [(v 0 +v 10 )+4( v 1+v 3+ v 5+v7 +v 9 )+2( v 2+v 4+v 6 +v 8 )]
0
20
⇒|s|t=20
t=0 = ∫ v dt= 32 [(0+0)+4(10+25+32+11+2 )+2(18+29+20+5 )]=309 .33 km.
0
Hence the required distance covered in 20 minutes is s=309 . 33 km.
Assignment:
6

∫ 1+dxx2 1
rd
1. Evaluate 0 by using (i) Trapezoidal rule, (ii) Simpson’s 3 rule and (iii)
3
th
Simpson’s 8 rule. Take h=1.
0.6

∫ e−x dx
2
1 3
rd th
2. Use Simpson’s 3 rule and 8 rule to find 0 by taking seven ordinates.
6

∫ dxx
3. Find the value of 2 by Simpson’s rule. Hence obtain approximate value of ln 2.
5

∫ 4 dxx+5
4. Find an approximate value of ln 5 (take four decimal places) from 0 , using 11
coordinates by applying (i). Trapezoidal rule and (ii) Simpson’s rule.
π /2

∫ sin xdx 1
rd
5. Calculate the value of 0 by Simpson’s 3 rule, using 11 ordinates.
4

∫ e x dx
6. Evaluate 0 by Simpson’s rule, given that e=2.72, e 2 =7.39, e 3=20.09,
e 4 =54.6 and compare it with actual value.
7. Given that
x 4.0 4.2 4.4 4.6 4.8 5.0 5.2
f (x ) 1.3863 1.4351 1.4816 1.5261 1.5686 1.6094 1.6484
5.2

∫ f ( x)dx
Evaluate 4 by using
i. Trapezoidal rule
1
rd
ii. Simpson’s 3 rule
3
th
iii. Simpson’s 8 rule
**********************************END************************************

You might also like