Lecture - 13 & 14
Lecture - 13 & 14
Numerical Integration:
𝑏
Let 𝐼 = ∫𝑎 𝑦 𝑑𝑥 , where 𝑦 = 𝑓(𝑥)
Let the interval [𝑎, 𝑏] be divided into 𝑛 equal subintervals such that 𝑎 = 𝑥0 < 𝑥1 < 𝑥2 <
⋯ ⋯ < 𝑥𝑛 = 𝑏. Clearly, 𝑥𝑛 = 𝑥0 + 𝑛ℎ. Hence the integral becomes
𝑥𝑛
𝐼 = ∫ 𝑦 𝑑𝑥
𝑥0
Approximating 𝑦 by Newton’s forward difference formula, we get
𝑥𝑛
p(p − 1) 2 p(p − 1)(p − 2) 3
𝐼 = ℎ ∫ [𝑦0 + 𝑝 Δy0 + Δ y0 + Δ y0 + ⋯ ] 𝑑𝑥
2 6
𝑥0
Since
𝑥 = 𝑥0 + 𝑝ℎ
𝑥= 𝑥0 + 𝑝ℎ 𝑥= 𝑥0 + 𝑝ℎ
𝑑𝑝
⟹1=0+ℎ 𝑥0 = 𝑥0 + 𝑝ℎ 𝑥𝑛 = 𝑥0 + 𝑝ℎ
𝑑𝑥 𝑥𝑛 − 𝑥0
∴ 𝑝ℎ = 0 ∴𝑝=
1 𝑑𝑝 ℎ
⟹ = = 𝑛
ℎ 𝑑𝑥
⟹ 𝑑𝑥 = ℎ 𝑑𝑝
𝑛2 1 𝑛3 𝑛2 2 1 𝑛4
=ℎ [𝑛𝑦0 + Δ𝑦0 + ( − ) Δ 𝑦0 + ( − 𝑛3 + 𝑝2 ) Δ3 𝑦0 + ⋯ ] − 0
2 2 3 2 6 4
𝑛2 1 2 2𝑛 − 3 2 1 2 𝑛2 − 4𝑛 + 4 3
=ℎ [𝑛𝑦0 + Δ𝑦0 + 𝑛 ( ) Δ 𝑦0 + 𝑛 ( ) Δ 𝑦0 + ⋯ ]
2 2 6 6 4
𝑥𝑛
𝑛 1 𝑛(2𝑛−3) 𝑛(𝑛−2)2
∴ ∫ 𝑦 𝑑𝑥 =𝑛ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 + ⋯ ] ⋯ ⋯ (1 )
2 2 12 24
𝑥0
This is known as 'Newton-cotes quadrature formula'. From this general formula, we can
get different integration formula by putting 𝑛 = 1, 2, 3, ⋯ ⋯ etc.
Trapezoidal Rule:
We know, general quadrature formula for numerical integration is
𝑥𝑛
𝑛 1 𝑛(2𝑛−3) 𝑛(𝑛−2)2
∴ ∫ 𝑦 𝑑𝑥 =𝑛ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 + ⋯ ] ⋯ ⋯ (1 )
2 2 12 24
𝑥0
Putting 𝑛 = 1 in the general formula (1) and neglecting second and higher differences,
we get
𝑥1
1
∫ 𝑦 𝑑𝑥 = ℎ [𝑦0 + Δ𝑦0 ]
2
𝑥0
1
=ℎ [𝑦0 + (y1 − y0 )]
2
ℎ
= 2 [2𝑦0 + 𝑦1 − 𝑦0 ]
ℎ
= 2 [𝑦0 + 𝑦1 ]
For the next interval[𝑥1 , 𝑥2 ], similarly we get,
𝑥2
ℎ
∫ 𝑦 𝑑𝑥 = [𝑦1 + 𝑦2 ]
2
𝑥1
And so on. For the last interval[𝑥𝑛−1 , 𝑥𝑛 ], we get,
𝑥𝑛
ℎ
∫ 𝑦 𝑑𝑥 = [𝑦𝑛−1 + 𝑦𝑛 ]
2
𝑥𝑛−1
Summing up all these, we get
𝑥𝑛
ℎ
∫ 𝑦 𝑑𝑥 = [𝑦0 + 2(𝑦1 + 𝑦2 + ⋯ ⋯ + 𝑦𝑛−1 ) + 𝑦𝑛 ]
2
𝑥0
Which is known as Trapezoidal Rule.
𝟏
Simpson’s Rule:
𝟑
We know, general quadrature formula for numerical integration is
𝑥𝑛
𝑛 1 𝑛(2𝑛−3) 𝑛(𝑛−2)2
∴ ∫ 𝑦 𝑑𝑥 =𝑛ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 + ⋯ ] ⋯ ⋯ (1 )
2 2 12 24
𝑥0
Putting 𝑛 = 2 in the general formula (1) and neglecting 3rd and higher differences, we get
𝑥2
2 2(2⋅2−3)
∫ 𝑦 𝑑𝑥 = 2ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 ]
2 12
𝑥0
1
=2ℎ [𝑦0 + (𝑦1 − 𝑦0 ) + (𝑦 − 2𝑦1 + 𝑦0 )]
6 2
2ℎ
= [6𝑦0 + 6𝑦1 − 6𝑦0 + 𝑦2 − 2𝑦1 + 𝑦0 ]
6
ℎ
= [𝑦0 + 4𝑦1 + 𝑦2 ]
3
Similarly for the next interval[𝑥2 , 𝑥4 ], we get,
𝑥4
ℎ
∫ 𝑦 𝑑𝑥 = [𝑦 + 4𝑦3 + 𝑦4 ]
3 2
𝑥1
And so on. For the last interval[𝑥𝑛−2 , 𝑥𝑛 ], we get,
𝑥𝑛
ℎ
∫ 𝑦 𝑑𝑥 = [𝑦 + 4𝑦𝑛−1 + 𝑦𝑛 ]
3 𝑛−2
𝑥𝑛−2
Summing up all these, we get
𝑥𝑛
ℎ
[ ( ) ( )
∫ 𝑦 𝑑𝑥 = 3 𝑦0 + 4 𝑦1 + 𝑦3 + 𝑦5 + ⋯ ⋯ + 𝑦𝑛−1 + 2 𝑦2 + 𝑦4 + 𝑦6 + ⋯ ⋯ + 𝑦𝑛−2
𝑥0 + 𝑦𝑛 ]
𝟏
Which is known as Simpson’s Rule.
𝟑
𝟑
Simpson’s Rule:
𝟖
We know, general quadrature formula for numerical integration is
𝑥𝑛
𝑛 1 𝑛(2𝑛−3) 𝑛(𝑛−2)2
∴ ∫ 𝑦 𝑑𝑥 =𝑛ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 + ⋯ ] ⋯ ⋯ (1 )
2 2 12 24
𝑥0
Putting 𝑛 = 3 in the general formula (1), we get
𝑥 3 3 3 1
∫𝑥0 𝑦 𝑑𝑥 = 3ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 ]
2 4 8
3ℎ 3⋅8 3⋅8 2 8
= [8𝑦0 + Δ𝑦0 + Δ 𝑦0 + Δ3 𝑦0 ]
8 2 4 8
3ℎ
= [8𝑦0 + 12 (y1 − 𝑦0 ) + 6 (𝑦2 − 2𝑦1 + 𝑦2 ) + (𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0 )]
8
3ℎ
= [8𝑦0 + 12 𝑦1 − 12 𝑦0 + 6 𝑦2 − 12 𝑦1 + 6𝑦0 + 𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0 ]
8
3ℎ
= [𝑦0 + 3 𝑦1 + 3 𝑦2 + 𝑦3 ]
8
𝑥𝑛
3ℎ
[
∫ 𝑦 𝑑𝑥 = 8 𝑦0 + 3 (𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 + ⋯ + 𝑦𝑛−2 + 𝑦𝑛−1 ) + 2(𝑦3 + 𝑦6 + ⋯ + 𝑦𝑛−3
𝑥0 + 𝑦𝑛 ]
𝟑
Which is known as Simpson’s Rule.
𝟖
Weddle’s rule:
We know, general quadrature formula for numerical integration is
𝑥𝑛
𝑛 1 𝑛(2𝑛−3) 𝑛(𝑛−2)2
∴ ∫ 𝑦 𝑑𝑥 =𝑛ℎ [𝑦0 + Δ𝑦0 + Δ2 𝑦0 + Δ3 𝑦0 + ⋯ ] ⋯ ⋯ (1 )
2 2 12 24
𝑥0
Putting 𝑛 = 6 in the general formula (1) and neglecting all differences of above the sixth,
we get
𝑥6
9 2 123 4 11 5 1 41 6
∫ 𝑦 𝑑𝑥 = 6ℎ [𝑦0 + 3 Δ𝑦0 + Δ 𝑦0 + 4Δ3 𝑦0 + Δ 𝑦0 + Δ 𝑦0 + ∙ Δ 𝑦0 ]
2 60 20 6 140
𝑥0
41 3 3 41 1
We now replace Δ6 𝑦0 by Δ6 𝑦0 , the error made will be − = which is
140 10 10 140 140
negligible.
𝑥6
3ℎ
∴ ∫ 𝑦 𝑑𝑥 = [𝑦 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 + 𝑦6 ]
10 0
𝑥0
Similarly for the next interval[𝑥6 , 𝑥12 ], we get,
𝑥12
3ℎ
∫ 𝑦 𝑑𝑥 = [𝑦 + 5𝑦7 + 𝑦8 + 6𝑦9 + 𝑦10 + 5𝑦11 + 𝑦12 ]
10 6
𝑥6
𝑥𝑛
3ℎ
∫ 𝑦 𝑑𝑥 = [(𝑦 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 ) + (2𝑦6 + 5𝑦7 + 𝑦8 + 6𝑦9 + 𝑦10 + 5𝑦11 )
10 0
𝑥0
𝟏 𝟏 𝟏
Example: Evaluate 𝑰 = ∫𝟎 𝒅𝒙 using trapezoidal rule and Simpson’s rule.
𝟏+𝒙 𝟑
Solutions:
𝑥𝑛 −𝑥0 1−0
Take ℎ = 0.25 then 𝑛 = = = 0.25. So the interval (0,1) divides into 4 equal parts.
ℎ 4
Here the tabulated values are given below:
𝑥 0 0.25 0.50 0.75 1.0
1
𝑦= 1.0000 0.8000 0.6667 0.5714 0.5
1+𝑥
𝟏 𝟏
Problem: Compute the integral ∫𝟎 𝒅𝒙 up to 4 decimal places by using Simpson’s
√𝟏+𝒙𝟐
𝟏
rule. Ans: 0.88137
𝟑
𝟓.𝟐
Example: Calculate the value of the integral ∫𝟒 𝒍𝒏𝒙 𝒅𝒙 by using
(i) Trapezoidal rule, n=1
𝟏
(ii) Simpson’s rule, n=2
𝟑
𝟑
(iii) Simpson’s rule, n=3
𝟖
(iv) Weddle’s rule, n=6
After finding the exact value, compare the errors in the four cases.
𝑥𝑛 −𝑥0 5.2−4
Solution: Let 𝑛 = 6, then ℎ = = = 0.2
𝑛 6
So taking ℎ = 0.2 the interval (4,5.2) divides into 6 equal parts. Here the tabulated values
are as follows:
𝑥 4.0 4.2 4.4 4.6 4.8 5.0 5.2
𝑦 = 𝑙𝑛𝑥 1.3862944 1.4350845 1.4816045 1.5260563 1.5658159 1.609437 1.6486586
(i) By trapezoidal rule, we have
ℎ
𝐼 = 2 [𝑦0 + 2(𝑦1 + 𝑦2 + 𝑦3 + 𝑦4 + 𝑦5 ) + 𝑦6 ]
0.2
= [1.3862944 + 2(1.4350845 + 1.4816045 + 1.5260563 + 1.5658159
2
+1.609437) + 1.6486586]
=1.8276551
𝟏
(ii) By Simpson’s rule, we have
𝟑
ℎ
𝐼= [𝑦 + 4(𝑦1 + 𝑦3 + 𝑦5 ) + 2(𝑦2 + 𝑦4 ) + 𝑦6 ]
3 0
0.2
= [1.3862944 + 4(1.4350845 + 1.5260563 + 1.6094379)
3
+2(1.4816045 + 1.5686159) + 1.6486586]
=1.8278472
𝟑
(iii) By Simpson’s rule, we have
𝟖
3ℎ
𝐼= [𝑦0 + 3 (𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 ) + 2𝑦3 + 𝑦6 ]
8
3 × 0.2
= [1.3862944 + 3 (1.4350845 + 1.4816045 + 1.5658159 + 1.609437)
8
+2 × 1.5260563 + 1.6486586]
=1.827847
(iv) By Weddle’s rule, we have
3ℎ
𝐼 = [(𝑦0 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 ) + 𝑦6 ]
10
3 × 0.2
= [(1.3862944 + 5 × 1.4350845 + 1.4816045 + 6 × 1.5260563
10
+1.5658159 + 5 × 1.609437) + 1.6486586]
=1.8278474
2nd Part:
5.2 𝑑
∫ 𝑢𝑣 𝑑𝑥 = 𝑢 ∫ 𝑣 𝑑𝑥 − ∫ { 𝑢 ∫ 𝑣 𝑑𝑥} 𝑑𝑥
𝑑𝑥
Exact Value = ∫ 𝑙𝑛𝑥 𝑑𝑥
∴ ∫ 𝑙𝑛𝑥 𝑑𝑥 = ∫ 𝑙𝑛𝑥 ⋅ 1 𝑑𝑥
4
𝑑
= 𝑙𝑛𝑥 ∫ 1 𝑑𝑥 − ∫ { 𝑙𝑛𝑥 ∫ 1 𝑑𝑥} 𝑑𝑥
=[𝑥 (𝑙𝑛𝑥 − 1)]5.2
4 𝑑𝑥
1
= 𝑥𝑙𝑛𝑥 − ∫ ⋅ 𝑥 𝑑𝑥
𝑥
=[𝑥 𝑙𝑛𝑥 − 𝑥]5.2
4
= 𝑥𝑙𝑛𝑥 − ∫ 1 𝑑𝑥
=1.8278475 = 𝑥𝑙𝑛𝑥 − 𝑥
𝟑
(iii) Due to Simpson’s rule:
𝟖
1.8278475 − 1.827847 = 0.0000005
(iv) Due to Weddle’s Rule:
1.8278475 − 1.8278474 = 0.0000001
Here, we see that Weddle’s Rule is more accurate.
𝟔 𝒅𝒙 𝟏 𝟑
Example: Evaluate ∫𝟎 by using Simpson’s rule, Simpson’s rule and Weddle’s
𝟏+𝒙𝟐 𝟑 𝟖
Rule.
𝑥𝑛 −𝑥0 6−0
Solution: Let 𝑛 = 6, then ℎ = = =1
𝑛 6
Here the tabulated values are as follows:
𝑥 0 1 2 3 4 5 6
1
𝑦= 1 0.5 0.2 0.1 0.0588235 0.038405 0.0270270
1 + 𝑥2
𝟏
(i) By Simpson’s rule, we have
𝟑
ℎ
𝐼 = [𝑦0 + 4(𝑦1 + 𝑦3 + 𝑦5 ) + 2(𝑦2 + 𝑦4 ) + 𝑦6 ]
3
1
= [1 + 4(0.5 + 0.1 + 0.038405) + 2(0.2 + 0.0588235) + 0.0270270]
3
=1.3661734
𝟑
(ii) By Simpson’s rule, we have
𝟖
3ℎ
𝐼= [𝑦0 + 3 (𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 ) + 2𝑦3 + 𝑦6 ]
8
3×1
= [1 + 3 (0.5 + 0.2 + 0.0588235 + 0.038405) + 2 × 0.1 + 0.0270270]
8
=1.3570808
(iii) By Weddle’s rule, we have
3ℎ
𝐼 = [(𝑦0 + 5𝑦1 + 𝑦2 + 6𝑦3 + 𝑦4 + 5𝑦5 ) + 𝑦6 ]
10
3×1
= [(1 + 5 × 0.5 + 0.2 + 6 × 0.1 + 0.0588235 + 5 × 0.038405) + 0.0270270]
10
=1.3734474
𝟏 𝒅𝒙 𝟑
Example: Evaluate ∫𝟎 by using Simpson’s rule. Hence obtains the approximate
𝟏+𝒙𝟐 𝟖
value of 𝝅.
𝟑
By Simpson’s rule, we have
𝟖
3ℎ
𝐼= [𝑦0 + 3 (𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 ) + 2𝑦3 + 𝑦6 ]
8
1
= 3 ×
6 [1 + 3 (0.972972 + 0.9 + 0.691307 + 0.590163) + 2 × 0.8 + 0.5]
8
∴ 𝐼 =0.785395375 ⋯ ⋯ (1)
1 𝑑𝑥 𝜋 𝜋
Now 𝐼 = ∫0 = [tan−1 𝑥 ]10 = tan−1 1 − tan−1 0 = tan−1 ⋅ 𝑡𝑎𝑛 −0=
1+𝑥 2 4 4
𝜋
∴𝐼= ⋯ ⋯ (2)
4
By comparing (1) and (2) we get,
𝜋
= 0.785395375
4
∴ 𝜋 = 3.1415815
Home Work:
2.4 𝑥 2
Problem: Find ∫1 𝑑𝑥 by Trapezoidal Rule. Hence obtain the error.
1+𝑥 2
Ans: Numerical Value = 1.00802, Exact Value = 1.00939 and Error = 0.00137.
1 𝑑𝑥 3
Problem: Find ∫0 √1+𝑥 2
by Simpson’s Rule and obtain the error.
8
Ans: 0.8813725
Problem: A river is 80 meters wide. The depth ‘d’ in meters at a distance x meter from
one back is given by the following table. Calculate the area of cross-section of the river using
Simpson’s one-third rule.
x: 0 10 20 30 40 50 60 70 80
d: 0 4 7 9 12 15 14 8 3
3
Problem: Evaluate ∫−3 𝑥 4 𝑑𝑥 , using the Trapezoidal rule and Weddle’s rule. Also Compare
it with the exact value.