I am interested in the following definite integral:
$$\int_0^{2\pi}\frac{a-\cos\theta}{b-\cos\theta}d\theta$$
for $a>0$ and $b>0$. I asked Wolfram Alpha and it gave me an answer that worried me, so I decided to try the specific case of $a=1$ and $b=2$. It gives me the indefinite version:
$$\int \frac{1-\cos\theta}{2-\cos\theta}d\theta=\theta-\frac{2\tan^{-1}(\sqrt{3}\tan(\theta/2))}{\sqrt{3}}$$
so I can set the limits and get my answer. At $\theta=0$, $\tan(\theta/2)=0$ and $\tan^{-1}(0)=n\pi$. At $\theta=2\pi$, $\tan(\theta/2)=0$ again so $\tan^{-1}(0)=m\pi$ (different integer here for later comparison). My final answer is then
$$\int_0^{2\pi}\frac{a-\cos\theta}{b-\cos\theta}d\theta=2\pi-\frac{2}{\sqrt{3}}n\pi-(0-\frac{2}{\sqrt{3}}m\pi)=2\pi-\frac{2\pi}{\sqrt{3}}(n-m).$$
Which, not knowing what else to do, I might just say the final answer is $2\pi$ (choosing the same branch of the tangent function). Now, along with this indefinite integral, Wolfram also of course gives me its own answer for the definite form,
$$\int_0^{2\pi}\frac{a-\cos\theta}{b-\cos\theta}d\theta=-\frac{2}{3}(\sqrt{3}-3)\pi.$$
Apparently, it has decided that $n-m=1$ is the correct choice for the branches of tangent in the integral. Why?
Note that when one integrates a function of period $2\pi$ one has $\displaystyle\int_0^{2\pi} = \int_{-\pi}^\pi$.
\begin{align} u & = \tan \frac \theta 2 \\[10pt] \theta & = 2\arctan u \\[10pt] \cos\theta & = \cos(2\arctan u) \\ & = \cos^2 \arctan u - \sin^2\arctan u = \frac 1 {u^2 + 1} - \frac {u^2} {u^2+1} \\ & = \frac{u^2-1}{u^2+1} \end{align}
As $\theta$ increases from $-\pi$ to $\pi$, then $u$ increases from $-\infty$ to $+\infty$. Here we're using just one connected component of the graph of the tangent function.
Now suppose we instead let $\theta$ increase from $0$ to $2\pi$. Then $u$ first increases from $0$ to $+\infty$ and then increases from $-\infty$ to $0$. Either way, the definite integral is the same.
Normally I wouldn't bother with changing it back to a function of $\theta$ and going on from there. But suppose we do that. As $\theta$ goes once around the circle, $c\tan(\theta/2)$ goes once through the whole real line, regardless of the value of $c>0$. If we follow the "principal branch" of the arctangent function then the arctangent goes from $-\pi/2$ to $+\pi/2$, again regardless of the value of $c>0$. If we follow a different branch, the indefinite integral changes by a constant, so the definite integral does not change. So now the question is: Why remain on one branch? And there the point is that otherwise we have a jump discontinuity in our antiderivative and it fails to be an antiderivative at that point.