Problem statement: Suppose $f$ is continuously differentiable on $[0,1]$, and that $\sup_{x \in [0,1]}|f'(x)|\le M< \infty$. Show that $$\big|\int_0^1 f(x) - \sum^n_{i=1}f(i/n)\cdot 1/n\big| \le M/n.$$
My attempt at a solution: To start with, I was trying to get the derivative involved, somewhere, so I wrote $$f(i/n) = f(0) + \int^{i/n}_0 f'(x)$$ which gives $$\big|\int_0^1 f(x) - \sum^n_{i=1}f(i/n)\cdot 1/n\big| = \big|\int_0^1 f(x) - \sum^n_{i=1}\int_0^{i/n}f'(x)\cdot 1/n\big|.$$ I was hoping then to bound the integral using the bound on $f'$. But, there's that pesky minus sign in front of the sum that I'm working with, and even if there weren't, the bound doesn't seem to result in anything useful there, since we end up with $$1/n \cdot \sum^n_{i=1}\int_0^{i/n}f'(x) \le f(0) + M/n \sum^n_{i=1}i,$$ which doesn't seem useful to me. I would really appreciate some hints as to the right way to attack this problem!
I would start instead by writing $$\int_0^1 f(x) - \sum_{i=1}^n f(i/n)\cdot (1/n) \\ = \sum_{i=1}^n \int_{(i-1)/n}^{i/n}f(x) - f(i/n) \,dx.$$
Usually these problems with the $f(i/n)$ involved are solved by a clever interchange of integrals and summation.