Prove that, $\int_{0}^{2\pi}\frac{\cos x+2}{5+4\cos x} dx=\pi$ I have tried to solve this which goes as follows-
$$\begin{align*}
\int\frac{\cos x+2}{5+4\cos x} dx
&=\int\frac{(1/4)(5+4\cos x)+(3/4)}{5+4\cos x} dx\\
&={1\over4}\int dx+{3\over4}\int\frac{dx}{9\cos^2 {x\over 2}+\sin^2{x\over2}}\\
&=({x\over4}+C)+{3\over4}\int\frac{\sec^2{x\over2}}{9+\tan^2{x\over2}}dx\\
&=({x\over4}+C)+{3\over2}\int\frac{dy}{9+y^2}\qquad \text{substituting $\tan {x\over2}=y$}\\
&={x\over4}+{1\over2}\arctan({y\over3})+C'={x\over4}+{1\over2}\arctan({\tan{x\over2}\over3})+C'
\end{align*}$$
So, 
$$\int_{0}^{2\pi}\frac{\cos x+2}{5+4\cos x} dx=\left[{x\over4}\right]_{0}^{2\pi}+{1\over2}\left[\arctan({\tan{x\over2}\over3})\right]_{0}^{2\pi}
\\={\pi\over2}+{1\over2}\left[\arctan({\tan\pi\over3})-0\right]={\pi\over2}+{1\over2}\left[0-0\right]={\pi\over2}$$
So, I can't get $\pi$!! Can anybody find out where is my fault? Thanks for assistance in advance.
 A: Note that
$$\int\frac{\cos x+2}{5+4\cos x} dx=F(x):={x\over4}+{1\over2}\arctan\left({\tan{x\over2}\over3}\right)+c$$
but the function $F$ is not continuous on the interval of integration $[0,2\pi]$ (on the other hand a primitive of a continuous function should be continuous by the Fundamental Theorem of Calculus). 
Since $F$ has a "jump" at $x=\pi$ we may split the interval and therefore we obtain
$$\int_0^{2\pi}\frac{\cos x+2}{5+4\cos x} dx
=\int_0^{\pi} +\int_{\pi}^{2\pi} =[F(x)]_{0^+}^{\pi^-}+[F(x)]_{\pi^+}^{2\pi^-}=\frac{\pi}{2}+\frac{\pi}{2}=\pi.$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bbox[10px,#ffd]{\int_{0}^{2\pi}{\cos\pars{x} + 2 \over 5 + 4\cos\pars{x}}\,\dd x} =
{\pi \over 2} +
{3 \over 4}\int_{-\pi}^{\pi}{\dd x \over 5 - 4\cos\pars{x}} =
{\pi \over 2} +
{3 \over 2}\int_{0}^{\pi}{\dd x \over 5 - 4\cos\pars{x}}
\\[5mm] = &\
{\pi \over 2} +
{3 \over 2}\int_{-\pi/2}^{\pi/2}{\dd x \over 5 + 4\sin\pars{x}} =
{\pi \over 2} +
{3 \over 2}\int_{0}^{\pi/2}\bracks{{1 \over 5 + 4\sin\pars{x}} +
{1 \over 5 - 4\sin\pars{x}}}\dd x
\\[5mm] = &\
{\pi \over 2} +
15\int_{0}^{\pi/2}{\dd x \over 25 - 16\sin^{2}\pars{x}} =
{\pi \over 2} +
15\int_{0}^{\pi/2}{\sec^{2}\pars{x}\,\dd x \over
25\sec^{2}\pars{x} - 16\tan^{2}\pars{x}}
\\[5mm] = &\
{\pi \over 2} +
15\int_{0}^{\pi/2}{\sec^{2}\pars{x}\,\dd x \over
9\tan^{2}\pars{x} + 25} =
{\pi \over 2} +
15\,{1 \over 25}\,{5 \over 3}\int_{0}^{\pi/2}{\bracks{3\sec^{2}\pars{x}/5}\,\dd x \over
\bracks{3\tan\pars{x}/5}^{\, 2} + 1}
\\[5mm] = &\
{\pi \over 2}\ +\
\underbrace{\int_{0}^{\infty}{\dd x \over x^{2} + 1}}
_{\ds{=\ {\pi \over 2}}}\ =\ \bbx{\pi}
\end{align}
A: Hint: Substitute $$\cos(x)=\frac{1-t^2}{1+t^2}$$ and $$dx=\frac{2}{1+t^2}dt$$
