For a trigonometric polynomial $P$, can $\lim \limits_{n \to \infty} P(n^2) = 0$ without $P(n^2) = 0$?

Disclaimer: The original version of this question focused on $2^n$ in lieu of $n^2$. It is in the hope that the question is easier with $n^2$ that I changed it.

I have an always-nonnegative (on the nonnegative integers) trigonometric polynomial¹ $P$:
$$P(n) = \mathcal{R}\left(\sum_{j=1}^k a_j e^{i \theta_j n}\right),$$
with $\lim \limits_{n \to \infty} P(n^2) = 0$.

I want to show that $P(n^2) = 0$.

Here are a few basic facts on trigonometric polynomials that may help. A
trigonometric polynomial is an almost-periodic function. This implies in
particular that:

  • For $\epsilon > 0$, there is a number $L=L(\epsilon)$ such that any
    interval of length $L$ on the real line has an $\epsilon$-translation
    integer, that is, an integer $t$ such that $|P(n) – P(n +t)| < \epsilon$
    for any $n$.

  • From any sequence $\{P(n + m_k)\}$, one can extract a subsequence which
    converges uniformly with respect to $n$. Moreover the function to which it
    converges is almost-periodic itself. ($\{m_k\}$ is an arbitrary sequence
    of numbers).

  • In particular, for any sequence $\{m_k\}$, for any $\epsilon$, there exist
    $i \neq j$ such that $m_i – m_j$ is an $\epsilon$-translation number.

An even simpler case is to consider that $\lim \limits_{n \to \infty} P(n) =
0$. A proof that it implies that $P(n) = 0$ for any $n$ is the following.
Suppose there is an $m$ such that $P(m) > 0$, and set $\epsilon = P(m)/2$.
Now for any $N$, there exists an $\epsilon$-translation number $t$ of $P$ with $t
> N$ an integer. Then $|P(m) – P(m+t)| < \epsilon$, thus $P(m+t) >
\epsilon$. Thus $\lim \limits_{n \to \infty} P(n)$ is not null.

¹: Trigonometric polynomial is taken in the sense of, say, Corduneanu (in
Almost Periodic Functions). Wikipedia seems to have a different definition.

Solutions Collecting From Web of "For a trigonometric polynomial $P$, can $\lim \limits_{n \to \infty} P(n^2) = 0$ without $P(n^2) = 0$?"

[Edit: This answer concerns a previous version of the question.]

The following is a counter-example (assuming “positive” is meant to be read “non-negative”):


It is trivially non-negative for all $x\in\Bbb R$, since it is a square. For all $k\in\Bbb N_0$ we have:

$$\begin{align}P(2k)&=0\tag{1}\\P(2k+1)&=16 \cos^4k \sqrt2\pi\tag{2}\end{align}$$

which we can show using the usual trigonometric formulas:

$$\begin{align}P(2k)&=\left(1+\cos\pi(2k-1)+\cos(\sqrt2-1)\pi(2k-1)+\cos\sqrt2\pi(2k-1)\right)^2\\&=\left(1+(-1)+\cos(\sqrt2\pi(2k-1)-\pi(2k-1))+\cos\sqrt2\pi(2k-1)\right)^2\\&=\left(\cos(\sqrt2\pi(2k-1)+\pi)+\cos\sqrt2\pi(2k-1)\right)^2\\&=\left(-\cos(\sqrt2\pi(2k-1))+\cos\sqrt2\pi(2k-1)\right)^2\\&=0\\ \\P(2k+1)&=\left(1+\cos\pi2k+\cos(\sqrt2-1)\pi2k+\cos\sqrt2\pi2k\right)^2\\&=\left(1+1+\cos(2\sqrt2k\pi-2k\pi)+\cos2\sqrt2k\pi\right)^2\\&=\left(2+2\cos2\sqrt2k\pi\right)^2\\&=\left(4\cos^2\sqrt2k\pi\right)^2\\&=16 \cos^4 \sqrt2k\pi\end{align}$$

Also, $P$ is not a periodic function, which I think we can most likely show by choosing an arbitrary $T\neq 0$ and showing that $P(x+T)-P(x)$ is non-zero for some $x\in\Bbb R$. This seems a bit tedious, so I shall supply the calculation later if I have some more time. [Edit: As user10676 notes, this calculation is not necessary. $P$ is not periodic because $P(x)=16$ only for $x=1$.]

It is quite clear though that the period cannot be an integer, which can be seen directly by examining $(1)$ and $(2)$ and using the irrationality of $\sqrt2$. Since this is what the question is asking about, we have indeed found a relevant counter-example.