Complex contour integration of $\oint_{C}\frac{1}{\cos z+1}dz$ I want to evaluate the following complex contour integral:
$$
J = \oint_{C}\frac{1}{\cos z+1}dz
$$
where $C: |z|=5 $
I began by finding the singularities included inside $C$. With the following limit I find that $z=\pi$ is a 2nd order pole:
$$
\lim_{z\rightarrow\pi}{(z-\pi)^{2}\cdot f(z)} = 
\lim_{z\rightarrow\pi}\frac{(z-\pi)^{2}}{\cos(z)+1} =
\lim_{z\rightarrow\pi}\frac{\frac{\mathrm{d}^{2} }{\mathrm{d} z^{2}}(z-\pi)^{2}}{\frac{\mathrm{d}^{2} }{\mathrm{d} z^{2}}(\cos(z)+1)} =
2 \neq0
$$
I am now trying to evaluate the integral using the residues theorem by which:
$$
J=2\pi iRes(f;z=\pi)
$$
The problem I'm encountering is that when trying to evaluate this residue with second order poles, I find this:
$$
Res(f;z=\pi)=
\lim_{z\rightarrow\pi}\frac{\mathrm{d} }{\mathrm{d} z}\frac{(z-\pi)^{2}}{(\cos(z)+1)} =\cdots
$$
For which I have to apply L'Hospital's rule to the limit about 4 times which is a pain to say the least but seems like it should work. Using Maple I find that the residue is equal to 0 which makes me wonder if I could have seen this all along.
My question is: Is there some theorem or some method that I'm not aware of that can be used to compute this integral? Even though manually evaluating the residues seems to work, I hardly doubt this is the way this problem was intended to be solved given that this could potentially be an exam problem.
 A: The singularities enclosed by the contour are $\pm \pi$.
The fastest way to evaluate the integral is symmetry: The integrand is even, the contour is symmetric about $0$, hence the integral is $0$.
The second fastest method is the residue theorem, using a Laurent expansion:
$$1 + \cos (\mp\pi +(z\pm\pi)) = 1 - \cos (z\pm \pi) = \frac{(z\pm\pi)^2}{2} - \frac{(z\pm\pi)^4}{4!} + \dotsc,$$
which gives the Laurent expansion
$$\frac{1}{1+\cos z} = \frac{2}{(z\pm\pi)^2} \frac{1}{1 - \frac{(z\pm\pi)^2}{12} + \dotsc} = \frac{2}{(z\pm\pi)^2}\left(1 + \frac{(z\pm\pi)^2}{12} + O((z\pm\pi)^4)\right)$$
showing that the residue is $0$ with little work.
A: After taking the derivative, you are left with a limit of $\cdots/(\cos x+1)^2$. Try multiplying and dividing by $(z-\pi)^4$ and using the limit you computed at the start (where you found that $z=\pi$ is a second order pole). Pulling out the factor $(z-\pi)^4/(\cos x+1)^2$, whose limit is $4$, you are now left with a fraction much more amenable to repeated use of L'Hôpital.
