# Error bounds and Riemann sum

Let $$f$$ be continuous on $$\left[0,1\right]$$ and positive and assume also that for every $$\varepsilon>0$$ there exists some $$\overline{n}>0$$ such that for all $$n\geq\overline{n}$$ we have $$\left|\frac{1}{n}\sum_{k=0}^{n-1}f\left(\frac{k}{n}+\frac{1}{2n}\right)-\int_{0}^{1}f\left(u\right)du\right|\leq\frac{\varepsilon}{n}.\tag{1}$$ For a problem I need to prove that $$(1)$$ implies that $$f$$ is constant. How is it possible to prove it? I tried to search bounds for the Riemann sums error but they require regularity hypotheses, like $$f$$ is twice differentiable.

Thank you.

Take $$f(x) = x$$ then we have $$\int_0^1 f(u) du = \frac{1}{2}$$ and \begin{align*}\frac{1}{n}\sum_{k=0}^{n-1}f\left(\frac{k}{n}+\frac{1}{2n}\right) &= \frac{1}{n}\sum_{k=0}^{n-1}\left(\frac{k}{n}+\frac{1}{2n}\right) \\\ &= \frac{1}{n}\left(\sum_{k=0}^{n-1}\frac{k}{n}+\sum_{k=0}^{n-1}\frac{1}{2n}\right) \\\\ &= \frac{1}{n}\left(\frac{n-1}{2} + \frac{1}{2}\right) \\\\ &= \frac{1}{n}\cdot\frac{n}{2} = \frac{1}{2}\end{align*}
$$\left|\frac{1}{n}\sum_{k=0}^{n-1}f\left(\frac{k}{n}+\frac{1}{2n}\right)-\int_{0}^{1}f\left(u\right)du\right| = \left|\frac{1}{2} - \frac{1}{2}\right| = 0\leq\frac{\varepsilon}{n}.\tag{1}$$ for all $$\varepsilon > 0, n\in\mathbb{N}$$
Although $$f(x) = x$$ is not positive on $$[0,1]$$ consider that a shift upwards doesn't change anything (it's added as a constant to the LHS and to the integral as well so it will cancel out).
So each function $$f(x) = x + c$$ with $$c>0$$ contradicts your claim.