# Summed Newton-Cotes formula for 4 points applied to interval with 5 points

Given the Newton-Cotes formula for 4 points, can I do an integration over an interval where there are arbitrary many points (at least 4 points) given (so e.g. 4,5,6,7,...)? To be concrete, I have the Newton-Cotes formula

$\int_a^b f(x)dx = h[\frac{3}{8}f_0 + \frac{9}{8}f_1 + \frac{9}{8}f_2 + \frac{3}{8}f_3]$

which gives me an approximation of the integral over the interval $[a,b]$, for 4 given function values $f_i=f(x_i), \quad i=0...3$. How we get to these weights is clear (integration of Lagrange basis polynomials).

Now I have some code snippet where one applies the 4-point Newton-Cotes formula to an interval where we have 5 given function values:

$\int_a^b f(x)dx = h[\frac{8}{24}f_0 + \frac{32}{24}f_1 + \frac{16}{24}f_2 + \frac{32}{24}f_3 + \frac{8}{24}f_4]$,

How can we arrive at the weights used for calculation of this integral?

PS: In the code there are more weights given, also for the 4-point formula applied to 6 points and 7+ points in the interval $[a,b]$, but an explanation for the case of 5 points should be enough for understanding.

The formula you quoted becomes more transparent after simplification: $$\int_a^b f(x)dx \approx \frac{h}{3}\left[ f_0 + 4f_1 + 2f_2 + 4f_3 + f_4\right] \tag{1}$$ This is the composite Simpson's rule. Simpson's rule is the $3$-point Newton-Cotes quadrature. One gets its composite form by applying the rule to $(f_0,f_1,f_2)$ and to $(f_2,f_3,f_4)$, then adding the results. Your assumption that $(1)$ was somehow derived from the $4$-point formula is probably incorrect.