Information Technology Reference
In-Depth Information
the endpoints a and b. Hence, y is defined by
y.x/ D f.a/ C f.b/ f.a/
b a
.x a/;
(1.8)
and we have the following trapezoid approximation:
Z b
f.x/dx Z b
a
y.x/dx:
(1.9)
a
Since y is linear, it is easy to compute the integral analytically:
Z b
y.x/dx D Z b
a
f.a/ C
.x a/ dx D .b a/ 1
f.b/ f.a/
b a
2 .f .a/ C f.b//:
a
The trapezoidal rule, using a single trapezoid, is therefore given by
Z b
f.x/dx .b a/ 1
2 .f .a/ C f.b//:
(1.10)
a
Example 1.1. Let
f.x/ D sin.x/;
a D 1;
b D 1:5:
Then, the trapezoidal method gives
Z 1:5
f.x/dx .1:5 1/ 1
2 .sin.1/ C sin.1:5// 0:4597;
1
whereas the exact value is
Z 1:5
f.x/dx D Ĺ’cos.x/ 1:5
1
D .cos.1:5/ cos.1// 0:4696:
1
Thus, the relative error is
0:4696 0:4597
0:4696
100% 2:11%:
1.3.2
Approximating the Integral Using Two Trapezoids
The reasoning behind the trapezoidal method and the examples given above clearly
indicate that, in general, the error is smaller when the length of the interval, i.e.,
b a, is smaller. This observation can be utilized to derive a composite scheme just
 
Search WWH ::




Custom Search