Summation problem with trigonometric identities Find the sum $\displaystyle \sum_{k = 1}^{2004}\dfrac1{1+\tan^2 \left(\dfrac{k\pi}{2\cdot 2005}\right)}. $
I was able to simplify this to $ \displaystyle\sum_{k = 1}^{2004} {\cos^2\left(\frac{k\pi}{4010}\right)} $, however, from there I was unsure how to solve the problem. How would you continue?
Thank you.
 A: Let $S=\sum_{n=1}^{n=2004}\cos^2(\frac{k\pi}{4010})$. Then 
$2S-2004=\sum_{n=1}^{n=2004}\cos(\frac{k\pi}{2005})$. Therefore
$2S-2004=\cos(\frac{\pi}{2005})+\cos\frac{2\pi}{2005}+\cos\frac{3\pi}{2005}+...+\cos\frac{2004\pi}{2005}$ which is equal to $0$ because for example, $\cos\frac{\pi}{2005}=-\cos\frac{2004\pi}{2005}$ and this can be done for the other terms pariwise. Hence 
$2S-2004=0$ or $S=1002$.
These two formulas are used:
1) $\cos(2x)=2\cos^2(x)-1.$
2)$cos(\pi -\alpha)=-cos(\alpha).$
A: Generalization:
Using $\displaystyle\cos2A=2\cos^2A-1,  \displaystyle\cos^2\left(\frac{k\pi}{2m}\right)=\frac{1+\cos\left(\frac{k\pi}m\right)}2 $
$\displaystyle\sum_{k=1}^{m-1}\cos^2\left(\frac{k\pi}{2m}\right)=\sum_{k=1}^{m-1}\frac{1+\cos\left(\frac{k\pi}m\right)}2 =\sum_{k=1}^{m-1}\frac12+\frac12\cdot\sum_{k=1}^{m-1}\cos\left(\frac{k\pi}m\right)=\frac{m-1}2+\frac S2$
Using $\sum \cos$ when angles are in arithmetic progression,
$\displaystyle\alpha=\beta\implies\sum_{k=1}^{m-1}\cos(k\alpha)=\frac{\cos\frac{m\beta}2\sin\frac{(m-1)\beta}2}{\sin\frac{\beta}2}$
$\displaystyle\beta=\frac\pi m\implies S=\sum_{k=1}^{m-1}\cos\left(\frac{k\pi}m\right)=\frac{\cos\frac\pi2\sin\frac{(m-1)\pi}{2m}}{\sin\frac\pi{2m}}=0$
