<s>[INST] prove $\int_{0}^{2\pi}(1-\cos x)^n\cos nx dx=(-1)^n\frac{\pi}{2^{n-1}} $ prove $$\int_{0}^{2\pi}(1-\cos x)^n\cos nx dx=(-1)^n\frac{\pi}{2^{n-1}} $$
I tried with $2\cos x =z+\frac1z$ then use residue theorem but I faced some troubles 
my try is :
$2\cos x =z+\frac1z$
$$I=\int_{\left | z \right |=1}\frac{(-1)^n}{2^{n+1}}\frac{(z^2-2z+1)^n}{z^{2n+1}}dz$$
$$I=Res_{z=0}\frac{(z^2-2z+1)^n}{z^{2n+1}} $$
but I can't find closed form for the derivative
if any one can explain more how I can continue
if any one can solve it  using real or complex analysis 
 [/INST] By periodicity, shift the interval of integration to $[-\pi,\pi]$. Then by parity
$$\int_{-\pi}^\pi (1-\cos x)^n \cos nx\,dx = \int_{-\pi}^\pi (1-\cos x)^n e^{inx}\,dx.$$
Now substitute $z = e^{ix}$, $dx = \frac{dz}{iz}$ and $\cos x = \frac{1}{2}(z + z^{-1})$ to get
$$\begin{align}
\int_{-\pi}^\pi (1-\cos x)^n \cos nx\,dx &= \frac{1}{i} \int_{\lvert z\rvert = 1} \left(1 - \frac{z+z^{-1}}{2}\right)^n z^n \,\frac{dz}{z}\\
&= \frac{1}{i} \int_{\lvert z\rvert = 1} \left(z - \frac{z^2}{2} - \frac{1}{2}\right)^n\, \frac{dz}{z}.
\end{align}$$
When expanding the power, all integrals vanish except the one for the $\left(-\frac{1}{2}\right)^n$ term.
</s>