Trapezoidal Rule of Integration Civil Engineering Majors Authors: Autar Kaw, Charlie Barker
Download ReportTranscript Trapezoidal Rule of Integration Civil Engineering Majors Authors: Autar Kaw, Charlie Barker
Trapezoidal Rule of Integration
4/27/2020 Civil Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM Undergraduates http://numericalmethods.eng.usf.edu
1
Trapezoidal Rule of Integration
http://numericalmethods.eng.usf.edu
3
What is Integration
b a
f ( x ) dx
Integration:
The process of measuring the area under a function plotted on a graph.
y f(x) I
a
b f ( x ) dx
Where: f(x) is the integrand a= lower limit of integration b= upper limit of integration
a b
http://numericalmethods.eng.usf.edu
x
4
Basis of Trapezoidal Rule
Trapezoidal Rule is based on the Newton-Cotes Formula that states if one can approximate the integrand as an n th order polynomial…
I
a
b f ( x ) dx
where
f ( x )
f n ( x )
and
f n ( x )
a
0
a
1
x
...
a n
1
x n
1
a n x n
http://numericalmethods.eng.usf.edu
5
Basis of Trapezoidal Rule
Then the integral of that function is approximated by the integral of that n th order polynomial.
a
b f ( x )
a
b f n ( x )
Trapezoidal Rule assumes n=1, that is, the area under the linear polynomial,
b a f ( x ) dx
( b
a )
f ( a )
2
f ( b )
http://numericalmethods.eng.usf.edu
6
Derivation of the Trapezoidal Rule
http://numericalmethods.eng.usf.edu
Method Derived From Geometry
b a
f
1
( x ) dx
7 The area under the curve is a trapezoid. The integral
b a
f
(
x
)
dx
1 2
( Sum of Area of parallel trapezoid sides )( height ) y
1 2
f ( b )
f ( a )
( b
a )
( b
a )
f ( a )
2
f ( b )
f(x) f 1 (x) a b
Figure 2: Geometric Representation
http://numericalmethods.eng.usf.edu
x
Example 1
The concentration of benzene at a critical location is given by
c
1 .
75
erfc
0 .
6560
e
32 .
73
erfc
5 .
758 where
erfc
x
e
So in the above formula
z
2
dz erfc
0 .
6560 0 .
6560
e
z
2
dz e
approximate
z
2
erfc
0 .
6560 0 .
6560 5
e
z z
2
dz
a) Use single segment Trapezoidal rule to find the value of erfc (0.6560). b) Find the true error, for part (a).
c) Find the absolute relative true error, for part (a).
a)
Solution
I
( b
a )
f ( a )
2
f ( b )
a
5
b
0 .
6560
f
(
z
)
e
z
2
f
( 5 )
e
5 2 1 .
3888 10 11
f
( 0 .
6560 )
e
0 .
6560 2 0 .
65029
Solution (cont)
a)
I
0 .
6560 5 1 .
3888 10 11 2 0 .
65029 1 .
4124 b) The exact value of the above integral cannot be found. We assume the value obtained by adaptive numerical integration using Maple as the exact value for calculating the true error and relative true error.
erfc
0 .
6560 0 .
6560
e
z
2
dz
5 0 .
31333
b) c)
E t
True
Solution (cont)
Value
Approximat e Value
0 .
31333 ( 1 .
4124 ) 1 .
0991 The absolute relative true error ,
t
, would be
t
True Error 100 True Value 0 .
31333 1 .
4124 0 .
31333 100 350 .
79 %
Multiple Segment Trapezoidal Rule
12 In Example 1, the true error using single segment trapezoidal rule was large. We can divide the interval [8,30] into [8,19] and [19,30] intervals and apply Trapezoidal rule over each segment.
f ( t )
2000
ln
140000 140000 2100
t
9
.
8
t
30 8
f ( t ) dt
19 8
f ( t ) dt
30 19
f ( t ) dt
(
19 8
)
f (
8
)
2
f (
19
)
(
30 19
)
f (
19
)
2
f (
30
)
http://numericalmethods.eng.usf.edu
13
Multiple Segment Trapezoidal Rule
Hence: With
f (
8
)
177
.
27
m / s f (
30
)
901
.
67
m / s f (
19
)
484
.
75
m / s
8 30
f
(
t
)
dt
( 19 8 ) 177 .
27 2 484 .
75 ( 30 19 ) 484 .
75 2 901 .
67 11266
m
http://numericalmethods.eng.usf.edu
14
Multiple Segment Trapezoidal Rule
The true error is:
E t
11061 11266 205
m
The true error now is reduced from -807 m to -205 m. Extending this procedure to divide the interval into equal segments to apply the Trapezoidal rule; the sum of the results obtained for each segment is the approximate value of the integral.
http://numericalmethods.eng.usf.edu
15
Multiple Segment Trapezoidal Rule
Divide into equal segments as shown in Figure 4. Then the width of each segment is:
h
b
n
The integral I is:
a y f(x) I
a
b f ( x ) dx a a
b
a
4
a
2
b
a
4
a
3
b
a
4
b
Figure 4: Multiple (n=4) Segment Trapezoidal Rule
x
16
Multiple Segment Trapezoidal Rule
b a
The integral I can be broken into h integrals as:
f ( x ) dx
a a
h f ( x ) dx
a a
2
h f h ( x ) dx
...
a
( a
( n n
1 2
f ) h ( ) h x ) dx
a
( n
b
1
f ) h ( x ) dx
Applying Trapezoidal rule on each segment gives:
b a
f ( x ) dx
b
a
2
n
f ( a )
2
i n
1 1
f ( a
ih )
f ( b )
http://numericalmethods.eng.usf.edu
Example 2
The concentration of benzene at a critical location is given by
c
1 .
75
erfc
0 .
6560
e
32 .
73
erfc
5 .
758 where
erfc
x
e
z
2
dz
So in the above formula
erfc
0 .
6560 0 .
6560
e
z
2
dz e
z
erfc
0 .
6560 0 .
6560
e z
2
dz
a) Use two-segment Trapezoidal rule to find the value of erfc(0.6560). 5 b) Find the true error, for part (a).
c) Find the absolute relative true error, for part (a).
Solution
a) The solution using 2-segment Trapezoidal rule is
I
b
a
2
n
f
(
a
) 2
i
1
n
1
f
(
a
ih
)
f
(
b
)
n
2
a
5
b
0 .
6560
h
b
a
0 .
n
6560 2 2 .
172 5
Solution (cont)
Then:
I
0 .
6560 2 5
f
2
i
2 1 1
f
a
ih
f
0 .
6560 4 .
344
f
4 4 .
344 4 0 .
70695 1 .
3888 2
f
2 .
828 10 11
f
0 .
6560 2 0 .
00033627 0 .
65029
Solution (cont)
b) The exact value of the above integral cannot be found. We assume the value obtained by adaptive numerical integration using Maple as the exact value for calculating the true error and relative true error.
erfc
0 .
6560 0 .
6560 5
e
z
2
dz
so the true error is 0 .
31333
E t
True Value
0 .
31333
Approximat e
0 .
70695 0 .
39362
Value
Solution (cont)
c) The absolute relative true error ,
t
, would be
t
True Error 100 True Value 0 .
31333 0 .
70695 0 .
31333 125 .
63 % 100
Table 1 gives the values obtained using multiple segment Trapezoidal rule for:
erfc
0 .
6560 0 .
6560
e
5
z
2
dz
Solution (cont)
n
1 2 3 4 5 6 7 8
Value
−1.4124
−0.70695
−0.48812
−0.40571
−0.37028
−0.35212
−0.34151
−0.33475
E t
1.0991
0.39362
0.17479
0.092379
0.056957
0.038791
0.028182
0.021426
t
% 350.79
125.63
55.787
29.483
18.178
12.380
8.9946
6.8383
a
% -- 99.793
44.829
20.314
9.5662
5.1591
3.1063
2.0183
Table 1: Multiple Segment Trapezoidal Rule Values
Example 3
.
Use Multiple Segment Trapezoidal Rule to find the area under the curve
f ( x )
300 1
x e x
from
x
0 to
x
10 Using two segments, we get
h
10 0 2 5 and
f (
0
)
300
(
0
)
1
e
0 0
f (
5
)
300
(
5
)
10
.
039 1
e
5
f (
10
)
300
(
10
)
0
.
136 1
e
10
Solution
Then:
I
b
2
a n
f ( a )
2
n i
1 1
f ( a
ih )
f ( b )
10 0 2
(
2
)
f (
0
)
2
i
2 1 1
f (
0 5
)
f (
10
)
10 4
f (
0
)
2
f (
5
)
f (
10
)
10 0 4 2
(
10
.
039
)
0
.
136 50
.
535
Solution (cont)
So what is the true value of this integral? 10 0 1 300
x
e x dx
246
.
59 Making the absolute relative true error:
t
246
.
59 50
.
535 100
%
246
.
59 79
.
506
%
Solution (cont)
Table 2: Values obtained using Multiple Segment Trapezoidal Rule for: 10 0 1 300
e x x dx
n 1 2 4 8 16 32 64 Approximate Value 0.681
50.535
170.61
227.04
241.70
245.37
246.28
E t
245.91
196.05
75.978
19.546
4.887
1.222
0.305
t
99.724% 79.505% 30.812% 7.927% 1.982% 0.495% 0.124%
Error in Multiple Segment Trapezoidal Rule
The true error for a single segment Trapezoidal rule is given by:
E t
( b
a )
3 12
f " (
), a
b
where is some point in
, b
What is the error, then in the multiple segment Trapezoidal rule? It will be simply the sum of the errors from each segment, where the error in each segment is that of the single segment Trapezoidal rule. 27 The error in each segment is
E
1
( a
h )
a
3 12
f " (
1
), a
1
a
h
h
3 12
f " (
1
)
http://numericalmethods.eng.usf.edu
Error in Multiple Segment Trapezoidal Rule
28 Similarly:
E i
( a
ih )
( a
( i
1
) h )
3 12
f " (
i ),
h
3 12
f " (
i )
It then follows that:
a
( i
1
) h
i
a
ih E n
b
a
( n
12 1
) h
3
f " (
n ), a
( n
1
) h
n
b
h
3 12
f " (
n )
http://numericalmethods.eng.usf.edu
Error in Multiple Segment Trapezoidal Rule
29 Hence the total error in multiple segment Trapezoidal rule is
E t
i n
1
E i
h
3 12
i n
1
f " (
i )
( b
a
12
n
2
)
3
i n
1
f " n (
i )
The term
i n
1
f " (
i n )
is an approximate average value of the
f " ( x ), a
x
b
Hence:
E t
( b
a
12
n
2
)
3
i n
1
f " (
i ) n
http://numericalmethods.eng.usf.edu
30
Error in Multiple Segment Trapezoidal Rule
Below is the table for the integral 30 8 2000
ln
140000 140000 2100
t
9
.
8
t
dt
as a function of the number of segments. You can visualize that as the number of segments are doubled, the true error gets approximately quartered.
n
2 4 8 16
Value
11266 11113 11074 11065
E t
-205 -51.5
-12.9
-3.22
t %
1.854
0.4655
0.1165
0.02913
a %
5.343
0.3594
0.03560
0.00401
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/trapezoidal _rule.html
THE END
http://numericalmethods.eng.usf.edu