integrate $\int_0^\pi\frac {1-\alpha^2}{1-2\alpha\cos x +\alpha^2} dx$ I am stuck at this example from Wikipedia on differentiation under the integral sign.
$$\int_0^\pi\frac {1-\alpha^2}{1-2\alpha\cos x + \alpha^2} dx$$
Any help?
Edits: 


*

*The last term in the denominator is changed to $\alpha^2$.

*This integral appears in example 3 of the Wikipedia article https://en.wikipedia.org/wiki/Differentiation_under_the_integral_sign.

 A: Let us write the integrand as
\begin{equation}
g(x) = \frac{1 - \alpha^2}{1 - 2\alpha\cos x + \alpha^2}
\end{equation}
We first write $\cos x = \cos^2(x/2) - \sin^2(x/2)$, $1 = \cos^2(x/2) + \sin^2(x/2)$ and $\alpha^2 = \alpha^2(\cos^2(x/2) + \sin^2(x/2))$ to get
\begin{equation}
g(x) = \frac{(1 - \alpha^2)\sec^2(x/2)}{(1 - \alpha)^2 + (1 + \alpha)^2\tan^2(x/2)}
\end{equation}
which is same as
\begin{equation}
g(x) = 2\frac{1 + \alpha}{2}\frac{(1 - \alpha)\sec^2(x/2)}{(1 - \alpha)^2 + (1 + \alpha)^2\tan^2(x/2)}
\end{equation}
or,
\begin{equation}
g(x) = 2\frac{1}{1 + \frac{(1 + \alpha)^2}{(1 - \alpha)^2}\tan^2(x/2)}\frac{1 + \alpha}{1 - \alpha}\sec^2(x/2)\frac{1}{2}
\end{equation}
or
\begin{equation}
g(x) = 2 \frac{1}{1 + \left(\frac{1 + \alpha}{1 - \alpha}\right)^2\tan^2\left(\frac{x}{2}\right)}\frac{d}{dx}\left[\frac{1 + \alpha}{1 - \alpha}\tan\left(\frac{x}{2}\right)\right]
\end{equation}
Therefore,
\begin{equation}
\int g(x)dx = 2\tan^{-1}\left(\frac{1 + \alpha}{1 - \alpha}\tan\left(\frac{x}{2}\right)\right) + c,
\end{equation}
where $c$ is a constant of integration. Therefore,
\begin{equation}
\int_0^\pi \frac{1 - \alpha^2}{1 - 2\alpha\cos x + \alpha^2}
dx = \begin{cases}
 \pi & |\alpha| < 1 \\
-\pi & |\alpha| > 1
\end{cases}
\end{equation}
A: This is a typical example which can be solved by the residue theorem:
We have that (with $z=e^{ix}$)
\begin{align*}
I&= \int_0^\pi\frac {1-\alpha^2}{1-2\alpha\cos x + \alpha^2} dx \\
&=\frac12 \int_{-\pi}^\pi\frac {1-\alpha^2}{1-2\alpha\cos x + \alpha^2} dx \\
&= \frac1{2i} \oint_{|z|=1} \!\frac{dz}z\, \frac{1-\alpha^2}{1 + \alpha^2 -\alpha (z+z^{-1})}
\end{align*}
The denominator is given by
$$ d= z (1+\alpha^2) -\alpha (1+ z^2)$$
and has the poles $z_1=\alpha$ and $z_2=1/\alpha$. 
(1) For $|\alpha|<1$ the pole at $z=z_1$ contributes, and we obtain
$$I = \pi \mathop{\rm Res}_{z=\alpha} \frac{1-\alpha^2}{d} = \pi.$$
(2) For $|\alpha|>1$ the pole at $z=z_2$ contributes, and we obtain
$$I = \pi \mathop{\rm Res}_{z=1/\alpha} \frac{1-\alpha^2}{d} = -\pi.$$
A: If $|\alpha| < 1$ then we know that $$1 + 2\alpha\cos x + 2\alpha^{2}\cos 2x + \cdots = \frac{1 - \alpha^{2}}{1 - 2\alpha\cos x + \alpha^{2}}\tag{1}$$ Now integrating the above identity with respect to $x$ on interval $[0, \pi]$ we get the desired integral as $\pi$ (because $\int_{0}^{\pi}\cos nx \,dx = 0$). If $|\alpha| > 1$ then we note that $$\frac{1 - \alpha^{2}}{1 - 2\alpha\cos x + \alpha^{2}} = - \dfrac{1 - \dfrac{1}{\alpha^{2}}}{1 - \dfrac{2}{\alpha}\cos x + \dfrac{1}{\alpha^{2}}}$$ and since $|1/\alpha| < 1$ we see that the desired integral is equal to $-\pi$.
A: i guess, to the case $\vert{\alpha}\vert=1$, your result is different (maybe zero). because, under this assumption, only when $cosx=\frac{a^2+1}{2a}$, your integration will not be zero. so we can compute as below :
$\int_{0}^{\pi}\frac{1-\alpha^2}{1-2\alpha{cosx}+\alpha^2}dx=$$\int_{0}^{\pi}\frac{2(1-\alpha{cosx})}{1-2\alpha{cosx}+\alpha^2}dx$
pick $y=\alpha{cosx}$ and you can see it :
$\int_{0}^{\pi}\frac{2(1-\alpha{cosx})}{1-2\alpha{cosx}+\alpha^2}dx=$$\int_{0}^{\pi}\frac{2(1-y)}{1-2y+\alpha^2}dx=$$\int_{-1}^{1}\frac{1}{\sqrt{1-y^2}}dy=$$\alpha{\theta\vert_{-\pi/2}^{\pi/2}}=\vert{\pi}\vert$ 
but if you multiple $\vert{\pi}\vert$ with $\epsilon$, the result will be zero too!
