How to integrate $\frac{1}{(1+a\cos x)}$ from $-\pi$ to $\pi$ How to solve the following integration?$$\int_{-\pi}^\pi\frac{1}{1+a \cos x}$$

You can look at my earlier answer here (on my previous avatar).
Below is another method. We have
$$I = \int_{-\pi}^{\pi} \dfrac{du}{1+a\cos(u)} = 2 \int_0^{\pi} \dfrac{du}{1+a \cos(u)} = 2\int_0^{\pi/2} \dfrac{du}{1+a\cos(u)} + 2\int_{\pi/2}^{\pi} \dfrac{du}{1+a\cos(u)}$$
Hence,
$$\dfrac{I}2 = \int_0^{\pi/2} \dfrac{du}{1+a\cos(u)} + \int_0^{\pi/2}\dfrac{du}{1-a\cos(u)} = \int_0^{\pi/2} \dfrac{2du}{1-a^2\cos^2(u)} = \int_0^{\pi/2}\dfrac{2\sec^2(u)du}{\sec^2(u)-a^2}$$
This gives us
$$\dfrac{I}4 = \int_0^{\pi/2}\dfrac{\sec^2(u)du}{1+\tan^2(u)-a^2}$$
Setting $t=\tan(u)$, we obtain
$$\dfrac{I}4 = \int_0^{\infty} \dfrac{dt}{t^2+(1-a^2)}=\dfrac1{\sqrt{1-a^2}} \left.\arctan\left(\dfrac{t}{\sqrt{1-a^2}}\right) \right \vert_0^{\infty} \implies I = \dfrac{2\pi}{\sqrt{1-a^2}}$$
