Computing $\cos\frac{\pi}{7}$ Assume the heptagon below is regular.
Each of the angles marked with red below is $\frac{\pi}{7}$. Troughout this question I will use $\gamma$ to mark $\cos\frac{\pi}{7}$. By the cosine law we have $b = 2 a \gamma$, $c = \frac{a}{\sqrt{2(1-\gamma)}}$ and $a^2 = b^2+c^2-2bc\gamma$. If we replace $b$ and $c$ with the expressions in terms of $a$ and $\gamma$ in the third equation we derive an equation in terms of $a$ and $\gamma$ only. So to compute $\gamma$ all we have to do is solve that equation correct? But observe the results given by Mathematica:

None of the real solutions to the equation gives the correct value of $\cos\frac{\pi}{7}$ so my question is why doesn't this method produce the value of $\cos\frac{\pi}{7}$ ?
 A: I'm unsure as to why Solve[] is failing here, but using NSolve[] appeared to work:
c = a/Sqrt[2 (1 - g)];
b = 2 a g;
NSolve[a^2 == b^2 + c^2 - 2 b c g, g]

This returned
{{g -> -0.62349}, {g -> 0.5}, {g -> 0.809017}, {g -> 0.900969}

where $\cos \frac\pi7\approx 0.900969$
The two complex answers that Solve[] returned for you have a rather small imaginary part... on the order of $10^{-17}$. Perhaps this is floating point error? I'm unsure how Mathematica does this computation, but you might be best off asking on their Exchange. The first of the complex answers appears to be the one you're seeking:
N[1/6 (1 + 7^(2/3)/(1/2 (-1 + 3 I Sqrt[3]))^(
1/3) + (7/2 (-1 + 3 I Sqrt[3]))^(1/3))]

0.900969 + 3.70074*10^-17 I

A: The values given by Mathematica are correct, as some comments point out.  The third one in the list is a radical form for $cos(\pi/7)$. Such trigonometric radicals involve complex arguments unless the denominator in the argument corresponds to a power of 2 times zero or more distinct Fermat primes.
The equation itself has an interesting property.  If we eliminate $a, b, c$ and clear radicals and fractions we get a sixth degree polynomial equation, yet numerical methods find only four roots.  The two missing roots are those for which the $2bc\gamma$ term has the reversed sign.  When $a, b, c$ are eliminated, that last term still contains a square root, which is responsible for the sign reversal.
A list of all six roots, each with the sign appearing before the last term:
$cos(\pi/3)=1/2, -$ (the given sign)
$cos(\pi/5)=(\sqrt{5}+1)/4, -$
$cos(3\pi/5)=(-\sqrt{5}+1)/4, +$ (the reversed sign)
$cos(\pi/7), -$
$cos(3\pi/7), +$
$cos(5\pi/7), -$
