$\int_{0}^{2\pi}\exp(ik\theta)d\theta$ where $k \neq 0$ is an integer with path integration. I am trying to solve $$\int_{0}^{2\pi}\exp(ik\theta)d\theta$$ where $k$ is nonzero integer.
I know the answer would be $0$, but I want to try it with path integration to understand the path integration better. So, I would like to share my path integration answer and hope I can get some corrections (if there are any) since I am very new to it.
Let a path $\gamma :[0,2\pi]\rightarrow \mathbb{C} $ s.t $\gamma (t)=\exp(\frac{ikt}{2})$ where $k$ is nonzero integer.
Then, since $\exp$ function is holomorphic, $\gamma '(t)=\frac{ik}{2}\exp(\frac{ikt}{2})$.
Now, consider $\int_{\gamma }z \, dz$.
By definition of the path integration,
$$\int_{\gamma }z \, dz=\int_{0}^{2\pi}\exp(\frac{ikt}{2})\cdot \frac{ik}{2}\exp(\frac{ikt}{2})dt \\ =\frac{ik}{2}\int_{0}^{2\pi}\exp(ikt)\, dt \\ = \frac{ik}{2}\cdot \frac{1}{ik}\left [ \exp(ikt) \right ]_{0}^{2\pi} \\ = \frac{1}{2}\left ( \exp(i(2\pi k))-\exp(0) \right ) \\ = \frac{1}{2}(1-1)=0 $$
Thus, $\int_{0}^{2\pi}\exp(ik\theta)d\theta=0$ for any nonzero integer $k$.
Did I use the path integration correctly?
Did I set the path correctly?
Furthermore, if we don't want to use the path integration, is it safe to use the fact $\exp$ functions have primitive (like we normally do for the real exponential functions)? Aren't there any restrictions like the Log functions do?
I'm kind of confused, so I want to make sure I have no confusion before I get deeper into the complex integration.
 A: It seems like your intention was to use a contour integral to evaluate a standard integral, but instead you used a standard integral to evaluate a contour integral. Alternately, you might set $\gamma(\theta)=e^{ik\theta}$ for $\theta\in [0,2\pi]$ and then
$$
\int_0^{2\pi} e^{i k \theta} d \theta=\int_{\gamma} \frac{dz}{ik}=0,
$$
since $\gamma$ is a closed path and $\frac{1}{ik}$ is entire.
A: Do the following substitution:
$$e^{i\theta} = z$$
$$ d\theta = \frac{dz}{zi}$$
Your integral is now a contour integral round the unit complex circle taken in the positive sense:
$$\int_{0}^{2\pi}\exp(ik\theta)d\theta = \frac{1}{i}\oint_{|z|=1} z^{k-1} dz $$
Note that if $k\geq 1$ the function $g(z) = z^{k-1}$ is analyitic in the contour and inside the contour. Then
$$\int_{0}^{2\pi}\exp(ik\theta)d\theta = \oint_{|z|=1} z^{k-1} dz =0 \textrm{ if } k>1$$
If $k<1$, denote $k-1=-r$, we have
$$\int_{0}^{2\pi}\exp(ik\theta)d\theta = \frac{1}{i} \oint_{|z|=1}  \frac{1}{z^r} dz  \textrm{ if }\; k<1 \; (r>0)$$
Now you have a singularity at $z=0$.
Recall the Cauchy integral formula:
Let $f$ be analytic on the region $A$ and let $\gamma$ be closed curve in $A$, homotopic to a point. Let $z_{0}\in A$ be a point inside $\gamma$. Then
$$ f(z_{0}) = \frac{1}{2\pi i} \oint_{\gamma} \frac{f(z)}{z-z_{0}} dz $$
And its extension for derivatives:
If $f$ is analytic on $\mathbb{C}\setminus\gamma$ in fact, $f$ is infinitely differentiable with the $k$th derivative given by
$$f^{(k)}(z) = \frac{k!}{2\pi i} \int_{\gamma} \frac{f(\zeta)}{(\zeta - z)^{k+1}} d\zeta$$
Then with $f(\zeta) = 1$ and $z = 0$ ie easy to see that  $f^{(r)} (\zeta) =0$ for $k<1$. Hence
$$\int_{0}^{2\pi}\exp(ik\theta)d\theta = \frac{1}{i}\oint_{|\zeta|=1}  \frac{1}{\zeta^r} d\zeta =  \frac{1}{i}\oint_{|\zeta|=1} \zeta^{k-1} d\zeta = 0 \textrm{ if } k<1$$
