TITLE: Complex integral - winding number
QUESTION [5 upvotes]: i want to find $$\frac{1}{2\pi i}\int _\gamma \frac{1}{z}dz$$
well $0$'s winding number is $2$, so $\frac{1}{2\pi i}\int _\gamma \frac{1}{z}dz=2$
but when I explicity calculate the integral I get
$$\frac{1}{2\pi i}\int _\gamma \frac{1}{z}dz=\frac{1}{2\pi i}(\log(z)\lvert ^{z=-1}_{z=3}+\log(z)\lvert ^{z=\sqrt 2}_{z=-1}+\log(z)\lvert ^{z=-\sqrt 5}_{z=\sqrt 2}+\log(z)\lvert ^{z=3}_{z=-\sqrt 5})=\\ \frac{1}{2\pi i}(\log |-1|+i\pi-\log 3+\log \sqrt 2 -\log |-1|-i\pi+\log |-\sqrt 5|+i\pi-\log \sqrt 2  +\\+\log 3-\log |-\sqrt 5|-i\pi)=0$$
whats going on here?

REPLY [3 votes]: An exaggerated idea to try to understand a little more that branch cut thingy of the logarithmic function: let us try to divide the given path in several semicircles, say
$$\begin{align*}\gamma_1&:=\{z\in\Bbb C\;;\;|z-1|=2\;,\;\;\text{Im}\,(z)\ge 0\}\\
\gamma_2:&=\left\{z\in\Bbb C\;;\;\left|z-\frac{\sqrt2 -1}2\right|=(\sqrt2-1)^2\;,\;\;\text{Im}\,(z)\le 0\right\}\\
\gamma_3&:=\left\{z\in\Bbb C\;;\;\left|z-\frac{\sqrt2-\sqrt5}2\right|=(\sqrt2-\sqrt5)^2\;,\;\;\text{Im}\,(z)\ge 0\right\}\\
\gamma_3&:=\left\{z\in\Bbb C\;;\;\left|z-\frac{3-\sqrt5}2\right|=(3-\sqrt5)^2\;,\;\;\text{Im}\,(z)\le 0\right\}\end{align*}$$
Now, in each and every case we get
$$\int\frac{dz}z=\text{Log}\,z$$
which makies things pretty simple...but with a catch, as you've been already explained: every time the (complex) logarithm completes a whole "spin" around zero we must add (or substract, depending on the spinning direction) $\,2\pi\,$ to its argument, so (Note: Log denotes the complex logaithm, log the real one):
$$\begin{align*}\int\limits_{\gamma_1}\frac{dz}z&=\text{Log}\,(-1)-\text{Log}\,3=\pi i-\color{red}{\log 3}\\
\int\limits_{\gamma_2}\frac{dz}z&=\text{Log}\,\sqrt2-\text{Log}\,(-1)=\frac12\log2+2\pi i-\pi i=\color{green}{\frac12\log2}+\pi i\\
\int\limits_{\gamma_3}\frac{dz}z&=\text{Log}\,(-\sqrt5)-\text{Log}\,\sqrt2=\frac12\log5+3\pi i-\frac12\log2-2\pi i=\color{blue}{\frac12\log5}-\color{green}{\frac12\log2}+\pi i\\
\int\limits_{\gamma_4}\frac{dz}z&=\text{Log}\,3-\text{Log}\,(-\sqrt5)=\log3+4\pi i-\frac12\log5-3\pi i=\color{red}{\log3}-\color{blue}{\frac12\log5}+\pi i\end{align*}$$
Now add all the above and you get, of course, $\,4\pi i\,$ ...