Evaluate the limit of a sequence by Riemann sums and mean value theorem Calculate:
$\displaystyle \lim_{n \rightarrow \infty} \left( \frac{n \pi}{4} - \left( \frac{n^2}{n^2+1^2} + \frac{n^2}{n^2+2^2} + \cdots \frac{n^2}{n^2+n^2} \right) \right)$.
I solved it by taking into account that $\displaystyle \int_0^{1} \frac{1}{1+x^2} \mathrm{d}x = \frac{\pi}{4}$ and let the given sequence be:
$a_n= \displaystyle \frac{n \pi}{4} - \left( \frac{n^2}{n^2+1^2} + \frac{n^2}{n^2+2^2} + \cdots + \frac{n^2}{n^2+n^2} \right)$
Let $f(x) = \frac{1}{1+x^2}$, then:
$a_n = \displaystyle \frac{n \pi}{4} - \sum_{i=1}^n \frac{1}{1+\left( \frac{i}{n} \right)^2} = n \int_0^{1} f(x) \mathrm{d}x - \sum_{i=1}^n f\left( \frac{i}{n} \right) = n \sum_{i=1}^n \int_{\frac{i-1}{n}}^{\frac{i}{n}} f(x) \mathrm{d}x - n \sum_{i=1}^n \int_{\frac{i-1}{n}}^{\frac{i}{n}} f\left( \frac{i}{n} \right) \mathrm{d}x = n \sum_{i=1}^n \int_{\frac{i-1}{n}}^{\frac{i}{n}} \left( f(x)- f\left( \frac{i}{n} \right) \right) \mathrm{d}x$
Using Mean Value Theorem and doing a lot of calculations, I finally get that the limit is $\displaystyle \frac{1}{4}$.
Is it correct? Is there an easier method to solve the problem?
 A: Using
$$ \sum_{k=1}^{n} \frac{1}{k^2 +n^2} = \frac{i}{2 n} \, \left( \psi(1 - i n) - \psi(1 + i n) + \psi(1 + (1+i) \, n) - \psi(1 + (1-i) \, n) \right), $$
where $\psi(x)$ is the digamma function, and
$$ \psi(x) \approx \ln(x) + \frac{1}{2 x} - \sum_{j=1}^{\infty} \frac{B_{2j}}{2 \, j \, x^{2 j}}, $$
where $B_{n}$ are the Bernoulli numbers, then
$$ \sum_{k=1}^{n} \frac{n^2}{k^2 + n^2} \approx \frac{n \, \pi}{4} - \frac{1}{4} - \sum_{j=1}^{\infty} \frac{B_{2 j}}{2^{j+1} \, j \, n^{2 j -1}} \, \sin\left(\frac{j \pi}{2}\right). $$
Now the limit in question takes the form
$$ \lim_{n \to \infty} \left( \frac{n \pi}{4} - \sum_{k=1}^{n} \frac{n^2}{k^2 + n^2} \right) = \lim_{n \to \infty} \left( \frac{1}{4} + \sum_{j=1}^{\infty} \frac{b_{j}}{n^{2 j -1}} \right) = \frac{1}{4}. $$
A: Let us use the following
Lemma: If $f\in C^1[0,1]$ then we have $$\lim_{n\to\infty} \sum_{k=1}^nf(k/n)-n\int_0^1 f(x) \, dx=\frac{f(1)-f(0)}{2}$$ Using $f(x) =1/(1+x^2)$ we get your desired limit as $1/4$. The lemma is proved using mean value theorem and matches your approach. An extension of the lemma is available here.
