Vanishing of a sum of roots of unity In my answer to this question, there appears the following sub-question about a sum of roots of unity. Denoting $z=\exp\frac{i\pi}N$ (so that $z^N=-1$), can the quantity
$$\sum_{k=0}^{N-1}z^{2k^2+k}$$
vanish ?
The answer is clearly No for $N\le7$. I suspect that it never vanishes, which should answer definitively the above matricial question. Any idea of a general argument ?
 A: For general $N$, we can reason by induction on the $2$-adic valuation of $N$. If $N$ is odd, GH from MO's answer shows that $S_N :=\sum_{k=0}^{N-1} \zeta_{2N}^{2k^2+k} \neq 0$, where $\zeta_{2N} = z = e^{\pi i/N}$ is a primitive $2N$-th root of unity. The same argument shows that for any odd $N$ and any $b \neq 1$, the following variant of $S_N$ is nonzero:
\begin{equation*}
S_{N,b} :=\sum_{k=0}^{N-1} \zeta_{2N}^{2^b k^2+k} \neq 0.
\end{equation*}
For convenience of the reader, the proof goes as follows. In the ring $\mathbb{Z}[z]/(2)$, we have
\begin{equation*}
S_{N,b}^{2^{b+3}} = \sum_{k=0}^{N-1} z^{2^{b+3} (2^b k^2+k)} = \sum_{k=0}^{N-1} \zeta_N^{2^{2b+2} k^2+2^{b+2} k} = \sum_{k=0}^{N-1} \zeta_N^{(2^{b+1} k + 1)^2 - 1} = \zeta_N^{-1} \sum_{\ell=0}^{N-1} \zeta_N^{\ell^2},
\end{equation*}
and one conclude as in GH from MO's answer.
Now write $N=2^a M$ with $M$ odd, and assume $a \geq 1$. The Galois group of $\mathbb{Q}(\zeta_{2N})/\mathbb{Q}(\zeta_N)$ is of order 2, generated by the automorphism $\sigma : \zeta_{2N} \mapsto \zeta_{2N}^{1+N} = - \zeta_{2N}$. Moreover, we have
\begin{equation*}
\sigma(S_{N,b}) = \sum_{k=0}^{N-1} (-\zeta_{2N})^{2^b k^2+k} = \sum_{k=0}^{N-1} (-1)^k \zeta_{2N}^{2^b k^2+k},
\end{equation*}
so that
\begin{equation*}
\frac12 (S_{N,b}+\sigma(S_{N,b})) = \sum_{\substack{k=0 \\ k \textrm{ even}}}^{N-1} \zeta_{2N}^{2^b k^2+k} = \sum_{k=0}^{N/2-1} \zeta_{2N}^{2^{b+2} k^2+2k} = \sum_{k=0}^{N/2-1} \zeta_N^{2^{b+1} k^2+k} = S_{N/2, b+1}.
\end{equation*}
By induction, we have $S_{N/2,b+1} \neq 0$, which implies $S_{N,b} \neq 0$.
A: The sum does not vanish when $N$ is odd. I will elaborate on François Brunault's idea.
Assume that $N$ is odd, and let $S$ be the sum in question. Working in the ring $\mathbb{Z}[z]$, we see that $S^{16}\equiv T\pmod{2}$, where
$$T:=\sum_{k=0}^{N-1}e^{16\pi i(2k^2+k)/N}=e^{-2\pi i/N}\sum_{k=0}^{N-1}e^{2\pi i(4k+1)^2/N}=e^{-2\pi i/N}\sum_{\ell=0}^{N-1}e^{2\pi i\ell^2/N}.$$
The $\ell$-sum is a classical Gauss sum whose fourth power is known to be $N^2$. Therefore, $S^{64N}\equiv T^{4N}=N^{2N}\equiv 1\pmod{2}$, and hence $S\neq 0$ as claimed.
