Show that $\int_0^{\pi} \dfrac{\cos2\theta \ d \theta}{1-2 a \cos {\theta} +a^2}=\dfrac{a^2 \pi}{1-a^2}; \ \ (-1For $a=0$ the equality holds. For $a \ne 0$, by change of variable and letting $C_0$ be the unit circle about the origin, we have: 
\begin{align*}
\int_{-\pi}^{\pi} \dfrac{\cos2\theta \ d \theta}{1-2 a \cos {\theta} +a^2} &= \int_{C_0} \dfrac{\frac12 (z^2+z^{-2}) dz/zi}{1- 2a \frac12 (z+z^{-1})+ a^2} \\
& = \int_{C_0} \dfrac{(1+z^4)dz}{2iz^2(-a)(z+a)(z+\frac1a)}\\
& = \dfrac{\pi (a^4+1)}{a^2(a^2-1)} \\
& \ne  2\dfrac{a^2 \pi}{1-a^2}
\end{align*}
Where did I make a mistake?
PS This post couldn't help to find my mistake. 

From the second line, it should be
$$\int_{C_0} \dfrac{(1+z^4)dz}{2iz^2(z-a)(1-az)}
=\pi\left(\dfrac{ 1+a^4}{a^2(1-a^2)}-\frac{1+a^2}{a^2}\right)=\dfrac{2a^2 \pi}{1-a^2}$$
where we evaluated the residues at $a$ AND at $0$.
