Integral of a complex function over a circle I've got the problem. I was to compute:
$\int_0^{2 \pi} \frac{1- cos(n\phi)}{1 - cos(\phi)} d\phi$
using analytic functions methods. My attempt: I came to this:
On a unit circle, we have $z= e^{i\phi}$, where $\phi \in [0, 2\pi)$. Then, we obtain $log(z) = i \phi \Rightarrow dz = ie^{log(z)} d\phi = iz d\phi \Rightarrow d\phi = \frac{1}{iz} dz$.
So my integral is equal to (C is a unit circle):
$\int_C \frac{1}{iz} \frac{1- cos(n\frac{log,z}{i})}{1 - cos(\frac{logz}{i})} dz =  \int_C \frac{1}{iz} \frac{1- \frac{e^{nlogz} + e^{-nlogz}}{2}}{1 - \frac{e^{logz} + e^{-logz}}{2}} dz = \int_C \frac{1}{iz} \frac{1- \frac{z^n +z^{-n} }{2}}{1 - \frac{z + z^{-1}}{2}} dz = \int_C \frac{z^{-n}(z^n -1)^2}{i(z-1)^2} dz$
Here I got stuck. How to compute $\int_C \frac{z^{-n}(z^n -1)^2}{i(z-1)^2} dz$? Can you show me? I will be grateful.
 A: Hint: You now have the fraction 
$$
\frac{z^{-n}(z^n - 1)^2}{i(z-1)^2}
$$
Note, however, that $\frac{z^{n}-1}{z-1} = 1 + z + z^2 + \cdots z^{n-1}$.  Use this to simplify the above fraction to one without singularities on the unit disk.
Second hint: you now have
$$
\frac 1i \int_C \frac{(1 + z + z^2 + \cdots z^{n-1})^2}{z^n}
$$
By Cauchy's integration formula, we have
$$
\begin{align}
\frac 1i \int_C \frac{(1 + z + z^2 + \cdots z^{n-1})^2}{z^n} &=
\frac{2 \pi }{(n-1)!} \left[\frac{(n-1)!}{2 \pi i} \int_C \frac{(1 + z + z^2 + \cdots z^{n-1})^2}{z^{(n-1)+1}}\right]\\
&= \frac{2 \pi }{(n-1)!} \frac{d^{n-1}}{dz^{n-1}}\left[(1 + z + z^2 + \cdots z^{n-1})^2\right]_{z=0}
\end{align}
$$
A: The Cauchy formula you seek is of the form
$$f^{(n-1)}(0) = \frac{(n-1)!}{2 \pi i} \oint_{|z|=1} dz \frac{f(z)}{z^n}$$
where $n \in \mathbb{N}$.  So your integral looks like, from @Omnomnomnom, 
$$-i \oint_{|z|=1} dz \frac{(1+z+z^2+\cdots+z^{n-1})^2}{z^n}$$
which is then equal to
$$\frac{2 \pi}{(n-1)!}  \left [\frac{d^{n-1}}{dz^{n-1}}\left (1+z+z^2+\cdots+z^{n-1} \right )^2 \right ]_{z=0}$$
The value of the derivative term may be deduced from considering the sum:
$$\left ( \sum_{k=0}^{n-1} z^k\right)^2 =  \sum_{k=0}^{n-1} z^k \sum_{\ell=0}^{n-1} z^{\ell} = \sum_{k=0}^{n-1} \sum_{\ell=0}^{n-1} z^{k+\ell} $$
The coefficient of $z^{n-1}$ in the above sum is the number of pairs $(k,\ell)$ that sum to $n-1$, or $n$.  Thus the value of the $(n-1)$th derivative at $z=0$ is $n (n-1)! = n!$.  Thus the value of the integral is
$$\int_0^{2 \pi} d\phi \frac{1-\cos{n \phi}}{1-\cos{\phi}} = 2 \pi n$$
