Ramanujan-type trigonometric identities with cube roots, generalizing $\sqrt[3]{\cos(2\pi/7)}+\sqrt[3]{\cos(4\pi/7)}+\sqrt[3]{\cos(8\pi/7)}$
Ramanujan found the following trigonometric identity \begin{equation} \sqrt[3]{\cos\bigl(\tfrac{2\pi}7\bigr)}+ \sqrt[3]{\cos\bigl(\tfrac{4\pi}7\bigr)}+ \sqrt[3]{\cos\bigl(\tfrac{8\pi}7\bigr)}= \sqrt[3]{\tfrac{5-3\sqrt[3]7}2} \end{equation} (see e.g. Ramanujan — For Lowbrows, (3.7) and around, for details and an analogue for 9 instead of 7).
Are there analogous identities for all primes $p$ of the form $3k+1$ instead of 7?
Let me try to explain what I mean. As I've learned from S. Markelov, for $p=13$ \begin{multline} \sqrt[3]{\cos\bigl(\tfrac{2\pi}{13}\bigr)+\cos\bigl(\tfrac{10\pi}{13}\bigr)}+ \sqrt[3]{\cos\bigl(\tfrac{4\pi}{13}\bigr)+\cos\bigl(\tfrac{6\pi}{13}\bigr)}+ \sqrt[3]{\cos\bigl(\tfrac{8\pi}{13}\bigr)+\cos\bigl(\tfrac{12\pi}{13}\bigr)}=\\ \sqrt[3]{\tfrac{3\sqrt[3]{13}-7}2} \end{multline} and there are close analogues for all $p$ of the form $n^2+n+1$. For example, for $p=43=6^2+6+1$ three groups of numerators are {2, 4, 8, 16, 22, 32, 42}, {6, 10, 12, 20, 24, 38, 40}, {14, 18, 26, 28, 30, 34, 36} and the sum is $\sqrt[3]{\frac{3\sqrt[3]{86}-13}2}$.
So it looks like there is some pattern reminding of... quadratic Gauss sums, perhaps.
For any $p=3k+1$ one can partition $\mathbb F_p^\times$ into three groups, corresponding to $\mathbb F_p^\times/\mathbb F_p^{\times3}\cong\mathbb Z/3$ — and this is precisely the partitions from the last paragraph. This explains what LHS should look like. And indeed, at least for $p=19$ there is an identity \begin{multline} \sqrt[3]{\cos\bigl(\tfrac{\pi}{19}\bigr)+\cos\bigl(\tfrac{7\pi}{19}\bigr)+\cos\bigl(\tfrac{11\pi}{19}\bigr)}+ \sqrt[3]{\cos\bigl(\tfrac{3\pi}{19}\bigr)+\cos\bigl(\tfrac{5\pi}{19}\bigr)+\cos\bigl(\tfrac{17\pi}{19}\bigr)}+\\ \sqrt[3]{\cos\bigl(\tfrac{9\pi}{19}\bigr)+\cos\bigl(\tfrac{13\pi}{19}\bigr)+\cos\bigl(\tfrac{15\pi}{19}\bigr)}=\\ \sqrt[3]{\tfrac12-3\sqrt[3]7+\tfrac32\sqrt[3]{3\sqrt[3]{49}+18\sqrt[3]7-25}+\tfrac32\sqrt[3]{3\sqrt[3]{49}+18\sqrt[3]7-44}} \end{multline} which is closely related to the fact that $2 \left( \cos \frac{4\pi}{19} + \cos \frac{6\pi}{19}+\cos \frac{10\pi}{19} \right)$ is a root of the equation $\sqrt{ 4+ \sqrt{ 4 + \sqrt{ 4-x}}}=x$.
So,
more precisely: is it true, that for any $p=3k+1$ the sum of 3 cubic roots of sum of cosines (described above) can be expressed in real radicals?
what can be said about RHS in this case (say, about the number of nested radicals)?
$\color{blue}{\text{Edited 9 Jun 2017:}}$
Let $p$ be a prime number congruent to 1 modulo 6, and $g$ a primitive root modulo $p$, i.e. a generator of the group $ \mathbb F_{p} ^ {\times} \cong C_{p-1} $. By definition, put $$ S_p(g) = \sum_{k=0}^{\frac{p-4}3}\cos \left(\frac{2\pi}{p}g^{3k}\right) , S'_p(g) =\sum_{k=0}^{\frac{p-4}3}\cos \left(\frac{2\pi}{p}g^{3k+1}\right) \text{, } S''_p(g) = \sum_{k=0}^{\frac{p-4}3}\cos \left(\frac{2\pi}{p}g^{3k+2}\right) . $$
In this PDF we prove the following result.
Theorem 1. Suppose $p$ equals $9m^2+3m+1$ for some $m\in \mathbb Z$. Then for any primitive root $g$ we have $$\sqrt[3]{S_p(g)} + \sqrt[3]{S'_p(g)} + \sqrt[3]{S''_p(g)} =\sqrt[3]{ 3\sqrt[3]{mp}-(6m+1) } . $$
Warning: I am not sure about my English. If you find some mistakes please write me.
$\color{brown}{Update:}$
The question is: Is it true, that for any $p=3k+1$ the sum of 3 cubic roots of sum of cosines can be expressed in real radicals?
The answer is Yes. In general, given the roots $x_i$ of the general cubic equation,
$$x^3+ax^2+bx+c=0\tag0$$
then sums involving the cube roots of the $x_i$ can be given in the simple form,
$$(u+x_1)^{1/3}+(u+x_2)^{1/3}+(u+x_3)^{1/3} = \big(w+3\,\sqrt{d}\,^{1/3}\big)^{1/3}$$
where $u,w$ are the constants,
$$u = \frac{ab-9c+\sqrt{d}}{2(a^2-3b)}$$
$$w = -\frac{(2a^3-9ab+27c)+9\sqrt{d}}{2(a^2-3b)}$$
and $d$ is the negated discriminant $D$,
$$d = -D = \tfrac{1}{27}\Bigl(4(a^2-3b)^3-(2a^3-9ab+27c)^2\Bigr)$$
- If $d$ is positive, meaning the discriminant $D$ is negative, so the cubic has all real roots, thus $u,w$ are also real.
- Furthermore, if the cubic has a cyclic group, which is the case when it involves the $p$th root of unity, then $d$ is a square, so $u,w$ in fact are rational.
- The case $a^2-3b=0$ implies $d =-(a^3-27c)^2$, so $+D$, hence only one root $x_1$ is real.
Example. If we use the cubic for $\cos(2\pi/7)$, namely $x^3 + x^2 - 2x - 1 = 0$, then we have either $u = 0$ or $1$, since $\pm\sqrt{d} = 7$. So using the negative and positive case respectively, we get,
$$\sqrt[3]{2\cos\bigl(\tfrac{2\pi}{7}\bigr)}+\sqrt[3]{2\cos\bigl(\tfrac{4\pi}{7}\bigr)}+\sqrt[3]{2\cos\bigl(\tfrac{8\pi}{7}\bigr)} = \sqrt[3]{5\color{blue}{-}3\,\sqrt[3]{7}}$$
$$\sqrt[3]{1+2\cos\bigl(\tfrac{2\pi}{7}\bigr)}+\sqrt[3]{1+2\cos\bigl(\tfrac{4\pi}{7}\bigr)}+\sqrt[3]{1+2\cos\bigl(\tfrac{8\pi}{7}\bigr)} = \sqrt[3]{-4\color{blue}{+}3\,\sqrt[3]{7}}$$
and so on for other $p=6m+1$, covering my old addendum for $p=19$.
$\color{brown}{Old\; answer:}$
The general phenomenon can be explained by a beautiful cubic identity found by, of course, Ramanujan. {Grigori M, ironically, you pointed out this identity in an old question of mine. :) }
I. Given the three roots $x_i$ of,
$$x^3-ax^2+bx-1 = 0\tag1$$
then,
$$x_1^{1/3}+x_2^{1/3}+x_3^{1/3} = (a+6+3t)^{1/3}\tag2$$
where $t$ is a root of,
$$t^3-3(a+b+3)t-\big(ab+6(a+b)+9\big) = 0\tag3$$
The form of the $p=19$ suggests it is just a particular case of this identity. Note that,
$$y=2\Bigl(\cos\bigl(\tfrac{\pi}{19}\bigr)+\cos\bigl(\tfrac{7\pi}{19}\bigr)+\cos\bigl(\tfrac{11\pi}{19}\bigr)\Bigr)$$
(and the other two similar expressions) is a root of,
$$y^3+y^2-6y-7=0$$
One can then scale variables and make the constant term $c=-1$. I did so, and got the exact form as the one above.
II. Note that if $a+b+3=0$, then $(3)$ takes a particularly simple form. After some manipulation, I found that given,
$$x^3 + x^2 - (3 n^2 + n)x + n^3=0\tag4$$
then,
$$F_P = x_1^{1/3}+x_2^{1/3}+x_3^{1/3} = \sqrt[3]{-(6n+1)+3\sqrt[3]{nP}}\tag5$$
where $P = 9n^2+3n+1$. For $n = -1, 1, -2, 2$, we get the same cubics satisfied by the sums of cosines for $P=7,13,31,43,\dots$ thus explaining the simple sums,
$$F_7 =-\sqrt[3]{-5+3\sqrt[3]{7}} $$
$$F_{13} = \sqrt[3]{-7+3\sqrt[3]{13}} $$
and so on, though I cannot prove that the roots of $(4)$ are always sums of cosines when $P$ is prime. Maybe I'll ask it as a separate question.
I tried to find such rationals $a,b,c,d$ so that, $$(a+b\,x_1)^{1/3} + (a+b\,x_2)^{1/3} + (a+b\,x_3)^{1/3} = (c+\sqrt[3]{dp})^{1/3}$$ So, we have identities for all primes $p=1\ mod\ 3$ such that $p<100$ $$\sqrt[3]{1+\sum_{k=0}^{5}\cos(\frac{2\pi }{19}\cdot2^{3k}) }+\sqrt[3]{1+\sum_{k=0}^{5}\cos(\frac{2\pi }{19}\cdot2^{3k+1}) }+\sqrt[3]{1+\sum_{k=0}^{5}\cos(\frac{2\pi }{19}\cdot2^{3k+2}) }=\sqrt[3]{8-3\sqrt[3]{19}}\qquad\\ \sqrt[3]{-1+\sum_{k=0}^{11}\cos(\frac{2\pi }{37}\cdot2^{3k}) }+\sqrt[3]{-1+\sum_{k=0}^{11}\cos(\frac{2\pi }{37}\cdot2^{3k+1}) }+\sqrt[3]{-1+\sum_{k=0}^{11}\cos(\frac{2\pi }{37}\cdot2^{3k+2}) }=\sqrt[3]{-10+3\sqrt[3]{37}}\qquad\\ \sqrt[3]{-1+\sum_{k=0}^{19}\cos(\frac{2\pi }{61}\cdot2^{3k}) }+\sqrt[3]{-1+\sum_{k=0}^{19}\cos(\frac{2\pi }{61}\cdot2^{3k+1}) }+\sqrt[3]{-1+\sum_{k=0}^{19}\cos(\frac{2\pi }{61}\cdot2^{3k+2}) }=\sqrt[3]{14-3\sqrt[3]{3\cdot 61}}\qquad\\$$
$$\sqrt[3]{1+\sum_{k=0}^{21}\cos(\frac{2\pi }{67}\cdot2^{3k}) }+\sqrt[3]{1+\sum_{k=0}^{21}\cos(\frac{2\pi }{67}\cdot2^{3k+1}) }+\sqrt[3]{1+\sum_{k=0}^{21}\cos(\frac{2\pi }{67}\cdot2^{3k+2})}=\sqrt[3]{-16+3\sqrt[3]{3\cdot 67}}\qquad\\ \sqrt[3]{-2+\sum_{k=0}^{25}\cos(\frac{2\pi }{79}\cdot3^{3k}) }+\sqrt[3]{-2+\sum_{k=0}^{25}\cos(\frac{2\pi }{79}\cdot3^{3k+1})}+\sqrt[3]{-2+\sum_{k=0}^{25}\cos(\frac{2\pi }{79}\cdot3^{3k+2})}=\sqrt[3]{-13+3\sqrt[3]{79}}\qquad\\ \sqrt[3]{3+\sum_{k=0}^{31}\cos(\frac{2\pi }{97}\cdot5^{3k}) }+\sqrt[3]{3+\sum_{k=0}^{31}\cos(\frac{2\pi }{97}\cdot5^{3k+1})}+\sqrt[3]{3+\sum_{k=0}^{31}\cos(\frac{2\pi }{97}\cdot5^{3k+2})}=\sqrt[3]{14-3\sqrt[3]{97}} $$
$\color{blue}{\text{Added June 27:}}$
$$\sqrt[3]{\frac{74}{43}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k}) }+\sqrt[3]{\frac{74}{43}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+1}) }+\sqrt[3]{\frac{74}{43}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+2}) }=\sqrt[3]{\frac{392}{43}}$$ $$\sqrt[3]{\frac{5105}{11349}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k}) }+\sqrt[3]{\frac{5105}{11349}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+1}) }+\sqrt[3]{\frac{5105}{11349}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+2}) }=\sqrt[3]{\frac{21}{1261}}$$ $$\sqrt[3]{-\frac{2306997866696}{1047656140569}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k}) }+\sqrt[3]{-\frac{2306997866696}{1047656140569}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+1}) }+\sqrt[3]{-\frac{2306997866696}{1047656140569}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+2}) }=-\sqrt[3]{\frac{118149192000}{1908298981}}$$ $$\sqrt[3]{\frac{9658771264742899051}{5361029308457632889}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k}) }+\sqrt[3]{\frac{9658771264742899051}{5361029308457632889}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+1}) }+\sqrt[3]{\frac{9658771264742899051}{5361029308457632889}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+2}) }=\sqrt[3]{\frac{60079542508626277}{3881990809889669}}$$ $$\sqrt[3]{\frac{1512950552654226074845360221799154}{22816093930106873589073278570630913}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k}) }+\sqrt[3]{\frac{1512950552654226074845360221799154}{22816093930106873589073278570630913}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+1}) }+\sqrt[3]{\frac{1512950552654226074845360221799154}{22816093930106873589073278570630913}+\sum_{k=0}^{1}\cos(\frac{2\pi }{7}\cdot3^{3k+2}) }=-\sqrt[3]{\frac{9567191523845032860388297048}{16721690052047565734068821733}}$$ and so on.
Suppose $p=3k+1$. Then by a theorem of Gauss $4p=A^2+27B^2$ and cubic sums like $\displaystyle\sum_{t\in\mathbb Z/p}\cos\left(\frac{2\pi t^3}p\right)$ are roots of the equation $x^3-3px-Ap=0$. And if we have three roots $x_i$ of a cubic equation, Ramanujan's lemma gives the value of $\sqrt[3]{x_1}+\sqrt[3]{x_2}+\sqrt[3]{x_3}$. That's precisely what's going on, I believe.