How to integrate around a square I am trying to calculate the complex line integral of $f(z)=z^{-1}$ around the square of sides 2, centred at the origin counter clock wise. I know I cant use Cauchy theorem because of the singularity.
I thought maybe since f is holomorphic I could use the fundamental theorem, but then even nif my $F(z)=ln(z)$ I don't know what to use as my endpoints. I tried breaking it up into parts, ie end points at $1+i$ , $-1+i$, $-1-i$ and $1-i$, but when I compute using FTC that gives me 0. However, the correct answer I am told is $i2\pi$ ,
by the way , I also know that i2pi is the result of doing this integration but around a circle of radius irrelevant, maybe that could tie in somehow? I am looking for help. Thanks
 A: It's actually a good example of getting confused by parameterising curves, specifically the direction of your parameterisation. I tried to take shortcuts and got a result of zero as well, so I made the same mistake.
Let $C_{\pm}$ denote the vertical paths where $\mathfrak{R}(z) = \pm 1$. Then $z = \pm1 + t\mathrm{i}$, where $t \in [-1,1]$, then $\mathrm{d}z = \mathrm{i} \,\mathrm{d}t$ and
$$ f(z) = z^{-1} = \frac{1}{\pm1+t\mathrm{i}} = \frac{\pm1-t\mathrm{i}}{1+t^2}.$$
Integration gives
$$
\int_{C_{\pm}} f(z) \ \mathrm{d}z = \int_{-1}^1 \frac{\pm \mathrm{i}}{1+t^2} + \frac{t} {1+t^2} \ \mathrm{d}t = \pm\frac{\pi}{2}\mathrm{i} + 0.
$$
Let $\Gamma_{\pm}$ denote the horizontal paths where $\mathfrak{I}(z) = \pm 1$. Then $z = t \pm\mathrm{i}$, where $t \in [-1,1]$, then $\mathrm{d}z =  \mathrm{d}t$ and
$$ f(z) = z^{-1} = \frac{1}{t \pm\mathrm{i}} = \frac{t \mp \mathrm{i}}{t^2 + 1}.$$
Integration gives
$$
\int_{\Gamma_{\pm}} f(z) \ \mathrm{d}z = \int_{-1}^1 \frac{t}{1+t^2} \mp \frac{\mathrm{i}} {1+t^2} \ \mathrm{d}t = 0\mp\frac{\pi}{2}\mathrm{i}.
$$
So far it does look like all these contributions cancel. However, note that going counter clockwise around the square, some of our parameterisations are around the wrong way.
Our integral is actually 
$$
\int_{C_{+}} - \int_{\Gamma_{+}} - \int_{C_{-}} + \int_{\Gamma_{-}} = \frac{\pi}{2}\mathrm{i} - \left(-\frac{\pi}{2}\mathrm{i} \right)- \left(-\frac{\pi}{2}\mathrm{i} \right)+\frac{\pi}{2}\mathrm{i} = 2\pi \mathrm{i}.
$$
A: 
METHODOLOGY $1$:  Brute force valuation

Note that we can write
$$\begin{align}
\oint_C \frac{1}{z}\,dz&=\int_{-1}^1 \frac{1}{t-i}\,dt+\int_{-1}^1 \frac{i}{it+1}\,dt-\int_{-1}^1 \frac{1}{t+i}\,dt-\int_{-1}^1 \frac{i}{it-1}\,dt\\\\
&=4i\int_{-1}^1 \frac{1}{t^2+1}\,dt\\\\
&=4i \left.\left(\arctan(t)\right)\right|_{-1}^1\\\\
&=2\pi i
\end{align}$$
as was to be shown.


METHODOLOGY $2$:  General Development

In THIS ANSWER, I showed that for any rectifiable curve $\gamma \in \mathbb{C}\setminus\{0\}$ from $1$ to $z$  
$$\int_\gamma \frac{1}{z}\,dz=\log(r)+i(\theta +2k\pi) \tag 1$$
where $r=|z|$, $\theta =\arg (z)\in [0,2\pi)$ and $k$ is equal to the net number of times that $\gamma$ crosses the positive real axis from the fourth quadrant to the first one.
Applying $(1)$ to the case for which $\gamma$ is the contour of interest, we see that $z=1$, $\theta =2\pi$, and $k=0$ so that  
$$\int_\gamma \frac{1}{z}\,dz=2\pi i$$
