Definite integral of $1/(5+4\cos x)$ over $2$ periods Question:
$$\int_0^{4\pi}\frac{dx}{5+4\cos x} $$
My approach: 
First I calculated the antiderivative as follows:  
Using: $\cos\theta= \frac{1-\tan^2\frac{\theta}{2}}{1+\tan^2\frac{\theta}{2}}$ we have:
$\int\frac{dx}{5+4\cos x}=\int\frac{dx}{5+4\frac{1-\tan^2\frac{x}{2}}{1+\tan^2\frac{x}{2}}}=\int\frac{1+\tan^2\frac{x}{2}}{5+5\tan^2\frac{x}{2}+4-4\tan^2\frac{x}{2}}dx=\int\frac{\frac{1}{\cos^2 \frac{x}{2}}}{3^2+\tan^2\frac{x}{2}}dx$
Using substitution we have:  
$u=\tan\frac{x}{2}$
$du=\frac{1}{2}\frac{1}{\cos^2\frac{x}{2}}dx$ 
$2\int\frac{\frac{1}{2}\frac{1}{\cos^2 \frac{x}{2}}}{3^2+\tan^2\frac{x}{2}}dx=2\int\frac{du}{3^2+u^2}=\frac{2}{3}\arctan\frac{u}{3}+\mathscr{C}=\frac{2}{3}\arctan\frac{\tan\frac{x}{2}}{3}+ \mathscr{C}$
Now we can calculate the definite integral as follows:  
$\int_0^{4\pi}\frac{dx}{5+4\cos x} = \frac{2}{3}\arctan\frac{\tan\frac{x}{2}}{3}\bigl|_0^{4\pi}=\frac{2}{3}(\arctan\frac{\tan\frac{4\pi}{2}}{3}-\arctan\frac{\tan\frac{0}{2}}{3})=0$ 
The result I get is $0$ but the correct one is $\frac{4\pi}{3}$. Can someone explain me why?  
Here it shows that the correct answer is $\frac{4\pi}{3}$.

You have everything right up to the limit taking,
$$I=\int_0^{4\pi}\frac{dx}{5+4\cos x} = \frac{2}{3}\arctan\frac{\tan\frac{x}{2}}{3}\bigl|_0^{4\pi}$$
Note that the anti derivative function on the RHS is discontinuous at $\pi$ and $3\pi$. So, the limits have to be broken into  three intervals,
$$\bigl|_0^{4\pi} =  \bigl|_0^{\pi}+\bigl|_\pi^{3\pi} +\bigl|_{3\pi}^{4\pi} $$
which leads to the result 
$$I = \frac23 (\frac\pi2+\pi+\frac\pi2)=\frac43\pi$$
as expected.
