TITLE: Turning infinite sum into integral
QUESTION [8 upvotes]: Could someone explain how one can replace infinite sum with integral?
Examples (or you may use your own, it doesn't matter as I want to understand principles):
$$\frac{1}{n} \sum_{i=1}^{n} \sin \frac{i-1}{n} \pi$$
$$\frac{1}{n} \sum_{i=1}^{n} \sqrt{1 + \frac{i}{n}}$$
I see that $\frac{1}{n}$ denote partition, so my problem is that I don't know how to figure out the function, hence, the integrand.

REPLY [4 votes]: The basic idea is this:
If $f$ is a positive increasing function
then
$f(n)
\le \int_n^{n+1} f(x) dx
\le f(n+1)
$.
Similarly,
if $f$ is a positive decreasing function
then
$f(n)
\ge \int_n^{n+1} f(x) dx
\ge f(n+1)
$.
For increasing $f$,
$\sum_{i=0}^{n-1} f(i)
\le \int_0^{n} f(x) dx
\le \sum_{i=0}^{n-1} f(i+1)
$
or
$\sum_{i=0}^{n} f(i)-f(n)
\le \int_0^{n} f(x) dx
\le \sum_{i=0}^{n} f(i)-f(0)
$
or
$f(0)
\le \sum_{i=0}^{n} f(i)-\int_0^{n} f(x) dx
\le f(n)
$.
For a decreasing function,
the inequalities are reversed.
From this you can show that
for a bounded piecewise monotonic function,
the sum converges to the integral.