Convergence of Riemann sums for improper integrals I was considering whether or not the limit of Riemann sums converges to the value of an improper integral on a bounded interval.  This appears to be true in some cases when the sum avoids points where the function is not defined.
For example, the right-hand Riemann sum for $1/\sqrt{x}$ converges
$$\lim \frac1{n}\sum_{i = 1}^n  \sqrt{n/i} = \int_0^1 \frac{dx}{\sqrt{x}}.$$
This does not work, however, for the function $\sin(1/x)/x$ even though the improper integral is finite.
I’m sure this has something to do with the function being monotone, but I am not able to find a proof.
 A: We can prove that sequences of right- or left-hand Riemann sums will converge for a monotone function with a convergent improper integral. 
Suppose WLOG $f:(0,1] \to \mathbb{R}$ is nonnegative and decreasing. Suppose further that there is a singularity at $x =0$ but $f$ is Riemann integrable on $[c,1]$ for $c > 0$ and the improper integral is convergent:
$$\lim_{c \to 0+}\int_c^1 f(x) \, dx = \int_0^1 f(x) \, dx.$$
Take a uniform partition $P_n = (0,1/n, 2/n, \ldots, (n-1)/n,1).$ Since $f$ is decreasing we have 
$$\frac1{n}f\left(\frac{k}{n}\right) \geqslant \int_{k/n}^{(k+1)/n}f(x) \, dx \geqslant \frac1{n}f\left(\frac{k+1}{n}\right), $$
and summing over $k = 1,2, \ldots, n-1$
$$\frac1{n}\sum_{k=1}^{n-1}f\left(\frac{k}{n}\right) \geqslant \int_{1/n}^{1}f(x) \, dx \geqslant \frac1{n}\sum_{k=2}^nf\left(\frac{k}{n}\right). $$
Hence,
$$ \int_{1/n}^{1}f(x) \, dx +\frac{1}{n}f(1) \leqslant \frac1{n}\sum_{k=1}^{n}f\left(\frac{k}{n}\right) \leqslant \int_{1/n}^{1}f(x) \, dx+ \frac{1}{n}f \left(\frac{1}{n} \right).$$
Note that as $n \to \infty$ we have $f(1) /n \to 0$ and since the improper integral is convergent,
$$\lim_{n \to \infty} \int_{1/n}^{1}f(x) \, dx = \int_0^1 f(x) \, dx, \\ \lim_{n \to \infty}\frac{1}{n}f \left(\frac{1}{n} \right) = 0.$$
The second limit follows from monotonicity and the Cauchy criterion which implies that for any $\epsilon > 0$ and all $n$ sufficiently large
$$0 \leqslant \frac{1}{n}f \left(\frac{1}{n} \right) \leqslant 2\int_{1/2n}^{1/n}f(x) \, dx < \epsilon.$$
By the squeeze theorem we have
$$\lim_{n \to \infty}\frac1{n}\sum_{k=1}^nf\left(\frac{k}{n}\right)  = \int_0^1 f(x) \, dx.$$
This proof can be generalized for non-uniform partitions. For oscillatory functions like $g(x) = \sin(1/x)/x$, the failure of the sequence of right-hand Riemann sums to converge is, non-monotonicity notwithstanding, related to non-convergence as $n \to \infty$ of 
$$ \frac{1}{n}g \left(\frac{1}{n} \right) = \sin n. $$
This particular case appears to have been covered nicely by @Daniel Fischer in
Improper integrals and right-hand Riemann sums
