# How to evaluate $\int_0^{2\pi} \frac{d\theta}{A+B\cos\theta}$?

I'm having a trouble with this integral expression:

$$\int_0^{2\pi} \frac{d\theta}{A+B \cos\theta}$$

I've done this substitution: $t= \tan(\theta/2)$

and get: $\displaystyle \cos\theta= \frac{1-t^2}{1+t^2}$ and $\displaystyle d\theta=\frac{2}{1+t^2}dt$ where $\displaystyle \cos^2\theta/2=\frac{1}{1+t^2}$

then the integral becomes:

$$\int\frac{2 \, dt}{(A-B)t^2+(A+B)}= \sqrt\frac{A+B}{A-B} \arctan \left(\left(\sqrt\frac{A+B}{A-B} \right) t\right)$$

However, I'm not sure about the new limits since $\tan$ has period $\pi$ so what I have to do at this point to decide the new limits? And of course if you find some mistake in what I've done before, please let me know!

-
Hint: $\displaystyle \int_0^{2\pi} \frac{d\theta}{A+B\cos\theta} = 2 \displaystyle \int_0^{\pi} \frac{d\theta}{A+B\cos\theta}.$ – NeverBeenHere Dec 21 '12 at 20:24
Are you dealing with explicit $A$ and $B$? Sometimes the integral will not even converge. – André Nicolas Dec 21 '12 at 20:26
By the way, you don't have to use Weierstrass substitution that explicitly since we can write: \begin{aligned}I & = \frac{1}{a+b\cos{x}}\\& =\frac{1}{a\left(\sin^2 \frac{1}{2}x+\cos^2\frac{1}{2}x\right)+b\left(\cos^2 {\frac{1}{2}x}-\sin^2\frac{1}{2}x\right)} \\& =\frac{1}{(a-b)\sin^2\frac{1}{2}x+(a+b)\cos^2\frac{1}{2}x} \\& =\frac{\sec^2{\frac{1}{2}x}}{(a+b)+(a-b)\tan^2\frac{1}{2}x}. \end{aligned} – NeverBeenHere Dec 21 '12 at 20:36

To avoid confusion with limits, note that $$\int_0^{\pi} \dfrac{dx}{a+b \cos(x)} = \int_{\pi}^{2\pi} \dfrac{dx}{a+b \cos(x)}$$ Hence, we have $$I = \int_0^{2\pi} \dfrac{dx}{a+b \cos(x)} = 2\int_0^{\pi} \dfrac{dx}{a+b \cos(x)}$$ Now use your substitution $t = \tan(x/2)$ and note that $t$ goes from $0$ to $\infty$ as $x$ goes from $0$ to $\pi$.

EDIT

An easier way if you are familiar with a little bit of complex analysis is as follows.

Let $z = e^{ix}$. Then we have that $dz = iz dx$. Hence, \begin{align} I & = \int_0^{2 \pi} \dfrac{dx}{a+b \cos(x)} = \oint_{\vert z \vert = 1} \dfrac{dz}{iz \left( a + \dfrac{b}2 \left(z+ \dfrac1z \right)\right)}\\ & = \dfrac1i \oint_{\vert z \vert = 1} \dfrac{dz}{az + \dfrac{b}2 \left(z^2+1 \right)} = \dfrac2{ib} \oint_{\vert z \vert = 1}\dfrac{dz}{z^2 + \dfrac{2a}b z + 1}\\ & = \dfrac2{ib} \oint_{\vert z \vert = 1} \dfrac{dz}{\left(z + \dfrac{a}b \right)^2 + 1 - \dfrac{a^2}{b^2}} = \dfrac2{ib} \oint_{\vert z \vert = 1} \dfrac{dz}{\left(z + r + \sqrt{r^2-1} \right)\left(z + r - \sqrt{r^2-1} \right)} \end{align} where $r = \dfrac{a}b \in \mathbb{R}$.

First note that if $\vert r \vert \leq 1$, then $\left \vert r \pm \sqrt{r^2-1} \right \vert = 1$. Hence, the integral doesn't exist.

If $r > 1$, then $\left \vert r + \sqrt{r^2 - 1} \right \vert > 1$ and $\left \vert r - \sqrt{r^2-1} \right \vert < 1$. Hence, by Cauchy integral formula, we have that $$I = \dfrac{2}{ib} 2 \pi i \dfrac1{2 \sqrt{r^2-1}} = \dfrac{2 \pi \, \text{sign}(a)}{\sqrt{a^2 - b^2}}$$

If $r < -1$, then $\left \vert r - \sqrt{r^2 - 1} \right \vert > 1$ and $\left \vert r + \sqrt{r^2-1} \right \vert < 1$. Hence, by Cauchy integral formula, we have that $$I = \dfrac{2}{ib} 2 \pi i \dfrac{-1}{2 \sqrt{r^2-1}} = \dfrac{2 \pi \, \text{sign}(a)}{\sqrt{a^2 - b^2}}$$ Hence, to summarize, $$I = \begin{cases} \dfrac{2 \pi \, \text{sign}(a)}{\sqrt{a^2 - b^2}} & \text{if } \vert a \vert > \vert b\\ \text{Does not exists} & \text{if } \vert a \vert \leq \vert b\end{cases}$$

-
But you'd better have $|a| > |b|$ to avoid zeros of the denominator. – Robert Israel Dec 21 '12 at 20:35

Ideally, you want to do your substitution on a domain where it is defined, continuous, and invertible.

That's not quite true here, as this plot shows.

But we can carefully break the domain up into parts where the substitution behaves nicely, sort of, by splitting $\theta \in [0, 2 \pi]$ into two regions $\theta \in [0, \pi]$ and $\theta \in [\pi, 2 \pi]$. Note that we really should break the integral up into two integrals, one over each domain.

Over $\theta \in [0,\pi]$, $t$ varies from $0$ to $+\infty$; so the substitution is problematic! However, you can still set up the improper integral, and take care to show that it converges to the right thing.

You can treat $\theta \in [\pi, 2\pi]$ similarly.

Of course, once you've set that up, it's clear you can put the integrals back together, since $\int_0^{+\infty} f + \int_{-\infty}^0 f = \int_{-\infty}^{+\infty} f$. You could have observed this by changing the original limits of integration from $[0, 2\pi]$ to $[-\pi, \pi]$ because the integrand was periodic.

P.S. there's one extra problem with your integral: the integrand diverges at the $\theta$ where $A + B \cos \theta = 0$. Such solutions exist if $|A| \leq |B|$. So you have to handle the improperness of that as well. (notice that your solution method for the transformed integral assumes this, and possibly more)

-

By periodicity and parity of $\cos$ $$\int\limits_0^{2\pi} \dfrac{d\theta}{A+B\cos\theta}=\int\limits_{-\pi}^{\pi} \dfrac{d\theta}{A+B\cos\theta}=2\int\limits_0^{\pi} \dfrac{d\theta}{A+B\cos\theta}$$

-

As $\theta$ goes from $0$ to $2\pi$, $\theta/2$ goes from $0$ to $\pi$, so $\tan(\theta/2)$ goes from $0$ up to $+\infty$ and then from $-\infty$ up to $0$. Add the two together and you get $\displaystyle\int_{-\infty}^\infty$.

-