Integration 23

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

GEC 320: Numerical Methods

Numerical Integration
1. Trapezoidal Rule
2. Simpson Rule
1. Trapezoidal Rule
The trapezoidal rule states that
𝑏 1
‫𝑥𝑑𝑦 𝑎׬‬ ≈ 𝑤𝑖𝑑𝑡ℎ 𝑜𝑓 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙, ℎ ቄ
2
1𝑠𝑡 + 𝑙𝑎𝑠𝑡 𝑜𝑟𝑑𝑖𝑛𝑎𝑡𝑒 +
𝑠𝑢𝑚 𝑜𝑓 𝑟𝑒𝑚𝑎𝑖𝑛𝑖𝑛𝑔 𝑜𝑟𝑑𝑖𝑛𝑎𝑡𝑒𝑠 ቅ

Example 1. use the trapezoidal rule with 4 intervals to integrate


3 2
‫׬‬1 𝑑𝑥 correct to 3 d.p
𝑥

Solution

𝑟𝑎𝑛𝑔𝑒 3−1
The width of interval, h, is given as = = 0.5
𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 4
Since the width of the interval is 0.5 it then implies that the ordinates occurs
at 1, 1.5, 2. 2.5 and 3 and the corresponding values of x are

x 1 1.5 2 2.5 3
2 2.0000 1.6330 1.4142 1.2649 1.1547
𝑥

𝑏
2 1
න 𝑑𝑥 ≈ 0.5 2 + 1.1547 + 1.6330 + 1.4142 + 1.2649
𝑎 𝑥 2
= 2.945 𝑡𝑜 3 𝑑. 𝑝
Example 2. use the trapezoidal rule with 6 intervals to evaluate
𝜋
1
‫׬‬0 1+sin 𝑥 𝑑𝑥
2 correct to 4 s.f

Solution
𝜋
𝑟𝑎𝑛𝑔𝑒 −0 𝜋
2
The width of interval, h, is given as = =
𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 6 12

𝜋
Since the width of the interval, h, is it then implies that the ordinates
12
𝜋 𝜋 𝜋 𝜋 5𝜋 𝜋
occurs at 0, , , , , and . The corresponding values of x are
12 6 4 3 12 2
𝜋 𝜋 𝜋 𝜋 5𝜋 𝜋
x 0 or 15 or 30 or 45 or 60 or 75 or 90
12 6 4 3 12 2

1 1.0000 0.79440 0.66667 0.58579 0.53590 0.50867 0.50000


1 + sin 𝑥

𝜋
2 1
න 𝑑𝑥
0 1 + sin 𝑥
𝜋 1
≈ ൜ 1 + 0.5
12 2
+ 0.7944 + 0.66667 + 0.58579 + 0.53590 + 0.50867 ൠ =
1.006 𝑡𝑜 4 s.f
Classwork. use the trapezoidal rule with 8 intervals to integrate
3 2
‫׬‬1 𝑑𝑥 correct to 3 d.p
𝑥
Ans 2.932
Simpson 1/3 Rule (for intervals which are multiples of 2 eg
2, 4, 6, etc)
𝑏
න 𝑦𝑑𝑥
𝑎
1
≈ 𝑤𝑖𝑑𝑡ℎ 𝑜𝑓 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙, ℎ ሼ 1𝑠𝑡 + 𝑙𝑎𝑠𝑡 𝑜𝑟𝑑𝑖𝑛𝑎𝑡𝑒
3
+ 4 𝑠𝑢𝑚 𝑜𝑓 𝑒𝑣𝑒𝑛 𝑜𝑟𝑑𝑖𝑛𝑎𝑡𝑒𝑠 + 2 𝑠𝑢𝑚 𝑜𝑓 𝑟𝑒𝑚𝑎𝑖𝑛𝑖𝑛𝑔 𝑜𝑟𝑑𝑖𝑛𝑎𝑡𝑒𝑠 ሽ

6 1
Example 3: Evaluate ‫׬‬0 1+𝑥 2 𝑑𝑥 using 1/3 Simpson rule with 6 intervals
Solution

𝑟𝑎𝑛𝑔𝑒 6−0
The width of interval, h, is given as = =1
𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 6

Since the width of the interval, h, is 1 it then implies that the ordinates
occurs at 0, 1, 2, 3, 4, 5, and 6. The corresponding values of x are

X 0 1 2 3 4 5 6
1 1 0.5 0.2 0.1 0.0588 0.0385 0.027
1 + 𝑥2
6 1 1
‫׬‬0 1+𝑥 2 𝑑𝑥 ≈ 1 ሼ 1 + 0.027 + 4 0.5 + 0.1 + 0.0385 + 2ሺ0.2 +
3
0.0588ሻሽ= 1.3662
𝜋
1
Example 4: Evaluate ‫׬‬0 3 [1 − 𝑠𝑖𝑛2 𝜃]𝑑𝜃 using Simpson rule with 6
3
intervals

Solution
𝜋
𝑟𝑎𝑛𝑔𝑒 −0 𝜋
3
The width of interval, h, is given as = =
𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 6 18

𝜋
Since the width of the interval, h, is it then implies that the ordinates
12
𝜋 𝜋 𝜋 2𝜋 5𝜋 𝜋
occurs at 0, , , , , and . The corresponding values of x are
18 9 6 9 18 3
𝜋 𝜋 𝜋 2𝜋 5𝜋 𝜋
x 0
18 9 6 9 18 3

1.000 0.9950 0.9803 0.9574 0.9286 0.8969 0.8660


1
[1 − 𝑠𝑖𝑛2 𝜃]
3

6 1 1 𝜋
‫׬‬0 1+𝑥 2 𝑑𝑥 ≈ ሼ 1 + 0.8660 + 4 0.9950 + 0.9574 + 0.8969 +
3 18
2 0.9803 + 0.9286 ሽ= 0.994
Simpson 3/8 Rule (for intervals which are multiples of 3 eg
3,6,9, etc)
𝑏
න 𝑦𝑑𝑥
𝑎
3
≈ 𝑤𝑖𝑑𝑡ℎ 𝑜𝑓 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙, ℎ ሼ 𝑦𝑜 + 𝑦𝑛 + 3ሺ𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 + 𝑦7 + 𝑦8 ሻ
8
+ 2 𝑦3 + 𝑦6 + 𝑦9 ሽ

6 1
Example 3: Evaluate ‫׬‬0 1+𝑥 2 𝑑𝑥 using Simpson rule with 6 intervals
Solution

𝑟𝑎𝑛𝑔𝑒 6−0
The width of interval, h, is given as = =1
𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 6

Since the width of the interval, h, is 1 it then implies that the ordinates
occurs at 0, 1, 2, 3, 4, 5, and 6. The corresponding values of x are

X 0 1 2 3 4 5 6
1 1 0.5 0.2 0.1 0.0588 0.0385 0.027
1 + 𝑥2
6
1 3
න 2
𝑑𝑥 ≈ 1 1 + 0.027 + 3ሺ0.5 + 0.2 + 0.0588 + 0.0385ሻ + 2 0.1
0 1+𝑥 8
= 1.35708

You might also like