def simpsons_rule(f, N, a, b): approximation = 0 for i in range(N): approximation += (b-a)/(6*N) * (f(a + (i)*(b-a)/N) + 4*f(a + (i+1/2)*(b-a)/N) + f(a + (i+1)*(b-a)/N)) return approximation

Simpson's rule gives the exact answer for the integral, no matter how many vertical strips are used for both $x^2$ and $x^3$.