Simpson's rule, was Re: Integrating a Taylor series?
Subject: Simpson's rule, was Re: Integrating a Taylor series?
From: Richard Fateman
Date: Sun, 12 May 2013 15:25:01 -0700
On 5/12/2013 3:12 PM, Alasdair McAndrew wrote:
> integrate(f(x),x,a,a+2*h) = (h/3)*(f(a)+4*f(a+h)+f(a+2*h)) + E
define
simpson(f,x,a,h) := (h/3)*(f(a)+4*f(a+h)+f(a+2*h));
then notice
ratsimp(
simpson(lambda([x],x^3+r*x^2+s*x+t),x,a,h)-integrate(x^3+r*x^2+s*x+t,x,a,a+2*h));
is zero.
so Simpson's rule is exact for cubic polynomials or lower degree. (Note that
polynomials are Taylor series, effectively)
Change the input to a quartic and the difference is not zero but 4*h^5/15.
That tells you something about the error.