Convergence of the series $\sum_{n=1}^{\infty} \frac{\cos(n^2x)}{n}$. Let $x \in (0, 2\pi)$. Is the series $\sum_{n=1}^{\infty} \frac{\cos(n^2x)}{n}$ convergent? My guess is: YES and I would like to use Dirichlet test: however I have troubles proving that the partial sums $\cos(x)+\cos(4x)+...+\cos(n^2x)$ are bounded due to the lack of the simple formula for this sum. Any ideas?
 A: Sorry for joining the discussion after two years but I wanted to share this rather interesting result regarding the discrete case. I realize that this is just a partial answer but I feel it is a bit too long to fit in a comment. So let us assume
$$  x =  \frac{2\pi p}{q}, $$
where $q \in \mathbb{N}$ and $p \in \{1, 2,  \dots, q - 1\}$. Then the following holds:

*

*if $q$ is a prime and $q = 1 \; (\text{mod} \; 4)$, then the series diverges

*if $q$ is a prime and $q = 3 \; (\text{mod} \; 4)$, then the series converges

In particular, the set of $x$ such that the series diverges is dense in $(0, 2\pi)$. To prove this, denote
$$  \Delta :=  \sum_{n = 1}^{q} \cos(n^2x). $$
Now, thanks to $q$-periodicity, we can easily see that the series
$$\sum_{n = 1}^{\infty} \left[\cos(n^2x) - \frac{\Delta}{q}\right] $$
has bounded partial sums and hence by Dirichlet test, the series
$$\sum_{n = 1}^{\infty} \frac{\cos(n^2x)}{n} = \sum_{n = 1}^{\infty} \frac{1}{n}\left[ \cos(n^2x) - \frac{\Delta}{q}\right]  + \frac{\Delta}{q}\sum_{n = 1}^{\infty} \frac{1}{n}$$
converges if and only if $\Delta = 0$. (This trick does not work when $x$ is an irrational multiple of $\pi$.) Next, we will need some basic number theory. Suppose that $q$ is an odd prime and define:
$$\zeta := e^{ix}$$
$$ \phi(z) := z^{q - 1} + z^{q - 2} + \dots + 1, $$
$$ h(z) := \sum_{m = 1}^{q-1}\left(\frac{m}{q}\right)z^n, $$
where
$$ \left(\frac{m}{q}\right)$$
is the Legendre symbol. Since $q$ is a prime, the multiplicative group modulo $q$ is cyclic. From the cyclic structure, it follows that each nonzero quadratic residue of $q$ is present in the sequence $1,4,9, \dots, (q-1)^2$ exactly twice. Hence
\begin{align} \Delta  &=  1 + \sum_{n = 1}^{q-1} \cos(n^2x),\\
 &=  1 + 2\sum_{m \in (\mathbb{Z}/q\mathbb{Z})^\times \; \wedge \; \left(\frac{m}{q}\right) = 1} \cos(mx),\\
 &  =  1 + 2\sum_{m \in (\mathbb{Z}/q\mathbb{Z})^\times \; \wedge \; \left(\frac{m}{q}\right) = 1} \Re{(\zeta^m)} - \phi(\zeta),\\
 & = \Re{(h(\zeta))}. \end{align}
Note that $h(\zeta) \neq 0$ (this follows from the fact that $\zeta$ is already a root of an irreducible polynomial $\phi$ and from the observation that $h$ is clearly not divisible by $\phi$). Finally, we observe that
\begin{align}
 h(\zeta) &= \sum_{m \in (\mathbb{Z}/q\mathbb{Z})^\times} \left(\frac{m}{q}\right)\zeta^m\\
  &= \sum_{m \in (\mathbb{Z}/q\mathbb{Z})^\times} \left(\frac{-m}{q}\right)\zeta^{-m}\\
  &= \left(\frac{-1}{q}\right)\overline{h}(\zeta).\\
\end{align}
If $q = 1 \; (\text{mod} \; 4)$, then $-1$ is a quadratic residue of $q$ and so $h(\zeta)$ is real. Then $\Delta \neq 0$ and the series will diverge. If $q = 3 \; (\text{mod} \; 4)$, then $-1$ is not a quadratic residue of $q$ and so $h(\zeta)$ is imaginary. Then $\Delta = 0$ and the series will converge. (For analogical sine series, this would be vice versa.)
The following table lists whether the series converges or diverges based on the numerically computed sign of $\Delta$ for different values of $q$ (rows) and $p$ (columns), where

*

*symbol $0$ denotes convergence

*symbol $+$ denotes divergence to $+\infty$

*symbol $-$ denotes divergence to $-\infty$

It shows that in the statement above, the assumption of primality is essential and the general case is more complicated. One can expect that the indiscrete case will be yet even more complicated.
