Chapter 07.02 Trapezoidal Rule for Integration-More Examples Computer Engineering

advertisement
Chapter 07.02
Trapezoidal Rule for Integration-More Examples
Computer Engineering
Example 1
Human vision has the remarkable ability to infer 3D shapes from 2D images. The intriguing
question is: can we replicate some of these abilities on a computer? Yes, it can be done and
to do this, integration of vector fields is required. The following integral needs to integrated.
100
I
 f ( x)dx
0
Where,
f x   0, 0  x  30
 9.1688  10 6 x 3  2.7961  10 3 x 2  2.8487  10 1 x  9.6778, 30  x  172
 0, 172  x  200
a) Use single segment Trapezoidal rule to find the value of the integral.
b) Find the true error, E t , for part (a).
c) Find the absolute relative true error for part (a).
Solution
a)
 f (a )  f (b) 
I  (b  a) 
 , where
2

a0
b  100
f x   0, 0  x  30
 9.1688  10 6 x 3  2.7961  10 3 x 2  2.8487  10 1 x  9.6778, 30  x  172
 0, 172  x  200
f 0  0
f 100  9.1688  10 6  100  2.7961  10 3  100  2.8487  10 1  100  9.6778
 0.017000
 0   0.017 
I  100  0

2

 0.85000
3
07.02.1
2
07.02.2
Chapter 07.02
b) The exact value of the above integral is found using Maple for calculating the true error
and relative true error.
100
I
 f ( x)dx
0
 60.793
so the true error is
Et  True Value  Approximate Value
 60.793   0.85000
 61.643
c) The absolute relative true error, t , would then be
t 
True Error
 100 %
True Value
60.793   0.850900 
 100 %
60.793
 101.40 %

Example 2
Human vision has the remarkable ability to infer 3D shapes from 2D images. The intriguing
question is: can we replicate some of these abilities on a computer? Yes, it can be done and
to do this, integration of vector fields is required. The following integral needs to integrated.
100
I
 f ( x)dx
0
where
f x   0, 0  x  30
 9.1688  10 6 x 3  2.7961  10 3 x 2  2.8487  10 1 x  9.6778, 30  x  172
 0, 172  x  200
a) Use 2-segment Trapezoidal rule to find the value of the integral
b) Find the true error, E t , for part (a).
c) Find the absolute relative true error, t ,for part (a).
Solution
a)

ba
 n1

 f (a)  2 f (a  ih )  f (b)
2n 
 i 1


n2
a0
b  100
I
Trapezoidal Rule-More Examples: Computer Engineering
07.02.3
ba
n
100  0

2
 50
h
f x   0, 0  x  30
 9.1688  10 6 x 3  2.7961  10 3 x 2  2.8487  10 1 x  9.6778, 30  x  172
 0, 172  x  200
I

100  0 
 21



f
0

2
 f a  ih   f 100

22 
 i 1


1
100 



f
0

2
f 0  1  50  f 100


4 
i 1

100
 f 0  2 f 50  f 100

4
100
0  21.2784   0.017000

4
 63.497

Since
f 0  0
f 100  9.1688  10 6  100  2.7961  10 3  100  2.8487  10 1  100  9.6778
 0.017000
3
2
f 50  9.1688  10 6  50  2.7961  10 3  50  2.8487  10 1  50  9.6778
 1.2784
3
2
b) The exact value of the above integral is found using Maple for calculating the true error
and relative true error.
100
I
 f ( x)dx
0
 60.793
so the true error is
Et  True Value  Approximate Value
 60.793  63.497
 2.7049
c) The absolute relative true error, t , would then be
t 
True Error
 100 %
True Value
07.02.4
Chapter 07.02
60.793  63.497
 100 %
60.793
 4.4494 %

Table 1 Values obtained using multiple-segment Trapezoidal rule for
f x   0, 0  x  30
 9.1688  10 6 x 3  2.7961  10 3 x 2  2.8487  10 1 x  9.6778, 30  x  172
 0, 172  x  200
n
Value
Et
1
2
3
4
5
6
7
8
0.85000
63.498
111.26
36.062
58.427
77.769
42.528
55.754
61.643
2.7049
50.465
24.731
2.3652
16.977
18.265
5.0388
t %
101.40
4.4494
83.011
40.681
3.8906
27.925
30.044
8.2885
a %
--101.34
42.927
208.52
38.279
24.870
82.866
23.722
Download