Error bound for midpoint rule – exact error

calculusnumerical methodsriemann sumupper-lower-bounds

I noticed that I get the exact error, using midpoint rule error bound formula, but with $f''(\frac{b-a}{2})$ for $K$, i.e. :

$E_m \leq $
$\frac{K(b-a)^3} {24n^2}$

$E_{m2} = $ $\frac{f''(\frac{b-a}{2} ) (b-a)^3} {24n^2}$

See my demonstration here (where $f''(x)$ is $i(x)$) :

https://www.desmos.com/calculator/rsnxcn2yf7

$E_{m2}$ is the exact error (line 14).

How to explain why I get exact error that way ?

Of course it must be related to the fact that the second derivative is a line, but I can't find out why.

Best Answer

What you observe happens because your test example is cubic, so that its second derivative is linear. This gives a certain symmetry about the midpoint.

To highlight this, consider that the integral value over $[0,a]$ is the same as the one for the symmetrized function $$f_e(x)=\frac12(f(x)+f(a-x)).$$ For this modified function the second derivative is a constant, the linear contributions of both terms in it are complementary. This constant has the value $$f_e''(x)=f_e''(a/2)=f''(a/2),$$ so that indeed all the error formulas are correct when inserting this value.