#%config InlineBackend.figure_format = 'svg'
from pylab import *
8.3.1Single interval¶
Consider a function and let us approximate this by a polynomial of degree one, say . This can be obtained by interpolation
Then the approximate integral is

Note that this is the area under the straight line curve which has the shape of a (rotated) trapezoid. To study the error in this approximation, we start with the error in interpolation (30)
Then, the error in the integral is
Using integral mean value theorem
Finally, using the properties of divided differences (65)
The error will be small only if is small.
8.3.2Composite trapezoidal rule¶
Divide into equal intervals by the partition
and

Let us use the Trapezoidal rule in each interval
From the previous section, we know that
Hence
where
is the composite Trapezoidal rule. The error is
where
If is continuous, then it attains all values between the minimum and maximum.
Hence, after using , the error is given by
The error goes to zero as since .
8.3.3Asymptotic error estimate¶
We can estimate the error as
provided we can estimate the second derivative. A more useful error estimate can be derived as follows.
Using the error of the composite rule, we can compute the limit
Hence for large
8.3.4Corrected trapezoidal rule¶
Using the asymptotic error estimate
we can define a corrected Trapezoidal rule as