Re: complex number
This is just RandomVariable's solution, but re-arranged a bit.
We'll start here:
Let $w = \cos(\frac{\pi}{8}) + i\sin(\frac{\pi}{8})$
If you know DeMoivre's formula, you can see that:
$w^8 = -1$, so $w$ is one root of $x^8 + 1$.
With any real polynomial, if a complex number $z$ is a root, so is $\overline{z}$.
This means that $\overline{w}^8 = -1$ as well.
It should also be clear that:
$(w^n)^8 = w^{8n} = (w^8)^n = (-1)^n = -1$ for $n = 1,3,5,7$.
Thus, likewise:
$((\overline{w})^n)^8 = 1$ for $n = 1,3,5,7$.
so this gives us 8 factors.
Let's look at the 4 quadratics:
$(x - w^n)(x - \overline{w}^n)$ for $n = 1,3,5,7$.
Expanding this out, this becomes:
$(x - \cos(\frac{n\pi}{8}) - i\sin(\frac{n\pi}{8}))(x - \cos(\frac{n\pi}{8}) + i\sin(\frac{n\pi}{8}))$
$= x^2 -2\cos(\frac{n\pi}{8})x + \cos^2(\frac{n\pi}{8}) + \sin^2(\frac{n\pi}{8})$
$= x^2 - 2\cos(\frac{n\pi}{8})x + 1$
Since we are only considering odd $n$, we can use the index $k = \frac{n-1}{2}$, in which case we get:
$n = 2k+1$ for $k = 0,1,2,3$ and our quadratics become:
$x^2 - 2\cos(\frac{(2k+1)\pi}{8})x + 1$
so that:
[math]x^8 + 1 = \prod_{k = 0}^3 [x^2 - 2\cos\left(\frac{(2k+1)\pi}{8}\right)x + 1][/math]
In other words, it's not the product of $(x^2 - a_k^2)$ like you had, but instead the product of:
$(x - a_k)(x - \overline{a_k})$