Proof for the formula: $\lim_{n \to \infty} \frac{1}{n}\sum^n_{r=1}f(\frac{r}{n})=\int^1_0f(x)dx$ While studying limits, continuity and differentiability in detail for a competitive examination, I chanced upon this useful formula to solve some limit questions:
$$\lim_{n \to \infty} \frac{1}{n}\sum^n_{r=1}f(\frac{r}{n})=\int^1_0f(x)dx$$
I find it very useful solve to certain limits like: 
$$\lim_{n \to\infty}\frac{1}{n}\sum^n_{r=1}\frac{r}{\sqrt{n^2+r^2}}=\lim_{n \to\infty}\frac{1}{n}\sum^n_{r=1}\frac{r/n}{\sqrt{1+(r/n)^2}}=\int^1_0\frac{x}{\sqrt{1+x^2}}dx=\sqrt2-1 $$ 

However, I wish to


*

*Prove the identity as well, but I don't know how; how can I prove it?

*Examine other cases; for instance, does the below hold true: 


$$\lim_{n \to \infty} \frac{1}{n}\sum^{an}_{r=1}f(\frac{r}{n})=\int^a_0f(x)dx$$
 A: This formula is a result of riemann summations which is used to define integrals.
We know $\sum_{i=1}^{N} f(x_i^*).\Delta_i$ is a riemann sum with $x_i^*$ is in $[x_i, x_{i+1}]$.
They represent finite summations of rectangles (for $1-D$ functions) with width $\Delta_i$, and 
making these widths smaller and smaller we obtain the definition of the integral:
$lim_{N \to \infty} \sum_{i=1}^{N} f(x_i^*).\Delta_i = \int_a^b f(x).dx$
Here the integration bounds are $a = x_0$ and $b = x_N$.
Now getting the question re-write $f(\frac{r}{n}) = f(0 + r*\frac{1}{n})$. Setting $\Delta_r = \frac{1}{n}$ 
and $x_r = x_0 + r*\Delta_r$ with $x_0 = 0$ we have:
$lim_{n \to \infty} \sum_{r=1}^{n} f(0 + r*\frac{1}{n}).\Delta_r = \int_{x_0}^{x_n} f(x).dx$
And we can calculate $x_n = x_0 + n*\frac{1}{n} = 1$.
Thus, if you want your integration upper bound to be $a$, then divide the interval $[0,a]$ into $n$ equal sub-interval,
and represend $x_r$ and $\Delta_r$ accordingly.
A: I think the question probably arises because of the way some textbooks define the symbol $\int_{a}^{b}f(x)\,dx$. One of the crude definitions adopted in many textbooks (aimed at students of 16 years of age) is like this.
Let $f$ be continuous on $[a, b]$ and let $F$ be a function such that $F'(x) = f(x)$ for all $x \in [a, b]$ then we define $$\int_{a}^{b}f(x)\,dx = F(b) - F(a)$$ This is the definition of a definite integral in terms of the anti-derivative (and I suspect OP is using this definition). While this definition is highly useful for beginners in evaluating integrals it is in reality a formula to evaluate the definite integral.
The proper definition of an integral is done in many ways the simplest of which is offered by Riemann and such an integral is called Riemann integral. The proper definition is slightly technical for beginners (of age 16 years or so). Based on the definition given by Riemann it is possible to prove that if $f$ is continuous on $[a, b]$ then there exists an anti-derivative $F$ such that $F'(x) = f(x)$ for all $x \in [a, b]$ and $$F(b) - F(a) = \int_{a}^{b}f(x)\,dx = \lim_{n \to \infty}\frac{b - a}{n}\sum_{r = 1}^{n}f\left(a + \frac{r}{n}(b - a)\right)$$ If we have $a = 0, b = 1$ we get $$F(1) - F(0) = \int_{0}^{1}f(x)\,dx = \lim_{n \to \infty}\frac{1}{n}f\left(\frac{r}{n}\right)$$ The proof however is complicated and is in fact the cornerstone of calculus and the result is often called The Fundamental Theorem of Calculus. If you are interested in the proof do have a look at this blog post.
