# Choosing the correct branch in $\int \frac{a-\cos(\theta)}{b-\cos(\theta)} d\theta$

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?

link to this calculation

• Changing the name of your variable from $\theta$ to $x$ can make people wonder if you did some substitution in which $x$ is some function of $\theta$ (among other difficulties). $\qquad$ – Michael Hardy Sep 2 '16 at 17:00
• ^^ Thanks, I changed it. I actually didn't know you could do LaTeX-y things like that onWolfram. – levitopher Sep 2 '16 at 17:48
• I don't think it's a branch issue. The function $g(x) = x-\frac{2\tan^{-1}(\sqrt{3}\tan(x/2))}{\sqrt{3}}$ is only a primitive of $\frac{1-\cos x}{2-\cos x}$ where $g(x)$ is defined. The function $g(x)$ is not defined at $x= \pi$. You need to break up the definite integral and take the appropriate limits. – Random Variable Sep 2 '16 at 18:48
• @RandomVariable Need to is perhaps too strong wording. For example, here the function $$\Bigl(1-\frac{1}{\sqrt{3}}\Bigr)x-\frac{2}{\sqrt{3}}\arctan\Bigl(\frac{\sin x}{2+\sqrt{3}-\cos x}\Bigr)$$ is a primitive that works for all $x\in\mathbb R$. – mickep Sep 2 '16 at 18:51
• @mickep To use $g(x)$ you need to break it up. That's the point I was trying to make. – Random Variable Sep 2 '16 at 18:58

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.

• Right right, so since the antiderivative is not defined in the interval, you gotta break up the limit evaluation to regions where it is. Since this is a periodic function, in this case you can just shift the integration region. – levitopher Sep 2 '16 at 19:11

I think that you don't really need branch to evaluate the integral. Suppose $b>1$. Noting that $\cos\theta=\frac{1-\tan^2(\frac{\theta}2)}{1+\tan^2(\frac{\theta}2)}$ and letting $u=\tan(\frac{\theta}2)$, then one has \begin{eqnarray} \int \frac{a-\cos\theta}{b-\cos\theta}d\theta&=&x+(a-b)\int\frac{1}{b-\cos\theta}d\theta\\ &=&x+(a-b)\int\frac{1+\tan^2(\frac{\theta}2)}{(b-1)+(b+1)\tan^2(\frac{\theta}2)}d\theta\\ &=&x+(a-b)\int\frac{1+u^2}{(b-1)+(b+1)u^2}\frac{2}{1+u^2}du\\ &=&x+2(a-b)\frac{\arctan(\sqrt{\frac{b+1}{b-1}}u)}{\sqrt{b^2-1}}+C\\ &=&x+2(a-b)\frac{\arctan(\sqrt{\frac{b+1}{b-1}}\tan(\frac{\theta}2))}{\sqrt{b^2-1}}+C\\ \end{eqnarray}

• This only gives an antiderivative and doesn't answer the question about "branches" in the definite integral. $\qquad$ – Michael Hardy Sep 2 '16 at 16:59
• Yeah exactly. I'm glad to see how one can get this answer without appealing to solvers, but you have the same problem when you go to set the limits. – levitopher Sep 4 '16 at 13:15

OK, I am going to seem like I am not answering the question by ignoring the issue posed by the OP altogether. Why? Because the whole question about "branches" is an artifice of the (inferior) method of evaluating the integral. But look at the integrand: no branch points! And for $b \gt 1$, no poles in the interval of integration. So really, the whole difficulty posed by the antiderivative should make one question whether that is an appropriate way to evaluate the integral.

A better way to evaluate this integral is via expression as an integral over the unit circle in the complex plane. Then we can evaluate directly using the residue theorem. To this effect, consider the case where $b \gt 1$ and let $z=e^{i \theta}$; then the integral is equal to

$$-i \oint_{|z|=1} \frac{dz}{z} \frac{z^2-2 a z+1}{z^2-2 b z+1}$$

The poles of the integrand are at $z=0$ and $z=b \pm \sqrt{b^2-1}$; we can ignore the pole at $z=b+\sqrt{b^2-1}$ as it lies outside the unit circle. By the residue theorem, the integral is equal to $i 2 \pi$ times the sum of the residues of the poles inside the unit circle. Leaving the simple computation of the residues to the reader, I get that the integral is equal to

$$\int_0^{2 \pi} d\theta \frac{a-\cos{\theta}}{b-\cos{\theta}} = 2 \pi \left (1-\frac{b-a}{\sqrt{b^2-1}} \right )$$

This answer was derived without any questions about branches of inverse trig functions, or any other questions at all.

• This is a great technique, but not really an "answer" because I'm asking generally about what I was doing wrong (not noticing that the antiderivative was singular). Additionally, I don't want to set $b>1$ (although I didn't specify that, $b$ is generally only positive). In any case, I appreciate the contribution! – levitopher Sep 4 '16 at 13:13
• @levitopher Yes I knew that when I answered. I was just making the point that for this integral all of the analysis you need to make is not really necessary. But I understand that you were asking a specific question about your technique. – Ron Gordon Sep 4 '16 at 13:37
• @levitopher By the way, the requirement $b > 1$ is not arbitrary. When $|b| < 1$ the integral is singular. – Ron Gordon Sep 4 '16 at 13:39