I have this integral $\int_0^{2\pi}\frac{1}{1+k\cos{x}}{\rm d}x$,
which is definitely:
$\int_0^{2\pi}\frac{1}{1+k\cos{x}}{\rm d}x = 2\int_0^{\pi}\frac{1}{1+k\cos{x}}{\rm d}x$,
but if I do this:
$\int_0^{2\pi}\frac{1}{1+k\cos{x}}{\rm d}x = \int_0^{\pi}\frac{1}{1+k\cos{x}}{\rm d}x$ + $\int_\pi^{2\pi}\frac{1}{1+k\cos{x}}{\rm d}x$,
I get in the second integral after substitution $x = z + \pi$:
$\int_0^{\pi}\frac{1}{1+k\cos{(z+\pi)}}{\rm d}z=\int_0^{\pi}\frac{1}{1-k\cos{z}}{\rm d}z$.
What am I doing wrong?