Limit of the sequence $\left(\sum_{k=0}^n f\!\left(\frac{k}{n^2}\right)\right)_n$. Following this post on Meta, I am going to regularly ask questions from competitive mathematics exams, on a variety of topics; and provide a solution a few days later. The goal is not only to list interesting (I hope) exercises for the sake of self-study, but also to obtain (again, hopefully) a variety of techniques to solve them.

Let $f\colon\mathbb{R}\to\mathbb{R}$ be differentiable at $0$, and such that $f(0)=0$. Letting $s_n\stackrel{\rm def}{=} \sum_{k=1}^n f\!\left(\frac{k}{n^2}\right)$ for $n\geq 1$, find the limit of the sequence $(s_n)_{n\geq 1}$.

Reference: Exercise 4.26 in Exercices de mathématiques: oraux X-ENS (Analyse I), by Francinou, Gianella, and Nicolas (2014) ISBN 978-2842252137.
 A: Using the definition of the derivative + using riemann sum to rewrite the sum as an integral yields $\frac{1}{2}f'(0)$.
A: Define $\phi : \Bbb{R} \to \Bbb{R}$ by
$$ \phi(x) = \begin{cases}
\dfrac{f(x)}{x}, & x \neq 0 \\
f'(0), & x = 0
\end{cases} $$
Then $\phi$ is continuous at $0$ and $f(x) = x\phi(x)$. Now your sum reduces to
$$ s_n = \sum_{k=0}^{n} \frac{k}{n^2}\phi\left(\frac{k}{n^2}\right), $$
from which we find that
$$ \Big( \inf_{[0,1/n]}\phi \Big) \sum_{k=0}^{n} \frac{k}{n^2} \leq s_n \leq \Big( \sup_{[0,1/n]}\phi \Big) \sum_{k=0}^{n} \frac{k}{n^2}. $$
Taking $n \to \infty$, by the squeezing theorem we get
$$ s_n \to \frac{1}{2}\phi(0) = \frac{1}{2}f'(0). $$
A: An answer (inspired from that of the book cited as reference in the question).


*

*First, let us try with a few simple examples:


*

*Identity $f\colon x\mapsto x$
$$
\sum_{k=0}^n f\left(\frac{k}{n^2}\right) = \frac{1}{n}\sum_{k=0}^n \frac{k}{n} \xrightarrow[n\to\infty]{} \int_0^1 xdx = \frac{1}{2}
$$

*Square $f\colon x\mapsto x^2$
$$
\sum_{k=0}^n f\left(\frac{k}{n^2}\right) = \frac{1}{n^2}\sum_{k=0}^n \frac{k^2}{n^2} \sim_{n\to\infty} \frac{1}{n}\int_0^1 x^2dx \xrightarrow[n\to\infty]{} 0
$$
Now, not sure how helpful this is if one does not already have an intuition for the answer, but one can also try the above more generally with a power series $f(x)=\sum_{k=1}^\infty a_k x^k$  satisfying $f(0)=0$ with non-zero radius of convergence to get $\frac{a_1}{2}$. At that point, either one recognizes a general trend ("it should obviously converge to $\frac{f'(0)}{2}$"), or, well, try to continue nonetheless. 


*

*One natural idea would be to write
$f(x) = f'(0)x + o(x)$ on a neighborhood of $0$, and then compute
$$
\sum_{k=0}^n f\left(\frac{k}{n^2}\right) = f'(0)\cdot \frac{1}{n}\sum_{k=0}^n \frac{k}{n} + \sum_{k=0}^n o\left(\frac{k}{n^2}\right)
= f'(0)\cdot \frac{1}{n}\sum_{k=0}^n \frac{k}{n} + o\left(1\right)
$$
and conclude that the limit is $\frac{f'(0)}{2}$. Now, this is correct, but looks a little be sketchy due to the use of the Landau notation in the sum (which looks like it may "hide" some non-uniformity issues between summands) -- we will make it more rigorous below.

*Namely, since $f$ is differentiable at $0$, we can write by Taylor's theorem (the Peano form of the remainer) that
$$
f(x) = f(0)+f'(0)x+r(x)x= f'(0)x+r(x)x \tag{1}
$$
for some $r\colon \mathbb{R}\to \mathbb{R}$ with $\lim_{x\to 0}r(x)=0$. This allows us to reproduce the same chain as above:
$$
\sum_{k=0}^n f\left(\frac{k}{n^2}\right) = f'(0)\cdot \frac{1}{n}\sum_{k=0}^n \frac{k}{n} + \frac{1}{n^2}\sum_{k=0}^n r\left(\frac{k}{n^2}\right)k \tag{2}
$$
and we want to argue the second term converges to $0$. In view of this, fix $\varepsilon > 0$: by assumption, there exists $\delta_\varepsilon>0$ such that $\lvert x\rvert \leq \delta_\varepsilon$ implies $\lvert r(x)\rvert \leq \varepsilon$. Since $0\leq \frac{k}{n^2} \leq \frac{1}{n}$ for all $0\leq k\leq n$, this implies that there exists $N_\varepsilon\geq 0$ such that, for all $n\geq N_\varepsilon$,
$$
\left\lvert \frac{1}{n^2}\sum_{k=0}^n r\left(\frac{k}{n^2}\right)k \right\rvert
\leq \frac{1}{n^2}\sum_{k=0}^n \left\lvert r\left(\frac{k}{n^2}\right)\right\rvert k
\leq \varepsilon \frac{1}{n^2}\sum_{k=0}^n k = \frac{\varepsilon}{2}\cdot \frac{n(n+1)}{n^2} \leq \varepsilon
$$
showing that 
$
\frac{1}{n^2}\sum_{k=0}^n r\left(\frac{k}{n^2}\right)k \xrightarrow[n\to\infty]{} 0
$
as wanted. Thus, we do get from $(2)$ that
$$
\sum_{k=0}^n f\left(\frac{k}{n^2}\right) 
\xrightarrow[n\to\infty]{} \boxed{\frac{f'(0)}{2}}\;.
$$
