Find $\int_0^{2\pi}\frac1{5-4\cos x}\ dx$ $$\int_0^{2\pi}\frac1{5-4\cos x}\ dx$$
How do I compute this integral? An online integral calculator gives an antiderivative as
$$\frac{2\arctan(3\tan\frac x2)}3$$
but then gives the definite integral as $\frac{2\pi}3$. Obviously this doesn't make sense as the antiderivative vanishes at $x=0$ and $x=2\pi$.

Using complex analysis 
your integral can be expressed as 
$$ \int \limits^{2\pi }_{0}\frac{1}{5-4\cos \left( x\right) } dx=\oint \frac{1}{5-2\left( z+\frac{1}{z} \right) iz} dz$$
Now we have two singularites at $z=2$and at $z=\frac {1}{2} $
Now apply Residue  theorem 
$$\oint \frac{1}{5-2\left( z+\frac{1}{z} \right) iz} dz = 2\pi i \ \text {Res}\sum \left( f\left( z\right) , z\right) $$
We have only one singularity in the contour.
So the Residue will be 
$$ 2 \pi i \ \text {Res} \sum(f (z), z)=2 \pi i \left[\lim \limits_{z\to \frac{1}{2} }\left( 2z-1\right) \frac{1}{2i\left( -z+2\right) \left( 2z-1\right) } =\frac{1}{3i} \right]=\frac {2 \pi}{3} $$
So 
$$\color{Brown }{\int \limits^{2\pi }_{0}\frac{1}{5-4\cos \left( x\right) } dx=\boxed {\frac{2\pi }{3}} }$$
