# Factoring cyclotomic polynomials over quadratic subfield

The quadratic subfield of $$\mathbb{Q}(\zeta_p)$$ is given by $$\mathbb{Q}(\sqrt{p^*})$$, where $$p^*$$ is the choice of $$\pm p$$ which is $$1$$ mod $$4$$. By some elementary Galois theory, the cyclotomic polynomial $$\Phi_p = \frac{x^p-1}{x-1}$$ factors into two irreducible polynomials of degree $$\frac{p-1}{2}$$ over this quadratic subfield, which one can describe as $$P_{QR}(x) = \prod_{k\ \text{QR}} (x-\zeta_p^k)$$ $$P_{QNR}(x) = \prod_{k\ \text{QNR}} (x-\zeta_p^k)$$ where $$k$$ ranges over the (nonzero) quadratic residues and quadratic nonresidues modulo $$p$$ respectively.

Is there an explicit description for the coefficients of these polynomials in terms of $$\sqrt{p^*}$$? The first coefficient, the one in front of $$x^{\frac{p-3}{2}}$$, is $$\frac{1\mp\sqrt{p^*}}{2}$$ by the statement of Gauss sums.

Some trivial observations. We have $$P_{QR}(1/x) x^{(p-1)/2} = \prod_{QR} (1 - x \zeta^k),$$ $$P_{QNR}(1/x) x^{(p-1)/2} = \prod_{QNR} (1 - x \zeta^k),$$ which are easier to work with. On the other hand, if $$p \ge 5$$, the product of $$\zeta^k_p$$ over quadratic residues is one, and the product over non-residues is also one. Hence we can write \begin{aligned} P_{QR}(1/x) x^{(p-1)/2} = & \ \prod_{QR} ( 1 - x \zeta^k) = \prod_{QR} ( \zeta^{-k} - x) \\ = & \ (-1)^{(p-1)/2} \prod_{QR} (x - \zeta^{-k}) \\ = & \ \begin{cases} P_{QR}(x), & p \equiv 1 \mod 4 \\ - P_{QNR}(x), & p \equiv 3 \mod 4 \end{cases} \end{aligned} because $$(-1/p) = (-1)^{(p-1)/2}$$. The same swapping occurs for $$P_{QNR}$$. Let's consider the highest powers of $$P_{QR}(x)$$ and $$P_{QNR}(x)$$, or equivalently the lowest powers of $$P_{QR}(1/x) x^{(p-1)/2}$$ and $$P_{QNR}(1/x) x^{(p-1)/2}$$. We have $$\frac{P_{QR}(1/x) x^{(p-1)/2}}{P_{QNR}(1/x) x^{(p-1)/2}} = \prod ( 1 - x \zeta^k)^{ \left( \frac{k}{p}\right)}.$$
As mentioned there is the Gauss sum: $$\sum \left( \frac{k}{p}\right) \zeta^{k} = \sqrt{p^*},$$ and similarly $$\sum \left( \frac{k}{p}\right) \zeta^{nk} = \left( \frac{n}{p} \right) \sqrt{p^*},$$ applying $$[n] \in (\mathbb{Z}/p\mathbb{Z})^{\times} = \mathrm{Gal}(\mathbb{Q}(\zeta)/\mathbb{Q})$$ to both sides; when $$p|n$$ we interpret the RHS as being zero, and this is still correct, although we won't actually care about terms this deep into the power series above. We deduce that $$- \log \left( \frac{P_{QR}(1/x) x^{(p-1)/2}}{P_{QNR}(1/x) x^{(p-1)/2}} \right) = \sum_{n=1}^{\infty} \frac{x^n}{n} \sum \left( \frac{k}{p}\right) \zeta^{nk} = \sqrt{p^*} \sum_{n=1}^{\infty} \left( \frac{n}{p}\right) \frac{x^n}{n}.$$ Naturally $$- \log \left( P_{QR}(1/x) x^{(p-1)/2} P_{QNR}(1/x) x^{(p-1)/2} \right) = \log \left( \frac{1 - x^p}{1 - x} \right) = \log(1-x) + O(x^p) = - \sum \frac{x^n}{n},$$ and so (for example) $$\log(P_{QR}(1/x) x^{(p-1)/2}) = \frac{1}{2} \sum \frac{x^n}{n} \left(1 - \left( \frac{n}{p}\right) \sqrt{p^*}\right) + O(x^p),$$ You can now formally expand this out to get the first few terms. For example, the first non-zero term is $$\frac{1 - \sqrt{p^*}}{2},$$ and the second is $$\frac{3 + p^* - 2 \sqrt{p^*}\left(1 + \left( \frac{2}{p}\right) \right) }{8}$$ For example, if $$p \equiv 3,5 \mod 8$$ so $$(2/p) = -1$$, this is $$\frac{3 + p^*}{8}.$$ Note the conditions on $$p$$ ensure that this is an algebraic integer, as it has to be. As you keep going, you get more and more terms involving the quadratic residues $$(n/p)$$ for small $$n$$, and it becomes messier and messier, and dependent on $$p$$ modulo higher integers. The third term, for example, is $$\frac{15 - 9 \sqrt{p^*} + 3 p^* - p^* \sqrt{p^*} + 6(p^* - \sqrt{p^*})(2/p) - 8 \sqrt{p^*} (3/p)}{48}.$$