# Evaluating a remarkable term for primes p = 5 (mod. 8)

Let $p > 3$ be a prime number, and $\zeta$ be a primitive $p$-th root of unity. I am interested in knowing the exact value of $$w_p = \prod_{a \in (\mathbb F_p^{\times})^2}(1 + \zeta^a) + \prod_{b \in \mathbb F_p^{\times} \backslash (\mathbb F_p^{\times})^2}(1 + \zeta^b).$$ (The term $w_p$ is related to the number of subsets $S \subset \mathbb F_p$ for which $\sum_{s \in S} s^2 = 0.$)

It is more or less straightforward to prove that $w_p = 2$ for $p \equiv \pm 1 \ (\text{mod}. 8)$ and $w_p = -2$ for $p \equiv 3 \ (\text{mod}. 8).$

(If anyone wants to see a proof for that, I can provide it. It boils down to the fact that $2 \in (\mathbb F_p^{\times})^2$ in the first case and $-1 \not\in (\mathbb F_p^{\times})^2$ in the scond case.)

So it remains to evealuate $w_p$ for $p \equiv 5 \ (\text{mod}. 8)$. One might conjecture that in this case, we also have $w_p = -2$, but this is wrong: The values for $p = 5,13,29,37$ are $w_p = 3,11,27,146$.

Indeed, it is easy to show that also in this case $w_p$ is an integer and $w_p \equiv -2 \ (\text{mod}. p)$. Looking at the values for small $p$, I arrived at the following conjecture:

Suppose $p \equiv 5 \ (\text{mod}. 8)$. Let $(\alpha,\beta)$ be the fundamental positive solution of the generalized Pell equation $\alpha^2 - p \beta^2 = 4$. Then $w_p = \alpha$.

Can anyone tell me if this statement is true?

According to Theorem 5.1 of http://math.mit.edu/~rstan/pubs/pubfiles/35.pdf, the number is $$\frac 1p\left[ 2^{p-1}+\frac{p-1}{2}(\epsilon^{4h} + \epsilon^{-4h})\right],$$ where $h$ is the class number of $\mathbb{Q}(\sqrt{p})$ and $\epsilon>1$ the fundamental unit of $\mathbb{Q}(\sqrt{p})$.
Addendum. I should clarify that the number above is the number of subsets $S$ of $\mathbb{F}_p^*$ satisfying $\sum_{s\in S}s^2=0$. To get the number of such subsets of $\mathbb{F}_p$, multiply by two.
• This is great; it gives (if I did not do a mistake) that $w_p = \epsilon^{2h} + \epsilon^{-2h}$. So it seems that my conjectrue is wrong, but there is a nice closed formula for $w_p$. – Jens Reinhold Apr 19 '15 at 21:39