# Is $f(n)=\cos(2\pi\theta(1+2+\ldots+n))$ almost periodic?

We use the following definition of almost periodicity given in https://arxiv.org/pdf/math-ph/0005018.pdf

Given a bounded function $f :\mathbb Z \to\mathbb R$ we denote the set of translates of $f$ by $U_0$. The function $f$ is said to be almost periodic if $U_0$ is precompact in $\ell_\infty(\mathbb Z)$.

For instance, all periodic functions are almost periodic. If $\theta$ is an irrational angle, $f(n)=\cos(2\pi n\theta)$ is another example of an almost periodic function.

Let $\Delta_n(x)=1+2+\ldots n$ be the $n$th triangular number and $\theta$ an irrational angle. Is $f(n)=\cos(2\pi\Delta_n\theta)$ almost periodic?

I believe the answer is no, for the same sort of reason that $g(t)=e^{it^2}$ is not almost periodic on $\mathbf R$.
(Indeed, the latter would mean that given $\varepsilon>0$ there is a $T$ such that every interval of length $T$ contains an "$\varepsilon$-almost period" of $g$, that is, a number $s$ such that $\sup_{t\in\mathbf R}|g(t+s)-g(t)|\leqslant\varepsilon$. But in fact, no nonzero $s$ can even be a $1$-almost period of $g$: for, taking $t=(\pi-s^2)/2s$ we get $$|g(t+s)-g(t)| = |e^{i(s^2+2st)}-1| = 2,\qquad\textrm{q.e.d.}$$ I am in a hurry, but expect that this can be refined into a proof that functions like $f(n)=e^{in^2}$, or $f(n)=\cos(n^2)$, or $f(n)=\cos(n(n+1)/2)$, are not almost periodic on $\mathbf Z$.)