interchanging limits in something like a Riemann sum

Formally, switching limits we get

$$\begin{align}\lim_{m \to \infty} \lim_{n \to \infty}\sum_{k=1}^{mn}\frac{n}{n^2+k^2} &= \lim_{m \to \infty}\lim_{n \to \infty}\frac{1}{n}\sum_{k=1}^{mn}\frac{1}{1+(k/n)^2}\\ &= \lim_{m \to \infty}\int_0^m \frac{dx}{1 + x^2} \\ &= \lim_{m \to \infty} \arctan(m)\\ &= \frac{\pi}{2}\end{align}$$

This is not easy to justify. The usual theorems fail since the summand is not monotone and the series is not uniformly convergent. (Otherwise the limit would be $0$).

A rigorous proof would use $$\sum_{k=1}^\infty\frac{n}{n^2+k^2} = \frac i2\sum_{k=1}^\infty\left(\frac1{in-k}+\frac1{in+k}\right) =-\frac{1}{2n}+\frac{\pi i}{2}\cot(\pi in)\\ =-\frac1{2n}+\frac\pi2\coth(\pi n)$$

which implies

$$\lim_{n \to \infty}\sum_{k=1}^\infty\frac{n}{n^2+k^2}= \frac{\pi}{2}$$

since $\coth(x) \to 1$ as $x \to \infty$.


Suppose $f:[0,\infty)\to [0,\infty)$ is decreasing, and $\int_0^\infty f(x)\,dx$ is finite. For $n=1,2,\dots,$ set

$$S_n = \sum_{k=1}^{\infty}f\left(\frac{k}{n}\right)\cdot\frac{1}{n}.$$

Then

$$\lim_{n\to \infty} S_n = \int_0^\infty f(x)\,dx.$$

This follows from the observation that

$$\int_{0}^\infty f(x)\,dx - \frac{f(0)}{n}\le \int_{1/n}^\infty f(x)\,dx \le S_n \le \int_{0}^\infty f(x)\,dx,$$

which you can see from looking at the areas of rectangles in the usual way.

In our problem, $f(x) = \dfrac{1}{1+x^2},$ and the desired limit is $\pi/2.$