I want to compute $\int_{0}^{2\pi}\frac{1-\cos(n\theta )}{1-\cos\theta }d\theta $ using the change of variable $z=\exp(i\theta)$.
Using the change of variable, we would get $\int \frac{1-\cos(n\theta )}{1-\cos\theta }d\theta = -\frac{1}{i}\int \frac{2-z^n-z^{-n}}{\left (z-1 \right )^2}dz$
I've seen answers for this problem using the singularity of $1$, but at this moment, I haven't learned about the singularity, so I wanted to use the corollary that we can get
$f^{(n)}(w)=\frac{n!}{2\pi i}\int_{\gamma }\frac{f(z)}{(z-w)^{n+1}}dz$ as a result. As you know, we need some conditions to use this corollary such as 1. $f:\Omega \rightarrow \mathbb{C}$ is holomorphic, and 2. $z_0 \in \Omega$ and $r>0$ must satisfy $w \in \overline{B(z_0,r)}\subset \Omega $. 3. $\gamma : [0,1]\rightarrow \Omega$ is given by $\gamma (t)=w+r\exp(2\pi i t)$.
It seems like I can use this corollary, if we let $\Omega = \mathbb{C} \setminus\left \{ 0 \right \}$, $z_0 = 1$, $r=\frac{1}{2}$.
However, what I am really having trouble with is $\gamma $, since the corollary needs $[0,1]$ while I need $[0,2\pi]$.
I first ignored $[0,1]$ and just set $\gamma :[0,2\pi]\rightarrow \mathbb{C}\setminus\left \{ 0 \right \}$ s.t $\gamma (t)=1+\frac{1}{2}\exp(2\pi i t)$.
So, I could get $0$ as desired. I wonder if this is just a coincidence.
If so, how should I reparametrize the path $\gamma$?
If not, does that mean we can use any domain for the path $\gamma $ like I did in my solution when we use this corollary?
The integral $\int_{0}^{2\pi}\frac{1-\cos(n\theta )}{1-\cos\theta }d\theta$ does not change its value if $n$ is replaced by $-n$, so it suffices to compute the integral for the case $n \ge 0$.
For $z \ne 0, 1$ is $$ -\frac{2-z^n-z^{-n}}{(z-1)^2} = \frac{(z^n-1)^2}{z^n (z-1)^2} = \frac{(1+z+z^2+ \cdots z^{n-1})^2}{z^n} $$ So the only singularity of the integrand is at $z=0$, and we have $$ I_n = \int_{0}^{2\pi}\frac{1-\cos(n\theta )}{1-\cos\theta }d\theta = \frac 1i \int_\gamma \frac{f(z)}{z^n} \, dz $$ where $\gamma(t) = e^{it}$, $0 \le t \le 2 \pi$, and $$ f(z) = (1+z+z^2+ \cdots z^{n-1})^2 \\ = 1 + 2z + \cdots + n z^{n-1} + \cdots + z^{2n-2} $$ is holomorphic in $\Bbb C$.
Using your corollary (which is Cauchy's integral formula for the derivatives) it follows that $$ I_n = 2 \pi \frac{f^{(n-1)}(0)}{(n-1)!} = 2 \pi n \, . $$
The answer for arbitrary integers $n \in \Bbb Z $ is $I_n = 2 \pi|n|$.