TITLE: Why the integral of $\frac{1}{z}$ over a closed curve is not $0$.
QUESTION [5 upvotes]: Consider the path $\gamma: [0,2\pi]\rightarrow \mathbb{C}$ given by $\gamma(t) = e^{it}$.
Let $f(z) = \frac{1}{z}, z\neq 0$.
I worked out the integral $$\int_\gamma f = \int_{0}^{2\pi} f(\gamma(t))\gamma'(t) dt = 2\pi i$$
However, $f$ is continuous on $f(\gamma([0,2\pi]))$, so I was wondering why this integral is nonzero, since I thought that the integral over a  closed path that takes $[a,b] \rightarrow G$, where $f$ is continous on $G$ and $f$ has a primitive on $G$ should be $0$. What is going wrong here?

REPLY [3 votes]: The following is a fundamental result in complex analysis (see the books of Ahlfors or Rudin).

Theorem. Let $f$ be a holomorphic function on a region $\Omega$; then $f$ has an antiderivative on $\Omega$ if and only if
  $$
\int_\gamma f(z)\,dz=0
$$
  for every closed path in $\Omega$.

(A region is an open and connected subset of the complex plane).
Since the integral you're considering is not zero, it follows that $1/z$ has no antiderivative on a region $\Omega$ that contains a circle centered at $0$, because the integral over this circle is $2\pi i\ne 0$.

It is also well known and basic in complex analysis that the integral of a holomorphic function on a contractible path is zero, so the result follows that a holomorphic function defined on a simply connected region has an antiderivative. So, for instance, $1/z$ does have an antiderivative on a region obtained from the complex plane by removing a ray with origin at $0$ (the main branch cut of the complex logarithm is defined as the antiderivative of $1/z$ over the region obtained by removing the nonpositive real numbers).
On the other hand, simple connectedness is only a sufficient condition; for example, the function $1/z^2$ has an antiderivative on $\mathbb{C}\setminus\{0\}$, which is a non simply connected region.