<s>[INST] 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?
 [/INST] 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.
</s>