Compute definite integral. I am trying to compute the integral:
$$\int_0^{2\pi}\frac{d\theta}{r-cos(\theta)}$$
I tried to set $u = \tan(\frac{\theta}{2})$ but is it impossible because $\tan(\frac{2\pi}{2}) = \tan(\pi) = 0$
I'll appreciate some guidance.
 A: HINT:
Inasmuch as the cosine function is even and $2\pi$-periodic, we have
$$\int_0^{2\pi }\frac{1}{r-\cos(\theta)}\,d\theta=\int_{-\pi}^\pi\frac{1}{r-\cos(\theta)}\,d\theta=2\int_0^\pi \frac{1}{r-\cos(\theta)}\,d\theta$$
A: Note that $\tan\frac\theta2$ is discontinuous at $\theta = \pi$. So, you need to divide the integration region into two continuous ones, i.e. $(0,\pi)$ and $(\pi, 2\pi)$, before making the  substitution $u=\tan\frac\theta2$.
A: Split your integral into two parts, the first from $0$ to $\pi$ and the second from $\pi$ to $2\pi$ and then apply your substitution
A: I suppose you don't want to deal with improper integrals.
First of all :
$$ \int_{0}^{2\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}=\int_{0}^{\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}+\int_{\pi}^{2\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}} $$
Substituting $ \small\left\lbrace\begin{aligned}\varphi &=2\pi -\theta\\ \mathrm{d}\theta &=-\,\mathrm{d}\varphi\end{aligned}\right. $ in the second term, we get : \begin{aligned} \int_{0}^{2\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}&=2\int_{0}^{\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}\\&=2\int_{0}^{\frac{\pi}{2}}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}+2\int_{\frac{\pi}{2}}^{\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}} \end{aligned}
Again, substituting $ \small\left\lbrace\begin{aligned}\varphi &=\pi -\theta\\ \mathrm{d}\theta &=-\,\mathrm{d}\varphi\end{aligned}\right. $ in the second term, we get : \begin{aligned} \int_{0}^{2\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}&=2\int_{0}^{\frac{\pi}{2}}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}+2\int_{0}^{\frac{\pi}{2}}{\frac{\mathrm{d}\varphi}{r+\cos{\varphi}}}\\ &=2\int_{0}^{\frac{\pi}{2}}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}+2\int_{0}^{\frac{\pi}{2}}{\frac{\mathrm{d}\theta}{r+\cos{\theta}}} \end{aligned}
Now, since $ \psi : x\mapsto\tan{\left(\frac{x}{2}\right)} $ is a $ \mathcal{C}^{1} $ function on $ \left[0,\frac{\pi}{2}\right] $, we can substitute $ \small\left\lbrace\begin{aligned}x&=\tan{\left(\frac{\theta}{2}\right)}\\ \mathrm{d}\theta &=\frac{2\,\mathrm{d}x}{1+x^{2}}\end{aligned}\right. $ in each of the two integrals, to get the following : \begin{aligned} \int_{0}^{2\pi}{\frac{\mathrm{d}\theta}{r-\cos{\theta}}}&=4\int_{0}^{1}{\frac{\mathrm{d}x}{\left(1+x^{2}\right)r-\left(1-x^{2}\right)}}+4\int_{0}^{1}{\frac{\mathrm{d}x}{\left(1+x^{2}\right)r+\left(1-x^{2}\right)}}\end{aligned}
I'll leave the rest to you.
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[5px,#ffd]{\int_{0}^{2\pi}{d\theta \over r - \cos\pars{\theta}}}  =
\int_{-\pi}^{\pi}{d\theta \over r + \cos\pars{\theta}} =
2\int_{0}^{\pi}{d\theta \over r + \cos\pars{\theta}}
\\[5mm] = &\
2\int_{-\pi/2}^{\pi/2}{d\theta \over r - \sin\pars{\theta}} =
2\int_{0}^{\pi/2}\bracks{{1 \over r - \sin\pars{\theta}} +
{1 \over r + \sin\pars{\theta}}}d\theta
\\[5mm] = &\
4r\int_{0}^{\pi/2}{d\theta \over r^{2} - \sin^{2}\pars{\theta}} =
4r\int_{0}^{\pi/2}{\sec^{2}\pars{\theta}\,d\theta \over r^{2}\sec^{2}\pars{\theta} - \tan^{2}\pars{\theta}}
\\[5mm] = &\
4r\int_{0}^{\pi/2}{\sec^{2}\pars{\theta}\,d\theta \over
\pars{r^{2} - 1}\tan^{2}\pars{\theta} + r^{2}}
\\[5mm] = &\
4r\,{1 \over r^{2}}\,{r \over \root{r^{2} - 1 }}\int_{0}^{\pi/2}
{\root{r^{2} - 1}\sec^{2}\pars{\theta}/r \over
\bracks{\root{r^{2} - 1}\tan\pars{\theta}/r}^{2} + 1}\,d\theta
\\[5mm] = &\
{4 \over \root{r^{2} - 1}}\,\int_{0}^{\infty}{\dd t \over t^{2} + 1} =
\bbx{{2\pi \over \root{r^{2} - 1}}} \\ &
\end{align}
A: For $r>1$ there is no problem that $\tan \theta$ is ever $0$, and then the solution is:
$$\frac{2 \pi}{\sqrt{r^2 - 1}}$$

