<s>[INST] 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.

 [/INST] 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}
</s>