Professional Documents
Culture Documents
Learning outcomes
At the end of the lesson students will be able to evaluate the integrals by
Trapezoidal and Simpson’s 1/3 rule
5/20/2021 1
Introduction
•We can use numerical integration to estimate the values of definite
integrals when a closed form of the integral is difficult to find or when an
approximate value only of the definite integral is needed.
•The most commonly used techniques for numerical integration are the
midpoint rule, trapezoidal rule and Simpson’s rule.
•The midpoint rule approximates the definite integral using rectangular
regions whereas the trapezoidal rule approximates the definite integral
using trapezoidal approximations.
•Simpson’s rule approximates the definite integral by approximating the
original function using piecewise quadratic functions
5/20/2021 2
𝑏
Approach: If we wish to evaluate a integral 𝑎
𝑓 𝑥 𝑑𝑥
Where, f(x) is called the integrand,
a = lower limit of integral
b = upper limit of integral
Then we can find the value of the above integral assuming 𝑓(𝑥) ≈ 𝑃𝑛 (𝑥)
Where, 𝑃𝑛 𝑥 = 𝑎0 + 𝑎1𝑥 + … + 𝑎𝑛 𝑥 𝑛 is a nth order polynomial.
𝑏 𝑏
So, we have 𝑎
𝑓 𝑥 𝑑𝑥 ≈ 𝑃
𝑎 𝑛
𝑥 𝑑𝑥 (Newton-Cotes Formula)
Note:
𝑏
• For trapezoidal rule, 𝑎
𝑓 𝑥 𝑑𝑥 is approximated assuming 𝑓(𝑥) ≈ 𝑃1 (𝑥)= a0 + a1x (first order Polynomial)
𝑏
• For Simpson’s 1/3 rule, 𝑎 𝑓 𝑥 𝑑𝑥 is approximated assuming 𝑓(𝑥) ≈ 𝑃2 (𝑥)= a0 + a1x + a2x2 (Second order Polynomial)
5/20/2021 3
Derivation of Trapezoidal Rule
Method I: Now, we can Derive the trapezoidal rule assuming
𝑏 𝑏
𝑎
𝑓 𝑥 𝑑𝑥 ≈ 𝑎 1
𝑃 𝑥 𝑑𝑥 where, P1 x is first order polynomial given by P1 x = a0 + a1x.
b b
f ( x)dx (a
a a
0 a1 x)dx
Also,
f (a ) f (b) (a0 a1a ) (a0 a1b)
2 2
a0 x a 2 x 2
b
a
2a 0 a1 (a b)
2
b2 a2 ab
a 0 (b a) a1 a0 a1 ... (ii )
2 2
b a
(b a ) a0 a1 ... (i )
2
𝑏
We know that, 𝑎
𝑓 𝑥 𝑑𝑥 = Area encloses by the curve y = f x , x − axis and ordinates at x = a, x = b.
5/20/2021 5
a) Derivation of Trapezoidal Rule(Elementary trapezoidal rule:)
𝑏
𝑎
𝑓 𝑥 𝑑𝑥 ≈ Area of trapezium
1
= ( sum of parallel sides)x height
2
1
= {f(a)+f(b)}(b-a)
2
[f(a)+f(b)]
= (b − a) .
2
5/20/2021 6
b. Derivation of composite trapezoidal rule
If a function f is continuous in [a,b] then
𝑏 h
𝑎
𝑓 𝑥 𝑑𝑥 ≈ 2 {f(x0)+2f(x1)+2f(x2)+2f(x3)+…………+2f(xn-1)+f(xn)}
b−a
Where [a,b] has been divided into n-sub intervals [x0,x1],[x1,x2],[x2,x3]……..[xn-1,xn] each of length h= n .
Proof:
We have a continuous function f defined in [a,b].
Now, we shall divide the interval [a,b] into n equally spaced sub-
b−a
intervals [x0,x1],[x1,x2],[x2,x3]……..[xn-1,xn] each of length h= .
n
5/20/2021 7
So, sum of area of all these n-trapezium is the required area.
𝑏
∴ 𝑎 𝑓 𝑥 𝑑𝑥 ≈ sum of area of n-trapezium
1 1 1 1
= [f(x0)+f(x1)]h + [f(x1)+f(x2)]h+ [f(x2)+f(x3)]h+……+ [f(xn-1)+f(xn)]h
2 2 2 2
h
= {f(x0)+f(x1)+f(x1)+f(x2)+f(x2)+f(x3)+f(x3)+…………+f(xn-1)+f(xn)
2
h
= {f(x0)+2f(x1)+2f(x2)+2f(x3)+…………+2f(xn-1)+f(xn)}
2
Remarks:
𝑏 h 𝑏−𝑎
1. 𝑓 𝑥 𝑑𝑥 = {y0+2y1+2y2+2y3+…………+2yn-1+yn} , where ℎ =
𝑎 2 𝑛
5/20/2021 8
Error and error bound of trapezoidal approximation
Error of approximation = E = actual value−aaproximated value = 𝑣 − 𝑣𝑎𝑝𝑝𝑟𝑜𝑥
b−a 3
Error bound of trapezoidal approximation ( max. expected error) = Et = 12n2 M
Where M= max. |f ’’(x)| in [a,b]
Note: number of sub intervals=n, number of partitioned points=n+1.
in adjoining figure no. of partitioned points= A,B,C,D,E =5
and no. of sub intervals = [ A,B],[B,C],[C,D],[D,E] =4
Solution:
We know,
f ( a ) f ( b )
I ( b a )
2
Here, a = 0 and b = 1
1
𝑓 (𝑥 ) = .
1+𝑥 2
1 1 1
𝑆0, 𝑓(0) = = 1, and 𝑓(1) = =
1+02 1+12 2
Now by using trapezoidal rule,
1 1 𝑏−𝑎 1−0
0 1+𝑥 2
𝑑𝑥 ≈ [𝑓 (0) + 𝑓(1) = ( )[1 + 0.5 = 0.75
2 2
𝟏
𝟏
∴ 𝒅𝒙 ≈ 𝟎. 𝟕𝟓. 𝑨𝒏𝒔
𝟏 + 𝒙𝟐
𝟎
5/20/2021 10
1 1
Example: Find the approximate value for 0 1+𝑥 2
𝑑𝑥, n=2 using composite trapezoidal rule.
𝑏 1 1
Solution: Given, 𝑎
𝑓 𝑥 𝑑𝑥 = 0 1+𝑥 2
𝑑𝑥
1
⇒a=0, b=1 and f(x)=
1+𝑥 2
Number of sub-intervals(n)= 2
𝑏−𝑎 1−0
Height of sub-intervals(h)= = = 0.5
𝑛 2
∴ the partitioned points and their ordinates are given by
x 𝑥0 = 𝑎 =0 𝑥1 = 𝑎 + ℎ =0.5 𝑥2 = 𝑎 + 2ℎ =1
f(x) 1 0.8944 0.7071
5/20/2021 11
3
Example: Evaluate 1 exlnx dx using composite trapezoidal rule for three points subintervals.
𝑏 3
Solution: Given, 𝑎 𝑓 𝑥 𝑑𝑥 = 1 exlnx dx
⇒a=1, b=3 and f(x)= exlnx
𝑏−𝑎 3−1
Height of sub-intervals(h)= = = 1
𝑛 2
x 𝑥0 = 𝑎 = 1 𝑥1 = 𝑎 + ℎ = 2 𝑥2 = 𝑎 + 2ℎ = 3
f(x) 0 5.1217 22.0662
x 𝑥0 =0 𝜋 𝜋 𝜋 2𝜋 5𝜋
𝑥1 = 𝑥2 = 𝑥3 = 𝑥4 = 𝑥5 = 𝑥6 = 𝜋
6 3 2 3 6
f(x) 0 0.7071 0.9306 1 0.9306 0.7071 0
5/20/2021 13
2 1
Example: Given I = 0 1+𝑥 𝑑𝑥
a) Approximate I using composite trapezoidal rule with five points sub- intervals.
b) Determine the actual value of I
(c) Find the error of approximation from Its actual value
(d) Find the absolute error bound of approximation. Does error lies within the bound?
(e) How many partition point is required to get approximation within the accuracy of 10-2?
𝑏 2 1
Solution: Given, 𝑎
𝑓 𝑥 𝑑𝑥 = 0 1+𝑥
𝑑𝑥
1
⇒a=0, b=2 and f(x)= 1+𝑥
a) Number of sub-intervals(n) = 4
𝑏−𝑎 2−0
Height of sub-intervals(h)= 𝑛 = 4 = 0.5
∴ the partitioned points and their ordinates are given by
x 𝑥0 =0 𝑥1 =0.5 𝑥2 =1 𝑥3 =1.5 𝑥4 =2
f(x) 1 0.667 0.5 0.4 0.333
b−a 3
d) We have absolute error bound of trapezoidal approximation ( max. expected error) |𝐸𝑡 |= M
12n2
Where M= max. |f ’’(x)| in [a, b]
1
Now, we have f(x) = = (1 + x)-1
1+𝑥
f’(x) = -1(1 + x)-2
2
f’’(x) = 2(1 + x)-3 = 3
1+𝑥
∴ M = max. |f”(x)| in [a, b] = [0, 2]
2
M =| |= 2
1+0 3
b−a 3 2−0 3 8
So, |𝐸𝑡 | = M = .2 = .2 = 0.0833
12n2 12.42 12 . 16
here, 𝐸 < | 𝐸𝑡|
5/20/2021 16
Exercise 1:
𝑏
1. Approximate 𝑎
𝑓 𝑥 𝑑𝑥 given the table of values
2. Compute the approximate value for the followings using composite trapezoidal rule
21 4 4
(a) 1 𝑥 𝑑𝑥 , n = 2 (b) 0 (2𝑥 + 1) 𝑑𝑥, 𝑛 = 4 (c) 0 (2𝑐𝑜𝑠3𝑥 − 1) 𝑑𝑥, 𝑛 = 4
2 𝑥 1
3. Using composite trapezoidal rule Evaluate 0
2 𝑑𝑥 , using composite trapezoidal rule with h = 2 .
42
4. How large should we take n in order to guarantee that the trapezoidal approximation for 1 𝑥 𝑑𝑥 is accurate
within 0.0001.
2 1
5. Using composite trapezoidal rule Evaluate 0 𝑥 −2 𝑑𝑥 , using composite trapezoidal rule with h = 2
5/20/2021 17
Topic : Simpson’s 1/3 Rule
f ( x)dx P ( x)dx
a a
2 , where 𝑃2 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2
5/20/2021 18
Proof: Let [a, b] has been divided into three equally spaced partitioned points
a+b b−a
a, m= , b such that h=
2 2
f (a) a0 a1a a2 a 2
2
ab ab ab
f a0 a1 a2
2 2 2
f (b) a0 a1b a 2 b 2
𝑎+𝑏
Here, 𝑓 (𝑎) + 4𝑓 + 𝑓 (𝑏)
2
2
𝑎+𝑏 𝑎+𝑏
= (𝑎0 + 𝑎1 𝑎 + 𝑎2 𝑎2 ) + 4 𝑎0 + 𝑎1 + 𝑎2 + (𝑎0 + 𝑎1 𝑏 + 𝑎2 𝑏 2 )
2 2
= {6𝑎0 + 3𝑎1 (𝑏 + 𝑎) + 2𝑎2 (𝑏 2 + 𝑏𝑎 + 𝑎2 ) .....(i)
5/20/2021 19
b b
Now, f ( x)dx (a0 a1 x a 2 x 2 )dx
a a
𝑏
𝑥2 𝑥3
= 𝑎0 𝑥 + 𝑎1 + 𝑎2
2 3 𝑎
𝑏−𝑎
= {6𝑎0 + 3𝑎1 (𝑏 + 𝑎) + 2𝑎2 (𝑏2 + 𝑏𝑎 + 𝑎2 ) ...(ii)
6
b
ba ab
so,
a
f ( x)dx
6
f ( a ) 4 f
2
f (b )
b
h ab ba
Therefore, f ( x)dx f (a) 4 f
a
3 2
f (b) as we have h
2
5/20/2021 20
3. Derivation of Composite Simpson's rule( Simpson's 1/3 rule)
𝑏 h
If a function f is continuous in [a,b] then 𝑓 𝑥 𝑑𝑥 ≈
𝑎 3 {f(x0)+4f(x1)+2f(x2)+4f(x3)+…………+4f(xn-1)+f(xn)}
b−a
Where [a,b] has been divided into n-sub intervals [x0,x1],[x1,x2],[x2,x3]……..[xn-1,xn] each of length h=
n .
𝑥𝑖+1 h
𝑓 𝑥 𝑑𝑥 ≈ { f(xi-1)+ 4f(xi)+ f(xi+1)}.
𝑥𝑖−1 3
5/20/2021 21
𝑏
∴ 𝑎
𝑓 𝑥 𝑑𝑥 ≈ sum of area under the parabolic arcs with each successive three points sub intervals.
ℎ ℎ ℎ
= [f(x0)+4f(x1)+f(x2] + [f(x2)+4f(x3)+f(x4]+…+ [f(xn-2)+4f(xn-1)+f(xn]
3 3 3
h
= {f(x0)+4f(x1)+f(x2)+f(x2)+4f(x3)+f(x4)+…………+4f(xn-1)+f(xn)}
3
h
= {f(x0)+4f(x1)+2f(x2)+4f(x3)+…………+4f(xn-1)+f(xn)}.
3
5/20/2021 22
Example
𝟏 𝟐
Using simpson’s 𝟑 rule evaluate 𝟎
(𝟐𝒙 − 𝟏)𝟐 𝒅𝒙 with n = 4.
2
Soln: Given integral is 0 (2𝑥 − 1)2 𝑑𝑥 with n = 4
1
Now, using Simpson’s rule
3
2
ℎ
(2𝑥 − 1)2 𝑑𝑥 ≈ [𝑓(𝑥0 ) + 4𝑓 (𝑥1 ) + 2𝑓 (𝑥2 ) + 4𝑓(𝑥3 ) + 𝑓 (𝑥4 )
3
0
1
= [1 + 4.0 + 2.1 + 4.4 + 9
2.3
1
= [28 = 4.667. 𝐴𝑛𝑠
6
5/20/2021 23
𝜋
Example: Estimate the following integral using simpson’s 1/3 rule, 0
𝑠𝑖𝑛𝑥 𝑑𝑥,
𝑛 = 6.
𝜋
Soln: Given integral is 0
𝑠𝑖𝑛𝑥 𝑑𝑥, 𝑛 = 6.
𝜋 1 3 3 1
= 0+4× +2× +4×1+2× +4× +0
6.3 2 2 2 2
𝜋
= 8 + 2 3 = 𝟐. 𝟎𝟎𝟎𝟖𝟔. Ans...
18
5/20/2021 24
1 1
Example: Define Simpson’s rule, hence evaluate 0 1+𝑥
𝑑𝑥 , for n = 4
5/20/2021 25
x 𝑥0 =0 𝑥1 =0.25 𝑥2 =0.5 𝑥3 =0.75 𝑥4 =1
f(x) 1 0.8 2/3 4/7 0.5
Now, using Simpson’s 1/3 rule,
1
1 ℎ
𝑑𝑥 ≈ [𝑓 (𝑥0 ) + 4. 𝑓 (𝑥1 ) + 2𝑓 (𝑥2 ) + 4𝑓(𝑥3 ) + 𝑓 (𝑥4 )
0 1+𝑥 3
0.25 2 4
≈ ( )
1 + 4. 0.8 + 2. ( ) + 4 + 0.5
3 3 7
1 1747
= . = 0.69325
12 210
5/20/2021 26
4
Example: Given I = 0 𝑥4 𝑑𝑥
a) Approximate I using Simpson’s 1/3 rule with n = 4.
b) Determine the actual value of I
(c) Find the error of approximation from Its actual value
(d) Find the absolute error bound of approximation. Does error lies within the bound?
1
(e) How many partition point is required to get approximation within the accuracy of 2 × 10-3?
𝑏 4
Solution: Given, 𝑎 𝑓 𝑥 𝑑𝑥 = 0 𝑥4 𝑑𝑥
⇒a=0, b=2 and f(x)=𝑥4
a) Number of sub-intervals(n) = 4
𝑏−𝑎 4−0
Height of sub-intervals(h)= 𝑛 = 4 = 1
∴ the partitioned points and their ordinates are given by
x 𝑥0 =0 𝑥1 =1 𝑥2 =2 𝑥3 =3 𝑥4 =4
f(x) 0 1 16 81 256
1
= 3 { 0+ 4x1 +2x 16 +4x 81 + 256}
b−a 5
d) We have absolute error bound of Simpson’s approximation ( max. expected error) |𝐸𝑡 |= M
180n4
Where M= max. |f4(x)| in [a, b]
4−0 5 1 1
Or,
180.n4 .24 ≤ 2 × 1000
2048 1 1
Or, ≤ ×
15n4 2 1000
⇒ 15n4 ≥ 2048 ×2 ×1000
⇒ n4 ≥ 273066.667
4
⇒ n ≥ 273066.667 = 22.85 ≈ 23
5/20/2021 29
Exercise 2:
1. A survey shows that a function f has the values as in the table
2
Use composite Simpson’s 1/3 rule to Approximate 1
𝑓 𝑥 𝑑𝑥 given the table of values.
2. Compute the approximate value for the followings using Simpson’s 1/3 rule
𝜋
21 1
(a) 1 𝑥
𝑑𝑥 , n =2 (b) 0
1+ 𝑥 3 𝑑𝑥, 𝑛 =4 (c) 2
0
𝑐𝑜𝑠𝑥 𝑑𝑥, 𝑛 = 2
.
2 1
3. Compute an approximate value of 0 𝑥+1 𝑑𝑥 , by using Simpson’s 1/3 rule with five points subintervals. Then
compare with the actual value of the integral. Next, determine the absolute error bond for the approximation and
numerically verify an upper bound on it.
41
4. How large should we take n in order to guarantee that the approximation of 1 𝑥 𝑑𝑥, using Simpson’s 1/3 rule is
accurate within 0.0001.
5/20/2021 30