Cubic exactness of Simpson's rule (source code)

= Cubic exactness of Simpson's rule
{title2=$S(p)=\int_a^b p(x)\,dx\quad(\deg p\leq3)$}

<Polynomial interpolation> makes <Simpson's rule> exact for every <polynomial> of <polynomial degree> at most two. To understand the extra <polynomial degree>, centre the coordinate at the <midpoint>: $y=x-m$, with endpoints $-h,h$. For any <cubic polynomial> $p$, let $p_2$ be its interpolating <quadratic polynomial>. The <polynomial> $p-p_2$ vanishes at all three <quadrature nodes>, so
$$
p(x)-p_2(x)=A(x-a)(x-m)(x-b)=A y(y^2-h^2),
$$
where $A$ is the coefficient of $x^3$ in $p$. As a <function> of $y$, this is an <odd function>, whose <integral> over the symmetric <interval> $[-h,h]$ is zero. Hence integrating $p_2$ also integrates $p$ exactly. This is the symmetry mechanism in the <nodal-polynomial criterion for quadrature exactness>.

In the worked example, the <polynomial> difference factors as
$$
f(x)-p_2(x)=(x+1)(x-1/2)(x-2)
=y^3-\frac94y.
$$
Its <definite integrals> on $[-1,1/2]$ and $[1/2,2]$ are respectively $81/64$ and $-81/64$. Their cancellation concerns signed <integrals>, rather than pointwise accuracy of <polynomial interpolation>.

The <degree of precision of a quadrature rule> stops at three: on the same <interval>, the <monomial> $x^4$ gives $S(x^4)=69/8$, whereas $\int_{-1}^{2}x^4\,dx=33/5$. Their difference, exact <integral> minus approximation, is $-81/40$.