Sharp one-panel trapezoidal error bound (source code)

= Sharp one-panel trapezoidal error bound
{title2=$|I(f)-T(f)|\leq\dfrac{(b-a)^3}{12}\max_{[a,b]}|f''|$}

For $f\in C^2[a,b]$ with $a<b$, the <trapezoidal rule> satisfies the displayed bound, and the constant $1/12$ is best possible. The <polynomial interpolation error> for the endpoint <linear interpolant> satisfies $|f(x)-p(x)|\leq\tfrac12 M(x-a)(b-x)$, where $M=\max|f''|$. Integrating this inequality and using the <triangle inequality for an integral> proves the bound because $\int_a^b(x-a)(b-x)\,dx=(b-a)^3/6$. Equality holds for $f(x)=(x-a)^2$: the exact <integral> is $(b-a)^3/3$, its <trapezoidal rule> estimate is $(b-a)^3/2$, and $M=2$.