# How to approximate an integral using the Composite Trapezoid Rule

I'm trying to estimate the value of the following integral on the interval $[0,1]$

$$I = \int_0^1 \frac{1}{1+x} dx$$

So, using the composite trapezoid rule (and with $n=4$, ie I'm only using the first 4 $x_i$ to do the approximation), I get the following expression:

$$I = \frac{67}{60} - \frac{1}{96} (2(1+\xi_1)^{-3} + 2(1+\xi_2)^{-3} + 2(1+\xi_3)^{-3} + 2(1+\xi_4)^{-3})$$

But I'm lost when it comes to calculating the error and finding a value for $\xi$. What's the general way of finding the error like this?

Formula I'm using

$$I = \frac{h}{2} \sum_{i=1}^n [f(x_{i-1}) + f(x_i)] - \frac{h^3}{12} \sum_{i=1}^n f^{''}(\xi_i)$$

• Ah, I see. Every time I've ever seen the term "composite trapezoid rule" it has referred to approximating the area under $y=f(x)$ using several (as opposed to one) trapezoids -- that is the first part of your formula not including the summation with fourth order derivatives. – Bill Cook Mar 24 '12 at 21:44
• Thanks for including the formula you are using. I'm still baffled as to where it comes from. It looks like an error term is being removed for each subinterval. But the 4th order derivatives don't jive with the trapezoid rule (seems like they should be 2nd derivatives). Where does this come from? – Bill Cook Mar 24 '12 at 21:49
• Ah yes, my bad :) They are second derivatives. – n0pe Mar 24 '12 at 21:58
• Ok. So your formula is: for each subinterval, pair the trapezoid approximation with its error term and then sum up. From my experience, one uses such formulas to approximate or bound the error not to "find the error". If you are looking to bound the error, you can find a bound for $f''(\xi_i)$ restricted to the i-th subinterval (or to simplify life you could use a single bound for the entire interval). Then the second summation (with your bound(s) subbed for the second derivatives) will give you a bound for the error. – Bill Cook Mar 24 '12 at 22:20

You have to find the upper bound of this error sum. Therefore you should take the maximum value of f'' on each subinterval (according to your formula). With $f(x)=\frac{1}{1+x}$, we got: $f''(x)=\frac{2}{(1+x)^3}$. The largest value of this function in the interval $[x_0,x_1]$ is $f''(x_0)$ , since $\ f''(x) \$ is a decreasing function in [0,1]. For n=4, we got the intervals [0,0.25], [0.25,0.5] [0.5,0.75] [0.75,1] with corresponding maximum values for $f''(x)$ ,
$\ f''(0)=2, \ f''(0.25)=1.024, \ f''(0.5)=0.592 \ and \ f''(0.75)=0.373$. So an upper bound for your problem would be $\frac{h^3}{12} \sum_{i=1}^n |f^{''}(\xi_i)|=\frac{0.25^3}{12}(2+1.024+0.592+0.373)=0.005194$