<s>[INST] 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.
 [/INST] 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}
$$
</s>