Show that
$$\frac{1}{2\pi i}\int_\gamma \frac{z^n}{1-2z \cos\theta +z^2} dz = \frac{\sin(n\theta)}{\sin\theta}$$, where
$$n \in Z_{\ge1}\;.\;\;\theta \in (0,\pi)\,,\;\ \gamma = C(0,2)$$
traversed counterclockwise.
I'm not really sure how to approach this. I have tried substituting $cos\theta$ for $\frac{1}{2} (z+\frac{1}{z})$ to get $\frac{z^n}{2}$ inside the integral, but isn't that analytic, so the integral of that would be 0?
The solution states that the roots of the denominator are $e^{i\theta}$ and $e^{-i\theta}$ of order 1 and then to proceed using Cauchy's Integral Formula. I don't understand how this was reached at all. Any help would be appreciated!
Observe that the quadratic's discriminant is
$$\Delta=4\cos^2\theta-4=-4\sin^2\theta\implies z_{1,2}=\frac{2\cos\theta\pm\sqrt\Delta}2=\cos\theta\pm i\sin\theta=e^{\pm i\theta}$$
Thus:
$$I\;\;Res_{z=e^{i\theta}}(f)=\lim_{x\to e^{i\theta}}\frac{(z-e^{i\theta})z^n}{(z-e^{i\theta})(z-e^{-i\theta})}=\frac{e^{ni\theta}}{e^{i\theta}-e^{-i\theta}}=\frac{e^{ni\theta}}{2i\sin\theta}$$
$$II\;\;Res_{z=e^{-i\theta}}(f)=\lim_{x\to e^{-i\theta}}\frac{(z-e^{-i\theta})z^n}{(z-e^{i\theta})(z-e^{-i\theta})}=\frac{e^{-ni\theta}}{e^{-i\theta}-e^{i\theta}}=\frac{e^{-ni\theta}}{-2i\sin\theta}$$
By the Residue Theorem (can you see where, how and why?), the integral equals
$$I+II\;=\;\frac{e^{ni\theta}-e^{-ni\theta}}{2i\sin\theta}=\frac{\sin n\theta}{\sin\theta}$$
Note: we used above that
$$t\in\Bbb R\implies \sin t=\frac{e^{it}-e^{-it}}{2i}$$