Evaluate $\int_0^{2\pi} \frac{d\theta}{(1-a\cos(\theta)+a^2)}$ Evaluate $\displaystyle \int_0^{2\pi} \frac{d\theta}{(1-a\cos(\theta)+a^2)}$
Super general. I get to a step: $\displaystyle \frac{2}{i}$ multiplied by Path integral $\displaystyle \frac{z}{[(2-a)z^2 + 2(a^2  z) + a]}.$
No idea if I'm on the right track. Maybe distribute the $i$? Wondering if I can get some help. 
 A: We have
$$I(a) = \int_{0}^{2 \pi} \dfrac{dx}{1+a^2-a \cos(x)} = \dfrac1{1+a^2} \int_0^{2\pi} \dfrac{dx}{1 - \dfrac{a}{1+a^2} \cos(x)}$$
Note that we always have $b = \dfrac{a}{1+a^2} < 1$. Hence, we can write
$$\dfrac1{1 - b \cos(x)} = \sum_{k=0}^{\infty}b^k \cos^k(x)$$
Now we have
$$\int_0^{2\pi} \dfrac{dx}{1 - b \cos(x)} = \sum_{k=0}^{\infty} \int_0^{2 \pi} b^k \cos^k(x)dx = \sum_{k=0}^{\infty} b^{2k} \int_0^{2 \pi} \cos^{2k}(x)dx (\because\text{odd terms integrate to }0)$$
We now have from here that
$$\int_0^{2 \pi} \cos^{2k}(x)dx= \dbinom{2k}k \dfrac{2 \pi}{4^k}$$
This gives us
$$\int_0^{2\pi} \dfrac{dx}{1 - b \cos(x)} = 2 \pi \left(\sum_{k=0}^{\infty} \dbinom{2k}k \left(\dfrac{b^2}4\right)^k\right) = \dfrac{2 \pi}{\sqrt{1-b^2}}$$
where we made use of the fact that the Taylor series of $\dfrac1{\sqrt{1-x}}$ is
$$\dfrac1{\sqrt{1-x}} = \sum_{k=0}^{\infty} \dbinom{2k}k \left(\dfrac{x}4\right)^k$$
Hence, we now have
$$I(a) = \dfrac1{1+a^2} \dfrac{2 \pi}{\sqrt{1-\left(\dfrac{a}{1+a^2}\right)^2}} = \dfrac{2 \pi}{\sqrt{1+a^2+a^4}}$$
A: This may be solved by complex variables. Put $z = e^{i\theta}$ to obtain
$$\int_0^{2\pi} \frac{d\theta}{1-a\cos\theta+a^2} =
\int_{|z|=1} \frac{1}{iz} \frac{dz}{1-a/2(z+1/z)+a^2} =
\int_{|z|=1} \frac{1}{iz} \frac{z dz}{z-a/2(z^2+1)+za^2} \\=
-i \int_{|z|=1} \frac{dz}{z-a/2(z^2+1)+za^2}$$
The two poles (use e.g. the quadratic formula) are at
$$z_{0,1} = \frac{1+a^2}{a} \pm \frac{\sqrt{1+a^2+a^4}}{a}.$$
Now assume that $a>1,$ so that the pole corresponding to the plus sign is clearly outside of the unit circle.
On the other hand $$z_1 =\frac{1+a^2}{a} - \frac{\sqrt{1+a^2+a^4}}{a} < 1$$
because it is equivalent to
$$ 1+a^2 -a < \sqrt{1+a^2+a^4}$$
which is $$ a^4 + 2 a^2(1-a) +(1-a)^2 < 1 + a^2 +a^4
\Leftrightarrow
2a^2 - 2a^3 + (1 - a)^2 < 1 + a^2\\
\Leftrightarrow
2a^2 < 2 a^3 + 2a
\Leftrightarrow a <a^2 + 1,$$
which holds trivially.
Now the residue of the integrand at $z_1$ is given by
$$\lim_{z\to z_1} \frac{1}{1-az+a^2} =
\frac{1}{1+a^2-1-a^2+\sqrt{1+a^2+a^4}} =
\frac{1}{ \sqrt{1+a^2+a^4} }.$$
It follows that the integral is given by
$$2\pi i \times -i \times \frac{1}{ \sqrt{1+a^2+a^4} } =
\frac{2\pi}{ \sqrt{1+a^2+a^4} }.$$
A: Take a Weierstrass substitution $u = \tan \frac{\theta}{2}$ after reducing the integration range using $\cos(2\pi - \theta) = \cos(\theta)$ in the second integral below:
$$
   \int_0^{2\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta} = \int_0^{\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta} + \int_{\pi}^{2\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta}
$$ 
giving
$$
   \int_0^{2\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta} = 2 \int_0^{\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta}
$$
Now apply the substitution, using $\cos\theta = \frac{1-u^2}{1+u^2}$, and $\mathrm{d}\theta = \frac{2\mathrm{d}u}{1+u^2}$:
$$
  2 \int_0^{\pi} \frac{\mathrm{d}\theta}{a^2+1-a \cos\theta} = 4 \int_0^\infty \frac{\mathrm{d}u}{a^2-a+1 + (a^2+a+1) u^2} = 4 \cdot \frac{\pi}{2 \sqrt{(a^2-a+1)(a^2+a+1)}} = \frac{2\pi}{\sqrt{a^4+a^2+1}}
$$
where we used the assumption $a^2-a+1>0$ and $a^2+a+1>0$, valid for all real $a$.
