I was trying to generalize,


$$\sqrt[3]{\sum\_{k=1}^5\cos\big(\tfrac{2^k\cdot\,2\pi}{31}\big)}+\sqrt[3]{\sum\_{k=1}^5\cos\big(\tfrac{2^k\cdot\,6\pi}{31}\big)}+\sqrt[3]{\sum\_{k=1}^5\cos\big(\tfrac{2^k\cdot\,10\pi}{31}\big)} = -\sqrt[3]{\tfrac{-11+3\,\sqrt[3]{62}}{2}} \tag1$$


which is a special case of an identity of Ramanujan's. It led me to a family of primes $p=x^2+27y^2$ ([A014752](https://oeis.org/A014752)). Let $\beta=2\pi/p$ and define,


$$p=x^2+27y^2=6m+1$$


$$x\_1=2\sum\_{k=1}^{m}\cos\big(2^k\times\beta\big)$$
$$x\_2=2\sum\_{k=1}^{m}\cos\big(2^k\times3\beta\big)$$
$$x\_3=2\sum\_{k=1}^{m}\cos\big(2^k\times m\beta\big)$$
and,
$$a = -(x\_1+x\_2+x\_3),\quad b=x\_1x\_2+x\_1x\_3+x\_2x\_3,\quad c=-x\_1x\_2x\_3$$


I noticed some $a,b,c$ were just ***plain integers***. In general, they were algebraic integers at most of a degree $n \leq 9$. The complete list for $p<1000$,


$$\begin{array}{|l|l|}
\hline
n&\quad\quad\quad p\\
\hline
1& 31, 43, 109, 157, 223, 229, 277, 283, 691, 733, 739, 811\\
2& 433, 457\\
3& 307, 439, 499, 643, 727, 919, 997\\
4& 601\\
6& (\text{for}\; p>1000?)\\
9& 127, 397\\
\hline
\end{array}$$


**Questions:**


1. All these primes are also $4^m \equiv 1\pmod p$ ([A016108](https://oeis.org/A016108)). However, what distinguishes the primes $p$ in the first row from the others such that their $a,b,c$ are just *plain integers*? (It seems $p\equiv 1\pmod{24}$ have $n=2,4$.)
2. Is there a $p$ with $n=6$? (I'm having trouble with $p=1297$.)


**P.S.** This is related to a [MSE post](https://math.stackexchange.com/questions/1069520/) of mine.



Primes $p=x^2+27y^2$ and Ramanujan's $x_1^{1/3} + x_2^{1/3} + x_3^{1/3}$
Let $\zeta = e^{2\pi i/p}$ be a primitive $p$th root of unity. Then
$2 \cos (2\pi k/p) = \zeta^k + \zeta^{-k}$. The Galois group of $\mathbb Q(\zeta)$
is isomorphic to $(\mathbb Z/p \mathbb Z)^\times$ and acts transitively on
the powers $\zeta^k$ with $1 \le k \le p-1$. What you want is that the Galois
action fixes the set $\{x\_1, x\_2, x\_3\}$. Now $x\_j = \sum\_{k \in A\_j} \zeta^k$
where $A\_1 = \{\pm 2^j : 0 \le k < m\} \subset \mathbb Z/p \mathbb Z$ (as a
multiset) and similarly for $A\_2$ and $A\_3$. So you want the natural action
of $(\mathbb Z/p \mathbb Z)^\times$ on $\mathbb Z/p \mathbb Z$ by multiplication
to just permute these three sets. This is only possible when $A\_1$ consists of
all cubes in $(\mathbb Z/p \mathbb Z)^\times$.
In any case, 2 is a cube (since $p = x^2 + 27 y^2$; this is a famous result
due to Gauss). However, not every cube is necessarily $\pm$ a power of 2.
For example, for $p = 127$, the powers of 2 give you only 7 residue classes,
so $A\_1$ has 14 distinct elements, but $(p-1)/3 = 42$ is larger.


The precise condition should be that 


1. the order of 2 in the group
$(\mathbb Z/p \mathbb Z)^\times$ must be either $2m$ or else $m$
and $m$ must be odd (otherwise $2^{m/2} = -1$ and the positive
and negative powers of 2 in $A\_1$ coincide), and
2. $3$ is not a cubic residue mod $p$ (this is the condition for
$A\_1$, $A\_2$ and $A\_3$ to be pairwise disjoint).


Note that this is consistent with your table. This answers Question 1.


To give an answer to Question 2, here is how you can determine the
degree $n$ of your algebraic integers $a$, $b$, $c$.
You consider the set $\{A\_1, A\_2, A\_3\}$ and count how many images it has
under the natural action of $(\mathbb Z/p \mathbb Z)^\times$. This is $n$.


For $p = 1297$, I get $n = 648$, so it is not surprising that you had trouble.
(But then, 1297 is not of the form $x^2 + 27y^2$!) And $p = 3889$ has $n = 6$.


