$\tan(z)$ with residue theorem Calculate
$$\oint_{|z|=2}\tan(z)\,dz$$
because $\tan(z)=\dfrac{\sin(z)}{\cos(z)}$ the poles are when $\cos(z)=0$ 
at $z=\pm\pi/2\pm n\pi, \;n\in\mathbb{Z}$
Poles inside $|z|=2$ are $\pm\pi/2$ and are of first order. Can I know use the theorem for simple poles and just calculate the residuals
$$\operatorname{Res} \limits_{z=\pi/2} = \lim_{z\to \pi/2}(z-\pi/2)\frac{\sin(z)}{\cos(z)}$$
But I get stuck here. Hints?
OR
$$\cos (z)=1-\frac{z^2}{2!}+\frac{z^4}{4!}-\frac{z^6}{6!}\cdots $$
How do I know which coefficient to choose for the residual. Is it $1$ because the coefficient when $n=0$ is $1$ in the series? So the residuals for $\pm \pi/2$ are $1$.
So the integral is $2\pi i (1+1)=4\pi i$ ?
 A: $\lim_{z \to \pi / 2} \dfrac{z - \pi/2}{\cos z} = \lim_{z \to \pi / 2} \dfrac{1}{\dfrac{\cos z- \cos \pi /2}{z - \pi/2}} = \dfrac{1}{\cos'(\pi/2)} = -\dfrac{1}{\sin(\pi / 2)} = -1$
and $\lim_{z \to \pi / 2} \sin z = 1$
A: Try using the series representation of $sin(z)$ and $cos(z)$.
$$ sin(z) = 0.5 i^{-1}(e^{iz} - e^{-iz}) $$
$$ cos(z) = 0.5(e^{iz} + e^{-iz}) $$
Remember also the series representation of $e^{x}$
$$  e^{x} = 1 + x + (2!)^{-1}x^2 + (3!)^{-1}x^{3} +   ...$$
A: You can split up the limit into:
$$2\pi i\lim_{z\rightarrow \frac{\pi}{2}} \frac{\sin z \cdot (z-\pi/2)}{\cos z} \: = 2\pi i(\lim_{z\rightarrow \frac{\pi}{2}} \sin z) (\lim_{z\rightarrow \frac{\pi}{2}} \frac{z - \frac{\pi}{2}}{\cos z}) =
2\pi i(\lim_{z\rightarrow \frac{\pi}{2}} \sin \frac{\pi}{2})(\lim_{z\rightarrow \frac{\pi}{2}} \frac{\frac{d}{dx}(z - \frac{\pi}{2})}{\frac{d}{dx} \cos z}) =
2\pi i (1)(\lim_{z\rightarrow \frac{\pi}{2}}(\frac{1}{\text{-} \sin z})) =
2\pi i (\frac{1}{\text{-}\sin\frac{\pi}{2}}) =
\text{-}2\pi i$$
The other residue is solved the same way and also ends up being -1 so it sums up to -4$\pi i$.
A: Let $f(z) = \tan z=(\sin z)/(\cos z)$.
cos $z = o$  when $z= ±π/2 , ±3π/2 , ±5π/2,$...
These are the poles of the function $\tan z$
Among these  the two poles $z= ±π/2$ lie inside the circle $|z| = 2$.
Residue of $f(z)$ at  $π/2 = −1$ and Residue of $f(z)$ at $−π/2  = −1$.
By the Residue Theorem, we have
the answer to be $= 2πi \text {(sum of the residues )} = 2πi(-2)=−4πi.$
