Determine the integral of the function $f(z)=\tan z$ Determine the integral of the function $f(z)=\tan z$ around a contour that is a rectangle extending from $0$ to $2 \pi$ in the real direction and from $-0.5i$ to $0.5i$  in the imaginary direction. $$ $$ How to find the rectagle ? Here $-0.5i \leq y \leq 0.5i$  and $z=0 $ implies $\tan0=0.$
So $x$ starts from $0$. But what is the upper limit of $x$ in order to find the rectangle?  Please help me, I got stuck here.
 A: If you want to do this the "primitive way." Which it sort of sounds like you might.
Then you break the perimeter of the rectangle into 4 lines, and evaluate the 4 line integrals.
e.g.
starting at $(0, -0.5 i)$ working counter clockwise
$$z = x+iy = t - 0.5i\\
dz = dt$$
$$\int_0^{2\pi} \tan(t-0.5i) \ dt$$
$$(2\pi, -0.5 i) \text{ to } (2\pi, 0.5i)$$
$$z = 2\pi + it\\
dz = i\ dt$$
$$\int_{-0.5}^{0.5} i\tan (2\pi + it)\ dt$$
etc. until you have done all four contours.
If you have learned the Cauchy integral formula/ residue formula, then you know that can evaluate the contour integral by evaluating the places where the function fails to be analytic. 
A: Your comment under the question says polar coordinates are involved. But they are not. The question as phrased refers to "the real direction" and "the imaginary direction". In the way in which the complex plane is usually represented graphically, those correspond to horizontal and vertical lines. So this is in Cartesian coordinates.
You wrote about the "rectangle extending from $0$ to $2\pi$ in the real direction and from $−0.5i$ to $0.5i$ in the imaginary direction". That means $0$ to $2\pi$ on the $x$-axis (the horizontal axis -- no polar coordinates are involved), and from $-1/2$ to $+1/2$ on the $y$-axis.
Now recall from trigonometry that the tangent function has poles at $\pi/2$ and $3\pi/2,$ and since the function is periodic with period $\pi,$ the residues are the same at both poles.
A contour running once around the rectangle encircles both poles once.
We have $\cot \dfrac\pi 2 = 0$ and $\cot'\dfrac\pi2 = -1$, and therefore
$$
\cot z = -1\left( z - \frac \pi 2\right) + (\text{something})\cdot\left( z - \frac \pi 2\right)^2 + (\text{something})\cdot\left( z - \frac \pi 2\right)^3 + \cdots.
$$
Consequently
$$
\tan z = \frac{-1}{\left( z-\frac\pi2 \right)} + \text{terms not contributing to the residue}.
$$
So the integral of this function along a contour that winds once counterclockwise around the point $\pi/2$ is $-2\pi i$ and the integral along a contour that winds once around each of two such points is $2$ times that.
