Evaluating a complex integral $\int \frac1z dz$ I know that the following complex integral
$$\int \frac1z dz$$
over the path $\frac12+e^{it}$ for $0 \le t \le 2\pi$ should give $2 \pi i$. But I get $0$ instead. Why is that?
My working so far:

*

*Substituting $z$ for $t$:

$$\int_0^{2\pi} \frac{i e^{it}}{\frac12+e^{it}} dt$$


*Using substitution of $u=\frac12 + e^{it}$:

$$\int_{\frac12+e^{i0}}^{\frac12+e^{i2\pi}} \frac1u du$$


*This integral is

$$\ln|u|$$


*Substitute back $t$ back in:

$$\ln\left|\frac12+e^{it}\right|$$


*Evaluate this between $t=2\pi$ and $t=0$ as specified earlier. $e^{2\pi i} = 1$ and $e^{0 i} = 1$ so the final answer is $\ln\frac32-\ln\frac32=0$.

Why don't I get $2 \pi i$?
Thank you.
 A: To simplify, we can talk about the same integral around the origin. I would first note that transforming $t$ to $u(t)$ where $u(t)=z(t)$ is equivalent to evaluating the original integral in terms of $z$ without transforming it.
So why can we not just take
$\oint_C \frac{1}{z}\,dz = \log(b)- \log(a)$ where $a = e^{0i}=1, b=e^{2 \pi i}=1$ and get $\log 1 - \log 1 = 0$?
The error is that in order to use the fundamental theorem for a complex function, we need to have a holomorphic antiderivative, and $\log z$ is not holomorphic- it is multivalued. A correct calculation should take that into account:
$\oint_C \frac{1}{z}\,dz = \log(e^{2 \pi i})- \log(e^{0 i}) = 2 \pi i -0 = 2 \pi i$
A: Integrating to a logarithm is tricky no matter what kind of numbers you deal with, because a difference of antiderivatives is only required to be locally constant, and there's a discontinuity at $0$.
For real $u$, $\int\frac1udu$ is $\ln u+C_+$ for $u>0$ and $\ln(-u)+C_-$ for $u<0$, where the constants $C_\pm$ are the values of a locally constant function of $u$, and can differ because of the discontinuity at $u=0$. We usually write this as $\ln|u|+C$, with $C$ the locally constant function.
For complex $u$, the topology of $u$ around $u=0$ is very different, as a path can loop around $u=0$ and smoothly vary $\operatorname{arg}u$, with a subtlety. Every now and then an argument $\in(-\pi,\,\pi]$ (or whichever length-$2\pi$ half-open interval you use) has to reset and thereby discontinuously change by $\pm\color{red}{2\pi}$, a bit like crossing the International Date Line. So$$\int\frac1udu=\ln u+C=\ln|u|+\color{blue}{i}\arg u+C$$with $C$ locally constant, but occasionally jumping by $\pm\color{red}{2\pi}$. With the definite integral in your problem, we absorb that awkward behaviour into the argument, giving$$\int_{\left\{\tfrac12+e^{it}|0\le t<2\pi\right\}}\frac1zdz=[\ln|\tfrac12+e^{it}|+\color{blue}{i}\arg(\tfrac12+e^{it})]_0^{2\pi}=\color{blue}{i}\color{red}{2\pi}.$$
A: Let $\gamma(t) = z_0 + r e^{it}$ for any $|z_0| < r$. In your case $z_0 = 1/2$, $r = 1$.
We will evaluate the integral $$
\begin{aligned} \int_\gamma \frac{d\zeta}{\zeta} &= \int_{0}^{2 \pi} \frac{\gamma'(t)}{\gamma(t)} dt\\
&= \int_0^{2 \pi} \frac{i re^{i \pi t}}{z_0 + r e^{i \pi t}} dt\\
&= \int_0^{2 \pi} i \frac{1}{1 - \left(-\frac{z_0}{r}e^{-i \pi t}\right)} dt\\
&= i \int_0^{2 \pi} \left(- \sum_{n=0}^\infty \frac{z_0}{r}e^{-i \pi t} \right)^n\\
&= i \sum_{n=0}^\infty \int_0^{2 \pi} \left(-\frac{z_0}{r}e^{-i \pi t} \right)^n\\
&= 2 i \pi
\end{aligned}
$$
because when $n=0$ you have $\int_0^{2 \pi}1 =2 \pi$ and all other terms ($n>0$) vanish because the inner term $h(z) = \left(-\frac{z_0}{r}\right)^ne^{-i \pi n t}$ has anti-derivative $H(z) = \left(-\frac{z_0}{r}\right)^n\frac{1}{-i \pi n}e^{-i \pi n t}$ and evaluating the integral using $H$ at each endpoints gives zero.
