Integral of complex function Consider the integral $\int_C \frac{1}{z} dz$ where $C:z(t)=\sin(t)+i\cos(t)$ on the interval $ 0 \leq t \leq 2\pi$.
I applied the definition of a line integral and got:
$$
\int_0^{2\pi} \frac{1}{\sin(t)+i\cos(t)}(\cos(t)-i\sin(t))dt
$$
However, I got two different answers when doing this in two different ways:
If I do the substitution $ u=\sin(t)+i\cos(t) $ and $ du = cos(t)-i\sin(t) $, I get:
$$
\int \frac{1}{u} du = \ln(\sin(t)+i\cos(t))+C
$$
Plugging in the limits of integration yields $ \ln(i) - \ln(i) = 0 $ which is incorrect.
Doing the integral by either using the Cauchy integral formula or by simplifying the integrand to $ -i $ yields the correct answer of $ -2\pi i $.
Where does this inconsistency come from?
 A: I'll write everything in exponential form for clarification.
$$
z(t)=\sin(t)+i\cos(t)=i(\cos(t)-i\sin(t))=e^{i\frac{\pi}2}e^{-it}=e^{i(\frac{\pi}2-t)}
$$
Since $dz=-ie^{i(\frac{\pi}2-t)}dt\ $ your integral becomes :
$$
-\int_0^{2\pi} e^{-i(\frac{\pi}2-t)}ie^{i(\frac{\pi}2-t)}dt=-\int_0^{2\pi} i\  dt=-2\pi i
$$
This is the wished answer so let's compare that to your derivation (neglecting the unimportant constant $C$) :
$$
\int \frac1u du = \ln\left(\sin(t)+i\cos(t)\right)=\ln(i(\cos(t)-i\sin(t))=\ln\left(e^{i(\frac{\pi}2-t)}\right)=i\left(\frac{\pi}2-t\right)
$$
The value of this at $2\pi$ minus the value at $0$ is again $-2\pi i$ as wished.
So where was the trouble in your case?
You had to subtract $\ln\left(e^{i(\frac{\pi}2-2\pi)}\right)$ and $\ln\left(e^{i(\frac{\pi}2-0)}\right)$ and got $0$.
This illustration of the Riemann surface of the logarithm function (from Wikipedia) 

may clarify things : you made a full turn around the vertical axis (the exponential made you 'turn' of $2\pi$). During this the logarithm progressed of $2\pi i$ (in height). The problem in your evaluation is that the phase information got lost after a full turn! $e^{2\pi i}$ seems equal to  $e^{0 i}$ but it isn't as seen by applying the logarithms on both terms! You may object that $e^{2\pi i}$ is equal to $e^{0 i}$ and that's true but it is too equal to any $e^{2\pi k i}$ for $k\in\mathrm{Z}$ so when asked for $\log(e^{2\pi k i})$ which one have we to choose? The answer is "the one that is the nearest to the last computed one!" and that's the point of staying on the same 'branch' and of analytic continuation (see the picture!).
For more details you may read the Wikipedia article previously linked.
A: Short answer: Your two evaluations of $\ln i$ are connected by a path going once around the origin, leaving you on a different branch of the natural log function, with the value being changed by $2\pi i$. The point being that the log function is not single valued.
The long answer is perhaps too long to fit here, and involves analytic continuations (you might look it up).
