Solving an integral with trig substitution I'm looking to solve the following integral using substitution:
$$\int \frac{dx}{2-\cos x}$$
Let $z=\tan\frac{x}{2}$
Then $dz=\frac 1 2 \sec^2 \frac x 2\,dx$
$$\sin x=\frac{2z}{z^2+1}$$
$$\cos x =\frac{1-z^2}{z^2+1}$$
$$dx=\frac{2\,dz}{z^2+1}$$
$$\int \frac{dx}{2-\cos x} = \int \frac{\frac{2\,dz}{z^2+1}}{2-\frac{1-z^2}{z^2+1}} =\int \frac{2\,dz}{3z^2+1}$$
But this is where things start to look at bit sticky.  If I integrate this last fraction, then I get a very complex expression that seems to defeat the point of z-substitution.  Any suggestions for where I may be going wrong?
Thanks!
Edit:
Thank you for your feedback.  I've completed my work as per your suggestions:
$$\int \frac{2\,dz}{3z^2+1} = 2\cdot\left(\frac{\tan^{-1} \frac{z}{\sqrt{3}}}{\sqrt{3}} \right) = \frac{2\tan^{-1} \left(\sqrt{3}\tan{\frac{x}{2}}\right)}{\sqrt{3}}+c$$

HINT:

$$\int \frac{1}{a^2+x^2}dx=\frac1a \arctan(x/a)+C$$

