How to Evaluate $\int \! \frac{dx}{1+2\cos x}$ ? [duplicate]

Possible Duplicate:
How do you integrate $\int \frac{1}{a + \cos x} dx$?

I have come across this integral and I tried various methods of solving. The thing that gets in the way is the constant $2$ on the $\cos(x)$ term. I tried the conjugate (works without the 2$\cos x$), Weierstrass Substitution (not sure if I was applying it correctly), and others. Is there a way to solve this integral elegantly or some unknown (sneaky) trick when you come across families of similar integrals as this one?:

$$\int \! \frac{dx}{1+2\cos x}$$

-

marked as duplicate by Willie WongJun 19 '12 at 12:50

Weierstrass substitution works for this integral, and it's not even that messy to work with.

Substitute $\tan \frac{x}{2} = t$, so that $\cos x = \frac{1-t^2}{1+t^2}$ and $dx = \frac{2dt}{1+t^2}$. Then the integral reduces to $$\int \frac{dx}{1+2 \cos x} = \int \frac{\frac{2}{1+t^2}}{1 + \frac{2(1-t^2)}{1+t^2}} dt = \int \frac{2}{1+t^2 + 2 - 2t^2} dt = \int \frac{2}{3-t^2} dt.$$ To evaluate the final integral, we can use the method of partial fractions: $$\frac{2}{3-t^2} = \frac{1}{\sqrt{3}} \left( \frac{1}{t + \sqrt{3}} - \frac{1}{t - \sqrt{3}} \right).$$

-
Thanks. Seems I did the same exact thing, I think I just messed up with the simplification after making the $\cos x$ and $\mathrm{d}x$ substitution. Good work. I will go back and make sure I get $\int \! \frac{2}{3-t^2}\,\mathrm{d}t$. Do you not get $-\int \! \frac{2}{t^2-3}$ after simplifying? Is there something I'm not seeing you pulled out? – night owl Oct 17 '11 at 5:14
@nightowl The expression $\dfrac{2}{3-t^2}$ is the same as: $\dfrac{-2}{t^2-3}$. – Srivatsan Oct 17 '11 at 5:15
@nightowl I have elaborated the relevant step a little. Hope that helps. – Srivatsan Oct 17 '11 at 5:27

$I=\int \frac{\mathrm{d}x}{1+2\cos x}$

$=\int\frac{\mathrm{d}x}{\sin^2(x/2)+\cos^2(x/2)+2(\cos^2(x/2)-\sin^2(x/2))}$

$=\int \frac{\mathrm{d}x}{3\cos^2(x/2)-\sin^2(x/2)}$

Multiply the Nr and the Dr of the integrand by $\sec^2 (x/2)$.

You will get:

$\int \frac{\sec^2(x/2)\mathrm{d}x}{3-\tan^2(x/2)}$

Substitution:

$z=\tan(x/2)$

$\mathrm{d}z=1/2 \sec^2(x/2) \mathrm{d}x$

Therefore,

Integral=$\int \frac {2\mathrm{d}z}{3-z^2}$

$=\int \frac{1}{\sqrt{3}}(\frac{1}{\sqrt{3}+z}+\frac{1}{\sqrt{3}-z})\mathrm{d}z$

-

Generalization:

Let's consider $\cos x = \frac{1-t^2}{1+t^2}; t = \tan\frac{x}{2}; dx=\frac{2}{1+t^2} dt.$ Then we get that our integral becomes:

$$J = \int \frac{2dt}{(a+b)+(a-b) t^2}$$

I. For the case $a>b$, consider $a+b=u^2$ and $a-b=v^2$, and obtain that: $$J = 2\int \frac{dt}{u^2+v^2 t^2}=\frac{2}{uv} \arctan\frac{vt}{u} +C.$$ Turning back to our notation we get: $$I=\frac{2}{\sqrt{a^2-b^2}} \arctan\left(\sqrt{\frac{a-b}{a+b}} \tan\frac{x}{2} \right) + C.$$

II. For the case $a<b$, consider $a+b=u^2$ and $a-b=-v^2$, and obtain that: $$J = 2\int \frac{dt}{u^2-v^2 t^2}=\frac{1}{uv}\ln\frac{u+vt}{u-vt} \ +C.$$

Turning back again to out initial notation and have that:

$$I=\frac{2}{\sqrt{b^2-a^2}} \ln\frac{b+a \cos x + \sqrt{b^2-a^2} \sin x}{a+b \cos x} + C.$$

Also, note that $x$ must be different from ${+}/{-}\arccos(-\frac{a}{b})+2k\pi$ if $|\frac{a}{b}|\leq1$.

Q.E.D.

-
It is a nice post and all, but is it necessary to post the same answer twice? :) – Willie Wong Jun 19 '12 at 12:51
@Willie Wong: i remember the first days i came here and it wasn't easy to find things i needed. For some new users, this would be of great benefit. Moreover, the problems are different, but the generalization works on both of them. – user 1618033 Jun 19 '12 at 13:01