What is the residue for this function How to find the residue of $\dfrac{1}{\tan(z)}$? I have calculated that it has a pole of order 2 . But I'm having trouble when using the residue theorem and I end up with a residue of $2$. However, wolfram alpha calculator says that the residue=$0$. 
 A: Using the residue formula we get
$$\begin{align*}\operatorname{Res}(f,\pi)&=\lim_{z\to\pi}\frac{d}{dz}\left((z-\pi)^2 f(z)\right) \\ &=\lim_{z\to\pi}\frac{2\pi-2z}{\cos z+1}+\frac{-\sin z(z-\pi)^2}{(\cos z+1)^2} \\ &=\lim_{z\to\pi}\frac{(2\pi-2z)(\cos z+1)-\sin z(z-\pi)^2}{(\cos z+1)^2}\end{align*}$$
Substituting $x=z-\pi$ and using $\cos x\sim 1$ and $\sin x\sim x$ near zero, we get:
$$\operatorname{Res}(f,\pi)=\lim_{x\to 0}\frac{2x(\cos x+1)+x\sin x}{(\cos x+1)^2}\lim_{x\to 0}\frac{4x+x^2}{4}=\color{red}0$$
as desired.
A: Since\begin{align}\frac{-1}{\cos(z)+1}&=\frac{-1}{\cos\bigl((z-\pi)+\pi\bigr)+1}\\&=\frac1{1-\cos(z-\pi)}\\&=\frac1{\frac{(z-\pi)^2}{2!}-\frac{(z-\pi)^4}{4!}+\cdots}\\&=\frac2{(z-\pi)^2}\cdot\frac1{1-\frac{(z-\pi)^2}{3\times4}+\cdots}\end{align}Since there are only powers of $z-\pi$ with even exponents, the Laurent series of $\frac{-1}{\cos(z)+1}$ at $0$ only has even exponents too, and therefor the residue is $0$. 
A: Since, $ 1 + \cos z = 2\cos^2 \frac{z}{2} $, the function has second-order poles at $\frac{z}{2} = (n + \frac12)\pi$ or $z = (2n+1)\pi$
Let $w = z - (2n+1)\pi$, we can compute the residues 
$$ \begin{align} 
\operatorname*{Res}_{z=(2n+1)\pi} f(z) &= -\frac12 \lim_{z\to (2n+1)\pi} \frac{d}{dz}\left(\big(z -
 (2n+1)\pi\big)^2\sec^2 \frac{z}{2}\right) && w = z- (2n+1)\pi \\
&= -\frac{1}{2} \lim_{w\to0} \frac{d}{dw}\left( w^2 \sec^2 \left(\frac{w + (2n+1)\pi}{2}\right)\right) && \cos(z + n\pi) = (-1)^n\cos(z) \\
&= -\frac12 \lim_{w\to0} \frac{d}{dw} \left(w^2 \sec^2 \left( \frac{w+\pi}{2} \right)\right) && \cos(z+\pi/2) = -\sin z \\
&= -\frac12 \lim_{w\to0} \frac{d}{dw} \left(w^2 \csc^2 \frac{w}{2}\right) \\
&= -\frac12 \lim_{w\to0} \left(2w\csc^2 \frac{w}{2} - w^2\csc^2 \frac{w}{2} \cot \frac{w}{2} \right) \\
&= -\frac12 \lim_{w\to0} \frac{2w\sin \frac{w}{2} - w^2 \cos \frac{w}{2}}{\sin^3 \frac{w}{2}} \\
&= -\frac12 \lim_{w\to0} \frac{2w\left(\frac{w}{2}-\frac{w^3}{48} + O(w^5)\right) - w^2 \left(1-\frac{w^2}{8}+O(w^4)\right)}{\frac{w^3}{8} + O(w^5)} \\
&= -\frac12 \lim_{w\to0} \frac{\frac{w^4}{12} + O(w^6)}{\frac{w^3}{8} + O(w^5)} \\
&= 0
\end{align} $$
