Proving $\frac{1}{\cos^2\frac{\pi}{7}}+ \frac {1}{\cos^2\frac {2\pi}{7}}+\frac {1}{\cos^2\frac {3\pi}{7}} = 24$ Someone gave me the following problem, and using a calculator I managed to find the answer to be $24$.

Calculate $$\frac {1}{\cos^2\frac{\pi}{7}}+ \frac{1}{\cos^2\frac{2\pi}{7}}+\frac {1}{\cos^2\frac{3\pi}{7}}\,.$$

The only question left is, Why? I've tried using Euler's Identity, using a heptagon with Law of Cosine w/ Ptolemy's, etc. but the fact that the cosine values are all squared and in the denominator keeps getting me stuck.
If $\zeta=e^{\frac{2\pi i}{7}}$, then the required expression is
$$4\left(\frac{\zeta^2}{(\zeta+1)^2}+\frac{\zeta^4}{(\zeta^2+1)^2}+\frac{\zeta^6}{(\zeta^3+1)^2}\right).$$
How do we simplify this result further?

First notice that since $\cos(x)=\cos(\pi-x)$, we have
$$1+2\left(\frac{1}{\cos(\frac{\pi}{7})^2}+\frac{1}{\cos(\frac{2\pi}{7})^2}+\frac{1}{\cos(\frac{3\pi}{7})^2}\right)=\sum_{k=0}^6 \frac{1}{\cos(\frac{k\pi}{7})^2}$$
Now, $x\mapsto 2x$ is a bijection of the integers mod $7$, so we may make the summands $\cos(\frac{2\pi k}{7})^{-2}$.
Using $\cos(\frac{2\pi k}{n})=(\zeta^k+\zeta^{-k})/2$ where $\zeta=e^{2\pi i/n}$ combined with the geometric sum formula
$$\frac{a^n+b^n}{a+b}=\sum_{r=0}^{n-1} a^{(n-1)-r}b^r,$$
and the fact that for $n$th roots of unity $\xi$,
$$\sum_{k=0}^{n-1} \xi^k =\begin{cases} n & \xi=1 \\ 0 & \xi\ne1 \end{cases} $$
we may derive
$$\sum_{k=0}^{n-1}\frac{1}{\cos(\frac{2\pi k}{n})^m}=\sum_k \left(\frac{2}{\zeta^k+\zeta^{-k}}\right)^m=\sum_k \left(\frac{\zeta^{nk}+\zeta^{-nk}}{\zeta^k+\zeta^{-k}}\right)^m $$
$$=\sum_k\left(\sum_{r=0}^{n-1}(-1)^r \zeta^{-(2r+1)k}\right)^m=\sum_k \sum_{\substack{r_1,\cdots,r_m \\ \sum r_i=r}}(-1)^r\zeta^{-(2r+m)k}$$ 
$$ =\sum_{\substack{r_1,\cdots,r_m \\ \sum r_i=r}} (-1)^r \sum_k (\zeta^{-2r-m})^k=n(A-B).$$
Therefore in conclusion we have
Theorem.
$$\sum_{k=0}^{n-1} \frac{1}{\cos(\frac{2\pi k}{n})^m}=n(A-B)$$
where $A$ and $B$ count the solutions to $r_1+\cdots+r_m\equiv -m/2$ mod $n$ with $\sum_i r_i$ even and odd respectively (and $0\le r_1,\cdots,r_m<n$). 
As a special case, if $m=2$ we see that $A=n$ and $B=0$, yielding the corollary
$$\sum_{k=0}^{n-1}\frac{1}{\cos(\frac{2\pi k}{n})^2}=n^2.$$
