Application of the residue theorem I want to prove that
$$\sum_{j=1}^n \frac{1}{\left[\text{cos} \left( \frac{j \pi}{2n+1} \right)\right]^4}=\frac{8n(n+1)(n^2+n+1)}{3}$$
for $n \in \mathbb{N}$ by using the residue theorem. 
Which meromorphic function $f$ should I use to get the suitable residue?
 A: Here are the details for my comment above. 
Let us take 
$$f(z)=\frac{z}{(z+1)^4(z^{2n+1}-1)}$$
There is a pole of order $4$ at $z=-1$, and simple poles at the $2n+1$'th roots of unity. 
The sum of all residues is $0$. (There is no residue at $z=\infty$ as $f(z)\sim z^{-(4+2n)}$ for large $z$; alternatively, if you don't like residues at infinity, integrate $f$ over a large circle centered at $0$, and notice that the integral goes to $0$ as the radius goes to $\infty$.)
If $w^{2n+1}=1$, i.e. $z=w$ is a simple pole, then
$$Res_{z=w}f(z)=\frac{1}{2n+1}\frac{w^2}{(w+1)^4};$$
if $w=\exp(2\pi i j/(2n+1))$ ($j$ runs from $0$ to $2n$) this means
$$Res_{z=w}f(z)=\frac{1}{2n+1}\frac{1}{(2\cos\pi j/(2n+1))^4}.$$
Notice that the sum of these residues is $2\times 2^{-4}/(2n+1)$ times the LHS ($j$ runs from $1$ to $2n$) plus ($j=0$) $2^{-4}/(2n+1)$.
The last residue is at $z=-1$ and is $\frac{g^{(3)}}{3!}|_{z=-1}$ where $g(z)=\frac{z}{(z^{2n+1}-1)}=(z+1)^4f(z)$. It should be straightforward to compute, but I'm scared of doing so, and I asked Wolfram Alpha to do so (thank Random Variable). The result is
$$Res_{z=-1}f(z)=-(8n^3+12n^2+10n+3)/48.$$
The sum of all the residues of $f$ is $0$, and it does, indeed, give the result you want.
