Professional Documents
Culture Documents
Numerical Integration
6.1 Introduction:
If F(x) is a differentiable function whose derivative is f (x), then we can evaluate the definite integral I as:
𝒃
Fig. (6.1)
1
The range of integration (b – a) is divided into a finite number of intervals in numerical integration. The integration
techniques consisting of equal intervals are based on formulas known as Newton-Cotes closed quadrature formulas.
In this chapter, we present the following methods of integration with illustrative examples:
1. Midpoint rule.
1. Trapezoidal rule.
2. Simpson’s 1/3 rule.
3. Simpson’s 3/8 rule.
Fig.(6.2)
2
With the mid-ordinate rule each interval of width d is assumed to be replaced by a rectangle of height equal to the ordinate
at the middle point of each interval, shown as y1, y2, y3, . . . , yn in fig.(6.2).
Thus:
𝑏
Example 6.1:
Use the mid-ordinate rule with (a) 4 intervals, (b) 8 intervals, to evaluate:
3 2
∫1√𝑥 𝑑𝑥 correct to 3 decimal places.
Solution:
(a) With 4 intervals, each will have a width of 𝟑−𝟏
𝟒
i.e. 0.5 and the ordinates will occur at 1.0, 1.5, 2.0, 2.5 and 3.0.
2
Hence the mid-ordinates y1, y2, y3 and y4 occur at 1.25, 1.75, 2.25 and 2.75. Corresponding values of are shown in the
√𝑥
following table.
3
3 2
∫1√𝑥 𝑑𝑥 =(0.5)[1.7889+1.5119 + 1.3333+1.2060]
= 2.920, correct to 3 decimal places. Ans.
(b) With 8 intervals, each will have a width of 0.25 and the ordinates will occur at 1.00, 1.25, 1.50, 1.75, . . . and thus mid-
ordinates at 1.125, 1.375,
𝟐
1.625, 1.875 . . . Corresponding values of are shown in the following table.
√𝒙
𝒙 1.125 1.375 1.625 1.875 2.125 2.375 2.625 2.875
𝟐
1.886 1.706 1.569 1.461 1.372 1.298 1.234 1.180
√𝒙
As previously, the greater the number of intervals the nearer the result is to the true value (of 2.928, correct to 3 decimal
places).
4
6.3 General Quadrature Formula:
Let 𝑦 = 𝑓(𝑥) be a function, where y takes the values y0, y1, y2, ..yn for x = x0, x1, x2, ...... xn. We want to find the value
𝒃
of 𝐼 = ∫ 𝒂𝒇(𝒙)𝒅𝒙.
𝑏−𝑎
Let the interval of integration (a, b) be divided into n equal subintervals of width ℎ = 𝑛
, so that:
𝑥0 = 𝒂, 𝑥1 = 𝑥0 + ℎ, 𝑥2 = 𝑥0 + 2ℎ, . . . . . . . . . . . . , 𝑥 𝑛 = 𝑥0 +
𝑛ℎ = 𝒃. 𝒃 𝑥 0 +𝑛
ℎ
𝐼 = ∫ 𝒇(𝒙)𝒅𝒙 = ∫ … (𝟔. 𝟑)
𝒂 𝒇(𝒙)𝒅𝒙
Newton’s forward interpolation formula is given 𝑥0
by: 𝑦 = 𝑓(𝑥) = 𝑦 + 𝑢∆𝑦 +
𝑢 (𝑢 – 1) ∆ 𝑦0 + ⋯ + 𝑢 (𝑢 – 1)(𝑢 – 2) … . . (𝑢 – 𝑛 + 1) ∆𝑛 𝑦
2
0 0 2! 𝑛!
𝑥−𝑥 0 0
Where; 𝑢 = ℎ
1
∴ 𝑑𝑢 = 𝑑𝑥 → 𝑑𝑥 = ℎ𝑑𝑢
ℎ
∴ Equation (6.3) becomes: 𝑛
𝒃 𝑢(𝑢 – 1) ∆2𝑦0 + ⋯ + 𝑢 (𝑢 – 1)(𝑢 – 2) … . . (𝑢 – 𝑛 + 1) ∆𝑛 𝑦 0 ] 𝑑𝑢
𝐼 = ∫ 𝒇(𝒙)𝒅𝒙 = ℎ ∫ [𝑦0 + 𝑢∆𝑦0 + 2! 𝑛!
𝒂 0
𝑛 2
𝐼 = 𝑛ℎ [𝑦0 + ∆𝑦0 + 𝑛(2𝑛 – 3) ∆2𝑦0 + 𝑛(𝑛 – 2) ∆3𝑦0 + ⋯ ]
2 12 24
𝑥𝑛
𝑛 2
∆𝑦0 + 𝑛(2𝑛 – 3) ∆2𝑦0 + 𝑛(𝑛 – 2) ∆3𝑦0 + ⋯ ] … (𝟔.
∴ 𝐼 = ∫ 𝒇(𝒙)𝒅𝒙 = 𝑛ℎ [𝑦0 +
12 24 𝟒)
𝑥0 2
5
This is called general Quadrature formula.
Fig.(6.3)
6
𝑥 0 +2ℎ 𝑥 0 +𝑛
ℎ ℎ ℎ
𝐼= ∫ 𝑓(𝑥)𝑑𝑥 = [𝑦1 + 𝑦2] … 𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 = [𝑦𝑛−1
2 2
𝑥 0+ℎ + 𝑦𝑛 ]
Adding the above integrals, we get:
𝑥 0 +𝑛ℎ
𝑂𝑟; ∫ 𝑦 𝑑𝑥 ≈ (𝒘𝒊𝒅𝒕𝒉 𝒐𝒇 𝒊𝒏𝒕𝒆𝒓𝒗𝒂𝒍) [(𝒇𝒊𝒓𝒔𝒕 + 𝒍𝒂𝒔𝒕 𝒐𝒓𝒅𝒊𝒏𝒂𝒕𝒆) + 𝟐(𝒔𝒖𝒎 𝒐𝒇 𝒓𝒆𝒎𝒂𝒊𝒏𝒊𝒏𝒈 𝒐𝒓𝒅𝒊𝒏𝒂𝒕𝒆𝒔] − − − (𝟔. 𝟔)
𝟐
𝑎
Example 6.2:
𝟑 𝟐
(a)Use integration to evaluate, correct to 3 decimal places, ∫𝟏 𝒙 𝒅𝒙.
√
(b) Use
i. the trapezoidal rule with:
4 intervals.
ii. 8 intervals correct to 3 decimal places.
Solution:
a) Exact solution
3 3
2
∫ 𝑑𝑥 = ∫ 2𝑥−1⁄2𝑑𝑥 ..
1 1
√𝑥
7
1 3
(− 2)+1
2𝑥 3
=[ 1 ] = [4𝑥1⁄2] 1 = 4[√3 − √1]
− +1
2 1
= 2.928 𝑐𝑜𝑟𝑟𝑒𝑐𝑡 𝑡𝑜 3 𝑑𝑒𝑐𝑖𝑚𝑎𝑙𝑠 𝑝𝑙𝑎𝑐𝑒𝑠
(b)
i) The range of integration is the difference between the upper and lower limits, i.e. 𝟑 − 𝟏 = 𝟐. Using
the 𝟑 −𝟏
trapezoidal rule with 4 intervals gives an interval width 𝒉 = 𝟒 = 𝟎. 𝟓 and ordinates situated at 1.0, 1.5, 2.0, 2.5 and
𝟐
3.0. Corresponding values of √𝒙are shown in the table below, each correct to 4 decimal places (which is one more
decimal place than required in
the problem):
𝒙 1.0 1.5 2.0 2.5 3.0
2⁄√𝑥 2.0000 1.6330 1.4142 1.2649 1.1547
𝟑 −𝟏
ii) With 8 intervals, the width of each is 𝒉 = 𝟖
= 𝟎. 𝟐𝟓, giving ordinates at 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50,
𝟐
2.75 and 3.00. Corresponding values of √ 𝒙are
shown
𝒙 in
1.0the table below:1.5
1.25 1.75 2.0 2.25 2.5 2.75 3.0
8
2⁄√𝑥 2.0000 1.7889 1.6330 1.5119 1.4142 1.3333 1.2649 1.2060 1.1547
Example 6,3:
𝟏
𝝅⁄𝟐 𝒅𝒙,using 6 intervals. Give the answer correct to 4 significant figures.
Use the trapezoidal rule to evaluate ∫ 𝟎 𝟏+𝒔𝒊𝒏𝒙
Solution:
𝝅
−𝟎 𝝅 𝝅 𝝅 𝝅 𝝅 𝟓𝝅 𝝅
With 6 intervals, each will have a width of 𝟐
= 𝟏𝟐 rad (or 15◦ ) and the ordinates occur at 0, , , , , , .
𝟔 𝟏𝟐 𝟔 𝟒 𝟑 𝟏𝟐 𝟐
𝟏
𝝅⁄𝟐 𝒅𝒙, are shown in the table below.
Corresponding values of ∫ 𝟎 𝟏+𝒔𝒊𝒏𝒙
9
𝝅⁄𝟐
1 0.7944 + 0.6667 + 0.5858
∫ 𝑑𝑥 ≈ 𝜋 ⁄12 ( )]
0 1 + 𝑠𝑖𝑛𝑥 2 [ 1.0 + 0.5 ) + 2 ( +0.5359 + 0.5087
10
i.e. Simpson’s (1/3) rule states:
Note that Simpson’s rule can only be applied when an even number
+𝟐of intervals
(𝒔𝒖𝒎 is chosen,
𝒐𝒇 𝒆𝒗𝒆𝒏 i.e. an)odd number of ordinates as
𝒐𝒓𝒅𝒊𝒏𝒂𝒕𝒆𝒔
shown in figure (6.4):
Fig.(6.4)
Example 6.4:
Use Simpson’s rule with:
(a) 4 intervals,
𝟑 𝟐
(b) 8 intervals, to evaluate ∫ 𝟏𝒅𝒙.
√𝒙
correct to 3 decimal places.
11
Solution:
𝟑 −𝟏
(a) With 4 intervals gives an interval width 𝒉 = 𝟒 = 𝟎. 𝟓 and ordinates situated at 1.0, 1.5, 2.0, 2.5 and 3.0. The values
of the ordinates are as shown in the following table:
𝒙 1.0 1.5 2.0 2.5 3.0
2⁄√𝑥 2.0000 1.6330 1.4142 1.2649 1.1547
3 2𝑑𝑥 ≈
0.25
∫
1 3 [(2.0 + 1.1547) + 4(1.7889 + 1.5119 + 1.3333 + 1.2060) + 2(1.6330 + 1.4142 + 1.2649)]
√𝑥
12
Example 6.5:
Evaluate:
𝜋 ⁄3 1
∫0 √ (1 − 3 𝑠𝑖𝑛 2 𝜃) 𝑑𝜃
correct to 3 decimal places, using Simpson’s rule (1/3) with 6 intervals.
Solution:
𝝅
−𝟎 𝝅 𝝅 𝝅 𝝅 𝟐𝝅 𝟓𝝅 𝝅
With 6 intervals, each will have a width of 𝟑
= 𝟏𝟖 rad (or 10◦ ) and the ordinates occur at 0, , , , , , .
𝟔 𝟏𝟖 𝟗 𝟔 𝟗 𝟏𝟖 𝟑
𝜋⁄3 1
Corresponding values of ∫ 0√ ( 1 − 𝑠𝑖𝑛32 𝜃 ) 𝑑𝜃are shown in the table below:
𝝅 𝝅 𝝅 𝟐𝝅 𝟓𝝅 𝝅
𝜃 0 𝟏𝟖 𝟗 𝟔 𝟗 𝟏𝟖 𝟑
Or 10o Or 20o Or 30o Or 40o Or 50o Or 60o
1
√(1 − 1.0000 0.9950 0.9803 0.9574 0.9286 0.8969 0.8660
𝑠𝑖𝑛2 𝜃) 3
13
6.5 Simpson's (3/8) rule:
Putting n = 3 in equation (6.4) and taking the curve through (x0, y0), (x1, y1), (x2, y2) and (x3, y3) as a polynomial of
degree three so that differences of order higher than three vanish, we get:
𝑥 0 +3𝑑
3 3 1
∫ 𝑓 (𝑥)𝑑𝑥 = 𝑛ℎ [𝑦0 + 2 ∆𝑦0 + 4 ∆ 𝑦0 + 8 ∆3 𝑦0 ]
2
𝑥0
3ℎ
= [8𝑦0 + 12(𝑦1 − 𝑦0) + 6(𝑦2 − 2𝑦1 + 𝑦0) + (𝑦3 − 3𝑦2 + 3𝑦1 −
𝑦0)] 8
3ℎ
= [(𝑦0 + 3𝑦1 + 3𝑦2
+ 𝑦3)] 8
Similarly;
𝑥 0 +6𝑑
∫ 𝑓(𝑥)𝑑𝑥 =3ℎ [(𝑦3 + 3𝑦4 +
8
3𝑦5 + 𝑦6)], … ..
𝑥0
𝑥 0 +𝑛𝑑
3ℎ
∫ 𝑓(𝑥)𝑑𝑥 = [(𝑦𝑛−3 + 3𝑦𝑛−2 + 3𝑦𝑛−1 +
𝑦𝑛)] 8
𝑥 0+( 𝑛−3) 𝑑
14
Note that, using this formula, the given interval of integration must be divided into sub-intervals whose number n is a
multiple of 3.
Example 6.6:
𝒅𝒙
𝟔 by using:
Evaluate ∫ 𝟎 𝟏+𝒙𝟐
(i) Trapezoidal Rule
(ii) Simpson’s one-third rule
(iii) Simpson’s three-eighth rule
Solution:
Divide the interval [0, 6] into six parts each of width h = 1.
𝑑𝑥
The value of𝑓(𝑥) = 1+𝑥 2are given below:
15
(ii) By Simpson’s one-third rule,
6
𝑑𝑥 ℎ
∫ = [((𝑦0 + 𝑦6) + 4(𝑦1 + 𝑦3 + 𝑦5) + 2(𝑦2
0 + 𝑦4))] 1 + 𝑥 2 3
1 1 1 1
= [( (1 + ) + 4 (0.5 + 0.1 + ) + 2 (0.2 + )) ]
3 37 26 17
= 1.366173413.
= 1.357080836.
16
𝑑
𝑏−𝑎
𝐼= (𝟔. 𝟏𝟎)
2 ∫ [ 𝑓 ( 𝑎, 𝑦) + 𝑓(𝑏, 𝑦)]𝑑𝑦
𝑐
Applying Trapezoidal rule again to evaluate the integral on the right hand side of (6.10) we get:
𝐼 = (𝑏 − 𝑎)(𝑑 − 𝑐) [ ( ) [ (
4 [ 𝑓 𝑎, 𝑐 + 𝑓 𝑎, 𝑑) + 𝑓(𝑏, 𝑐)]𝑓(𝑏, 𝑑)]] (𝟔. 𝟏𝟏)
As shown in figure (6.5).
If discrete value are given we can use the composite Trapezoidal rule by dividing the interval [a, b] into n equal
subintervals each of length h and the interval [c, d] into m equal subintervals each of length k.
We have:
xi = x0 + ih, x0 = a, xn = b yj
= y0 + jk, y0 = c, ym = d
Applying composite Trapezoidal rule in both the directions we get:
17
(6.12)
As shown in figure (6.6).
18
6.6.2 Simpson’s (1/3) rule:
Taking 𝒉 = 𝒃−𝒂
𝟐
, 𝒌 = 𝒅−𝒄𝟐and applying Simpson’s rule to evaluate (6.9) we get:
ℎ𝑘
𝐼 = 9 {[𝑓(𝑎, 𝑐 ) + 𝑓(𝑎, 𝑑) + 𝑓(𝑏, 𝑐 ) + 𝑓(𝑏, 𝑑)] + 4[𝑓(𝑎, 𝑐 + 𝑘) + 𝑓(𝑎 + ℎ, 𝑐 ) + 𝑓(𝑎 + ℎ, 𝑑) + 𝑓(𝑏, 𝑐 + 𝑘)]
+ 16𝑓(𝑎 + ℎ, 𝑐 + 𝑘)}
(𝟔. 𝟏𝟑)
As shown in figure (6.7):
19
Fig. (6.8). Weights in the Simpson’s (1/3) rule
Example 6.7:
Evaluate the integral:
𝟐 𝟐
𝒅𝒙 𝒅𝒚
𝑰=∫ ∫
(𝒙 + 𝒚)
𝟏 𝟏
Using Trapezoidal rule with ℎ = 𝑘 = 0.5.
Solution:
Using Trapezoidal rule, we get:
20
Example 6.8:
Evaluate the integral:
𝟎.𝟓 𝟎.𝟓
𝒙𝒚
𝑰=∫ ∫ 𝒅𝒙 𝒅𝒚
𝟎 (𝟏 + 𝒙𝒚)
𝟎
Using Simpson’s (1/3) rule for double integrals with both step sizes equal to 0.25
Solution
Taking;
We have;𝑛 = 𝑘 = 0.25,
𝑥0 = 0, 𝑥1 = 0.25, 𝑥2 = 0.5
𝑦0 = 0, 𝑦1 = 0.25, 𝑦2 = 0.5
21
Using Simpson’s (1/3) rule, we get:
1
𝐼=
144 [0 + 0 + 0 + 4(0 + 0.235141 + 0.110822) + 0 + 0.443288 + 0.197923]
= 0.014063
Another variant:
Example 6.9:
Suppose that the temperature of a rectangular heated plate is described by the following function:
𝑇 (𝑥, 𝑦) = 2𝑥𝑦 + 2𝑥 − 𝑥 2 − 2𝑦 2 + 72
If the plate is 8 m long (x dimension) and 6 m wide (y dimension), compute the average temperature.
Solution:
Let us merely use two-segment applications of the trapezoidal rule in each dimension. The temperatures at the necessary x
and y values are depicted in figure (9).
To make the evaluation numerically, the trapezoidal rule is first implemented along the x dimension for each y value. These
values are then integrated along the y dimension to give the final result.
22
23