Prove that $\sum\limits_{k=0}^{n-1}\dfrac{1}{\cos^2\frac{\pi k}{n}}=n^2$ for odd $n$ In old popular science magazine for school students I've seen problem

Prove that $\quad $
  $\dfrac{1}{\cos^2 20^\circ} + 
\dfrac{1}{\cos^2 40^\circ} + 
\dfrac{1}{\cos^2 60^\circ} + 
\dfrac{1}{\cos^2 80^\circ} = 40. $

How to prove more general identity:
$$
\begin{array}{|c|}
\hline \\
\sum\limits_{k=0}^{n-1}\dfrac{1}{\cos^2\frac{\pi k}{n}}=n^2 \\
\hline
\end{array}
,  \qquad \mbox{ where } \ n \ \mbox{ is odd.}$$

Whenever I see a problem like this, I think Chebyshev polynomials.
The Chebyshev polynomials of the first kind, $T_m(x)$, are defined so that:
$$T_m(\cos \theta) = \cos m\theta$$
$T_m$ is an $m$th degree polynomial, and the roots of $T_m(x)-1$ are exactly $\cos 2\pi k/m$ for $k=0,1,\dots,m-1$.
When $m=2n$ is even, we can write $$T_{2n}(x)=1+C\prod_{k=0}^{n-1}\left(x^2-\cos^2\frac{k\pi}{n}\right)$$ for some constant $C$. The occurrence of those $\cos^2\frac{k\pi}{n}$ suggested this might be a good approach.
Now, given a polynomial $p(x)=a_mx^m + a_{m-1}x^{m-1}\dots +a_0$, with non-zero roots $r_0,\dots, r_{m-1}$, we have formulas:
$$\sum \frac{1}{r_k} = -\frac{a_1}{a_0}$$
And:
$$\sum_{i< j} \frac{1}{r_ir_j} = \frac{a_2}{a_0}$$
So $$\sum \frac{1}{r_k^2} = \left(-\frac{a_1}{a_0}\right)^2 - 2\frac{a_2}{a_0}$$
Now let $p(x)=T_{2n}(x)-1$. The roots of $p$ are $r_k=\cos \frac{k\pi}{n}$ for $k=0,\dots,2n-1$, and the roots are non-zero since $n$ is odd. We know that $p(x)$ is even, so $a_1=0$. Finally, we know that $\sum_{k=0}^{2n-1} \frac{1}{r_k}^2$ is twice the sum that you are looking for.
So your sum is now reduced to finding $-\frac{a_2}{a_0}$ where the $a_0,a_2$ are coefficients of $p(x)$. Since $p(0)=T_{2n}(\cos \pi/2)-1 = \cos n\pi - 1 = -2$, so we know that $a_0=-2$. So $\sum r_k^{-2} = a_2$. (Again, we use $n$ odd here.)
So we need to prove that $a_2=2n^2$.
Now, $a_2=\frac{1}{2}T_{2n}^{''}(0)$. Let $f(x)=\cos 2nx = T_{2n}(\cos x)$. Differentiating we get:
$$-2n\sin 2nx = -T_{2n}^{'}(\cos x)\sin x$$
Differentiating both sides again:
$$-4n^2\cos 2nx = T_{2n}^{''}(\cos x)(\sin^2 x) - T_{2n}^{'}(\cos x)\cos x$$
Putting in $x=\pi/2$, then $\cos x=0$, $\sin x=1$, and $\cos 2nx=-1$. Therefore, we get $$4n^2 = T_n^{''}(0)\\a_n=\frac{1}{2}T_{2n}^{''}(0)=2n^2$$
and therefore your sum is $n^2$.

Note: Any symmetric rational function with rational coefficients of $\{\cos 2\pi k/n\mid k=0,\dots,n-1\}$ will be rational by this argument.
