Find $\int_0^{2\pi} \frac{1}{3 + \cos x} dx$. I have to find the integral
$$\int_0^{2\pi} \dfrac{1}{3 + \cos x} dx$$
I tried using the Weierstrass subtitution, but replacing the bounds, I get:
$$t_1 = \tan \dfrac{0}{2} = \tan 0 = 0$$
$$t_2 = \tan \dfrac{2 \pi}{2} = \tan \pi = 0$$
Resulting in the integral:
$$\int_0^0 \dfrac{1}{3 + \dfrac{1 - t^2}{1 + t^2}} \cdot \dfrac{2}{1 + t^2} dt$$
which obviously equals $0$ since the bounds are the same. Is this correct? It feels wrong.
 A: Using the identity
$$\frac{1}{a+b\cos t}=\frac{1}{\sqrt{a^2-b^2}}+\frac{2}{\sqrt{a^2-b^2}}\sum_{n=1}^{\infty}\left(\frac{\sqrt{a^2-b^2}-a}{b}\right)^n\cos{(nt)},\  a>b$$
we have 
$$\frac{1}{3+\cos x}=\frac{1}{\sqrt{8}}+\frac{1}{\sqrt{2}}\sum_{n=1}^{\infty}\left(\sqrt{8}-3\right)^n\cos{(nx)}$$
giving us 
$$\int_0^{2\pi}\frac{1}{3+\cos x}\ dx=\frac{1}{\sqrt{8}}\int_0^{2\pi}\ dx+\frac{1}{\sqrt{2}}\sum_{n=1}^{\infty}\left(\sqrt{8}-3\right)^n\underbrace{\int_0^{2\pi}\cos{(nx)}\ dx}_{0}=\frac{\pi}{\sqrt{2}}$$
A: By the tangent half-angle substitution we obtain: 
\begin{align}2\int_0^{\pi} \dfrac{1}{3 + \cos x} \,dx&=2\int_0^{\infty}\frac{1}{3+\frac{1-t^2}{1+t^2}}\frac{2}{1+t^2}\,dt\\&=
2\int_0^{\infty}\frac{1}{t^2+2}\,dt\\&=
2\left(\frac{1}{\sqrt{2}}\arctan\left(\frac{x}{\sqrt2{}}\right)\right)\Bigg|_0^{\infty}
\\&=2\left(\frac{1}{\sqrt{2}}\frac{\pi}{2}-0\right)\\&=
\frac{\pi}{\sqrt{2}}
\end{align}
A: No, to answer your question: "Is this correct?"
You're assuming that $\tan(x/2)$ is continuous on $[0,2\pi],$ by choosing this substitution. Since $\tan(x/2)$ is discontinuous at $x=\pi,$ and $\pi\in[0,2\pi]$ it is hopefully clear that you need to adjust your Weierstrass sub by making it an improper integral.
