TITLE: Error in midpoint approximation to the integral
QUESTION [2 upvotes]: Suppose $f''(x) \geq 0$, I want to check that
$$ \sum_{j=1}^k (x_j - x_{j-1}) f (c_j) \leq \int\limits_a^b f(x) dx
 $$
where $x_1,x_2,...,x_k$ are nodes of $[a,b]$ sothat $x_j = a + j
 (b-a)/k $ where $j=0,..k$ and $c_j = \frac{x_{j-1} + x_k }{2} $.

Ideas
Maybe we can try to prove in a subinterval $[x_{j-1},x_j]$ wlog and then adding up will give result, so we want show that
$$ \int_{x_{j-1}}^{x_j} f dx - (x_j-x_{j-1}) f(c_j) \geq 0 $$
how do I make the $f''(x)$ appear on the above so that I can apply the hypothesis? I think integration by parts may be the tool, but I dont see how to make it work in this situation

REPLY [3 votes]: Consider an interval $[x_{j-1},x_j]$ and define interval length $h = x_j-x_{j-1}$ and midpoint $c_j = (x_{j-1}+x_j)/2.$ Note that $x_j-c_j = c_j-x_{j-1} = (x_j-x_{j-1})/2 = h/2.$ 
The midpoint approximation error is
$$E_M = \int_{x_{j-1}}^{x_j} f(x) \, dx - hf(c_j)  =  \int_{x_{j-1}}^{x_j} [f(x) - f(c_j)] \, dx.$$
Using a second-order Taylor approximation,
$$f(x) = f(c_j) + f'(c_j)(x-c_j) + \frac{1}{2} f''(\xi_x)(x-c_j)^2, $$
we get
$$E_M = \int_{x_{j-1}}^{x_j} f'(c_j)(x-c_j) \, dx + \frac{1}{2}\int_{x_{j-1}}^{x_j} f''(\xi_x)(x-c)^2 \, dx \geqslant 0, $$
since the second integral on the RHS is nonnegative when $f'' \geqslant 0$  and the first integral vanishes, i.e.,
$$\int_{x_{j-1}}^{x_j} f'(c_j)(x-c_j) \, dx = f'(c_j) \frac{(x_j - c_j)^2 - (x_{j-1} - c_j)^2}{2} \\ = f'(c_j) \frac{(h/2)^2 - (-h/2)^2}{2} = 0$$
{"set_name": "stack_exchange", "score": 2, "question_id": 3156316}