<s>[INST] 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.}$$
 [/INST] From this answer we know that
$$
\sum\limits_{k=1}^{m}\tan^2\frac{\pi k}{2m+1}=m(2m+1)
$$
Similarly
$$
\sum\limits_{k=m+1}^{2m}\tan^2\frac{\pi k}{2m+1}=
\sum\limits_{l=1}^{m}\tan^2\frac{\pi (2m+1-l)}{2m+1}=
\sum\limits_{l=1}^{m}\tan^2\frac{\pi l}{2m+1}=m(2m+1)
$$
Since $\cos^{-2}\alpha=1+\tan^2\alpha$, then
$$
\begin{align}
\sum\limits_{k=0}^{2m}\frac{1}{\cos^2\frac{\pi k}{2m+1}}
&=\sum\limits_{k=0}^{2m} 1 +\sum\limits_{k=0}^{2m}\tan^2\frac{\pi k}{2m+1}\\
&=2m+1+\sum\limits_{k=1}^{m}\tan^2\frac{\pi k}{2m+1}+\sum\limits_{k=m+1}^{2m}\tan^2\frac{\pi k}{2m+1}\\
&=2m+1+m(2m+1)+m(2m+1)=(2m+1)^2
\end{align}
$$
</s>