I implemented Simpson's rule in Python and tested the error for a cubic polynomial. The error bound of Simpson's rule states that it should be equal to 0, but it is not. Does anybody know why?
def simps(f,a,b,N=50):
if N % 2 == 1:
raise ValueError("N must be an even integer.")
dx = (b-a)/N
x = np.linspace(a,b,N+1)
y = f(x)
S = dx/3 * np.sum(y[0:-1:2] + 4*y[1::2] + y[2::2])
return S
I expected the error to be equal to 0 for each $n$, but it was only equal to 0 for small $n$.