We consider the problem of computing approximations to gener
Solution
1-a = x0 < x1 < · · · < xn = b
The composite trapezoidal rule is obtained by applying the trapezoidal rule in each subinterval [xi1, xi ], i = 1, . . . , n, i.e., Z b a f(x)dx = Xn i=1 Z xi xi1 f(x)dx 1 2 Xn i=1 (xi xi1)[f(xi1) + f(xi)],
A particular case is when these points are uniformly spaced, i.e., when all intervals have an equal length. For example, if xi = a + ih, where h = b a n
then Z b a f(x)dx h 2 \" f(a) + 2Xn1 i=1 f(a + ih) + f(b) # = h Xn i=0 00f(a + ih). (6.13) The notation of a sum with two primes, P00, means that we sum over all the terms with the exception of the first and last terms that are being divided by 2. We can also compute the error term as a function of the distance between neighboring points, h. We know from (6.11) that in every subinterval the quadrature error is h 3 12 f 00(x).
Hence, the overall error is obtained by summing over n such terms: Xn i=1 h 3 12 f 00(i) = h 3n 12 \" 1 n Xn i=1 f 00(i) # . Here, we use the notation i to denote an intermediate point that belongs to the i th interval. Let M = 1 n Xn i=1 f 00(i). Clearly min x[a,b] f 00(x) 6 M 6 max x[a,b] f 00(x) If we assume that f 00(x) is continuous in [a, b] (which we anyhow do in order for the interpolation error formula to be valid) then there exists a point [a, b] such that f 00() = M. Hence (recalling that (b a)/n = h, we have E = (b a)h 2 12 f 00(), [a, b]. (6.14) This means that the composite trapezoidal rule is second-order accurate.
Then use this function as follows:
