While trying to find a closed-form solution for particular cubics as sums of cosines (related to this question), I came across this family with all roots real. Given a prime $p=6m+1$. Define, $$F(x) = x^3+x^2-2mx+N = \Big(x-2\sum_{k=1}^{m}\cos a\Big) \Big(x-2\sum_{k=1}^{m}\cos b\Big) \Big(x-2\sum_{k=1}^{m}\cos c\Big)=0$$ where, $$a=2^k\times\beta,\;\;b=2^k\times3\beta,\;\;c=2^k\times m\beta,$$
and $\beta = \displaystyle\frac{2\pi}{p}$. I noticed that for certain primes, then $N$ is an integer. The complete list for small $p$,
$$\begin{array}{|c|c|} \hline p&N\\ \hline 31& -8\\ 43& 8\\ 109& -4\\ 157& 64\\ 223& -256\\ 229& -212\\ 277& 236\\ 283& 304\\ \hline \end{array}$$
Questions:
- What is the complete list of such primes for a low bound, say $p<3000$? (My old version of Mathematica conks out at $p>2000$.)
- What do these primes $p$ have in common that make them distinct from other primes? (Other than that their $N$ is an integer.)
- The coefficients of the cubic $F(x)=0$ are simple polynomials in $m$, except the constant term. Can $N$ be expressed as a polynomial in $m$?
P.S. I've checked the OEIS and it's not there, but the list I have for $p<2000$ suggests that a necessary (but not sufficient) condition is that
$$p = x^2+27y^2,\quad\text{and}\quad 2^{2m} = 1\;\text{mod}\;p$$
(A014752) and (A016108), though it would be great if someone can prove (or disprove) that if $N$ is an integer, then these must hold.