[Math] How to find minimum n for Composite Trapezoidal rule

integrationnumerical methods

I'm taking a course on numerical methods to be able to program math, it's part of the game option of my compsci bachelors.This is part of one of the questions:

Given the integral: $\int_6^{12} (9x^3 – x^4)dx$

A. Using the Composite Trapezoidal Rule, what is the min. n required to have an accuracy of six decimal places (TOL. $\le 10^{-6}$), in the approximation of the given integral. n must be solved theoretically.

B. just use the composite trapezoidal rule with said n, which is easy since I programmed the rule (code here: http://pastebin.com/QzRdijrh)

C. Same as A but for Composite Simpson's rule.

D. Same as B but for Composite Simpson's rule (code here: http://pastebin.com/V9DYdRXU)

So the problem I'm having is I can't remember how to find minimum n, I know for Bisection Algorithm you make $2^n \le (b-a)/TOL$ But I forgot how to apply that to other rules…

Best Answer

The error term of the composite trapezoidal rule is $\frac {(b-a)^3}{12n^2}f''(\xi)$ so you need to evaluate the second derivative of your function, find its maximum and plug everything in. You will get something like error $\lt \frac a{n^2}$. Then you choose $n$ to get the error lower than $10^{-6}$. For the composite Simpson's rule, the approach is the same, but you have a different expression for the error.