I'm reading an example of how to calculate $\int_0^\pi\frac{d\theta}{z+\cos\theta}$ for $a>1$ with residues. Since $\cos\theta$ takes the same values on $(0,\pi)$ as $(\pi,2\pi)$, the integral equals $ \frac{1}{2}\int_0^{2\pi}\frac{d\theta}{z+\cos\theta}. $ Letting $z=e^{i\theta}$, I find $-i\frac{dz}{z}=d\theta$, and so the integral is $ -i\int_{|z|=1}\frac{dz}{2za+2z\cos\theta} $
How does this convert to $-i\int_{|z|=1}\frac{dz}{z^2+2az+1}$?
I know I should find $z^2+1=2z\cos\theta$, but I'm not seeing it.