Let $f:\mathbb{R}\to \mathbb{R}$ be a measurable function that has arbitrarily small periods, that is, for any $\varepsilon>0$ there is $0<T<\varepsilon$ such that $f(x+T)=f(x)$ for all $x\in\mathbb{R}$. I need to show that $f$ is constant, at least almost everywhere.
Can someone find an elementary proof of this ?
One proof: I found a proof in which I used distribution theory. First replace $f$ by $f_A:= f\mathbf{1}_{\vert f\vert\leq A}$ for $A>0$ to get a bounded function. Therefore, $f$ belongs to $L_{loc}^1(\mathbb{R})$ and can be seen as an element of $\mathcal{D}'(\mathbb{R})$.
Take $T$ a period of $f$ and denote by $\tau_Tf:= f(\cdot-T)$ the translation operator by $T$. Take $\varphi$ as a test function, and compute
\begin{aligned}
\left<f, \varphi \right> &=\left<\tau_T f, \varphi \right> \\ &= \left< f,\tau_{-T} \varphi \right>
\end{aligned}
Thus, for $T$ arbitrarily small
$$\left<f,\tau_T \varphi - \varphi \right> = 0.$$
Then, one uses the fact that if $\underset{n\to\infty}{\lim}T_n =0$, then
$$\underset{T_n\to0}{\lim} \frac{\tau_{T_n}\varphi - \varphi}{T_n} = \varphi'\quad \text{in}\ \mathcal{D(\mathbb{R})}.$$
Passing to the limit in the above inequality one gets that
$$\left<f', \varphi \right> = 0 $$
for any test function $\varphi$. Thus
$$f' = 0\quad\text{in}\ \mathcal{D'}(\mathbb{R}).$$
By a classical result, this implies that $f$ is constant almost everywhere.
Motivation: In a paper called "On the approximation of Lebesgue integrals by Riemann sums", Jessen proves the following theorem. Let $f$ be a $L^1(\mathbf{T})$ function. Denote its Riemann sum $$f_n:= \frac{1}{n}\sum_{k=1}^n f(x+\frac{k}{n}).$$ Then $$\underset{n\to\infty}{\lim} f_{2^n}(x) = \int_0^1 f\quad a.e.x $$ Jessen considers $$\phi(x):=\overline{\lim} f_{2^n}(x)$$ which is a $2^{-n}$ periodic function for all $n$, hence an almost everywhere constant function. The proof reduces to show that this constant is $\int_0^1 f$.