I am using contour integration to find $$\int_0^{2p} \frac{1}{2+cos\theta}\,d\theta~.$$
I learned in the book that upper limit of integral must be $2\pi$. To convert it to $2\pi$ i use substitution $t=(\pi/p)\theta$ but this change to $$(p/\pi)\int_0^{2\pi} \frac{1}{2+cos(pt/\pi)}\,dt~.$$
Now, here I can use contour integration by using $e^{ipt/\pi} = z$ and hence $cos(pt/\pi) = 1/2z(z^2+1)$ and the equation changes to $$1/i \int_0^{2\pi}\frac{2z}{z^2+4z+1}\,dz$$
Now this result has value which is not dependent on $p$. Am I doing something wrong, as the final result should have $p$. Please suggest.
Let's assume that $0< p<\pi$. Then, upon making the substitution $z=e^{i\theta}$, we have
$$\int_0^{2p} \frac1{2+\cos(\theta)}\,d\theta = -i\int_1^{e^{i2p}}\frac{2}{z^2+4z+1}\,\,dz\tag1$$
Note that the integral on the right-hand side of $(1)$ is not a closed contour and we cannot use the residue theorem to evaluate it.
But we can evaluate the integral on the right-hand side by using, for example, partial fraction expansion. However, it is easier to simply use the Weierstrass substitution on the original integral. Both of those approaches are left as exercises for the reader.