Given a set of datapoints, I was thinking about when to use which (closed) Newton-Cotes formula?
I developed a decision tree which would go like this:
- Are the given datapoints equally spaced? No --> Composite trapezoidal rule
- Yes! Is the number of split-intervals multiple of 4? (ex. 4,8,12,16,..) Yes! ---> Composite Boole's Rule
- No! Is the number of split-intervals multiple of 3? (ex. 3,9,12,15,..) Yes! ---> Composite Simpson's 3/8
- No! Is the number of split-intervals even? (ex. 2,4,6,8,10,..) Yes! ---> Composite Simpson's 1/8
- No! Use composite trapezoidal!
Is it right? If not please correct me. And it would be really helpful, if someone could provide me with the formulas of the composite Simpson's 1/8 and composite Simpson's 3/8, as I am not sure I have the right ones.
And last question: for 3 split-intervals, is it better to use composite trapezoidal rule or 1 simpson's 3/8 rule?
Thank you in advance!
Assuming that you are restricted to Newton-Cotes, if your data points aren't equally spaced, all you've got is the trapezoidal rule, crappy though it is. There are better things you can attempt, but my guess is that they aren't allowed for you at this point. Cases $2$ and $4$ could be consolidated to the plan to use $n$ steps of Romberg's rule if the number of split-intervals is a multiple of $2^n$. Simpson's $1/3$ rule is the result of one step of Romberg's rule and Boole's rule is two steps. Romberg's rule is easier to remember than Boole's rule in that you just take $4^n$ times the result obtained at step $n-1$ for the current interval width minus $1$ times the result obtained at step $n-1$ for double the current width and divide by $4^n-1$ to get the step $n$ result. Step $0$ is the trapezoidal rule. Romberg's rule gives you some kind of idea about how accurate your results are because they should start agreeing with each other as the steps progress. Also it gets high-order results without the error explosion that occurs if you try to do the same via Newton-Cotes.
If the split-intervals are equally spaced but there is an odd number of them, the normal thing to do is to apply Simpson's $3/8$ rule to the first $3$ split-intervals and then apply Simpson's composite $1/3$ rule to the rest of them. This way you don't have to fall back on the horrible trapezoidal rule just because the number of split-intervals is odd