The magnitude of the difference between the integral and the Riemann sums for continuous functions How do I prove that $$\lim_{n\to\infty}n\left[\int_{0}^{1}f(x){d}x - \frac{1}{n}\sum_ {i=0}^{n}f\left(\frac{i}{n}\right)\right] = -\frac{1}{2}$$ for any $ f(x)$ in $C^0([0,1])$ such that $f(0)=0$ and $f(1)=1$ ?

Suggested steps:


*

*Set $f(x)=x+g(x)$;

*Prove that for any $g\in C^0([0,1])$ such that $g(0)=g(1)=0$, the above limit is zero$\ldots$

*$\ldots$ by approximating $g$, uniformly over $[0,1]$, with a trigonometric polynomial of the form
$$ \tilde{g}(x)=\sum_{m=1}^{M} c_m \sin(\pi m x) $$

*For any function like $\sin(\pi m x)$, both the integral and the sum are simple to compute.

 A: For the more restricted case, $f \in C^1([0,1])$ this can be shown as follows.
Consider
$$x_n = n\left(\int_0^1f(x) \, dx - \frac{1}{n}\sum_{i=1}^nf(i/n)\right).$$
Applying the mean value theorem, 
$$\begin{align}x_n &= n\sum_{i=1}^n\int_{(i-1)/n}^{i/n}[f(x) - f(i/n)] \, dx \\ &= n\sum_{i=1}^n\int_{(i-1)/n}^{i/n}f'(\xi_{i,n})(x - i/n) \, dx \end{align}.$$
Define
$$M_{i,n} = \sup \{f'(x): (i-1)/n \leqslant x \leqslant i/n \}, \\ m_{i,n} = \sup \{f'(x): (i-1)/n \leqslant x \leqslant i/n \}. $$
Hence,
$$n \sum_{i=1}^nm_{i,n}\int_{(i-1)/n}^{i/n}(x - i/n) \, dx  \leqslant x_n \leqslant n \sum_{i=1}^nM_{i,n}\int_{(i-1)/n}^{i/n}(x - i/n) \, dx.  $$
Note that
$$\int_{(i-1)/n}^{i/n}(x - i/n) \, dx  = -\frac{1}{2}\left(\frac{i}{n} - \frac{i-1}{n} \right)^2 = - \frac{1}{2n^2},$$
and
$$-\frac{1}{2n}\sum_{i=1}^nm_{i,n} \leqslant x_n \leqslant -\frac{1}{2n}\sum_{i=1}^nM_{i,n}. $$
Now take the limit as $n \to \infty$, noticing the upper and lower Riemann sums above, to obtain
$$\lim_{n \to \infty} x_n = - \frac{1}{2} \int_0^1f'(x) \, dx = \frac{f(0)-f(1)}{2}= -\frac{1}{2}.$$
This link suggests it is not generally true for $f \in C^0([0,1]):$
Speed of convergence of Riemann sums
