# Find $\int_0^{2\pi}\frac1{5-4\cos x}\ dx$

$$\int_0^{2\pi}\frac1{5-4\cos x}\ dx$$ How do I compute this integral? An online integral calculator gives an antiderivative as $$\frac{2\arctan(3\tan\frac x2)}3$$ but then gives the definite integral as $\frac{2\pi}3$. Obviously this doesn't make sense as the antiderivative vanishes at $x=0$ and $x=2\pi$.

• Another way would be to use contour integration =). – Jacky Chong Sep 27 '16 at 0:52

Using complex analysis your integral can be expressed as $$\int \limits^{2\pi }_{0}\frac{1}{5-4\cos \left( x\right) } dx=\oint \frac{1}{5-2\left( z+\frac{1}{z} \right) iz} dz$$ Now we have two singularites at $z=2$and at $z=\frac {1}{2}$ Now apply Residue theorem $$\oint \frac{1}{5-2\left( z+\frac{1}{z} \right) iz} dz = 2\pi i \ \text {Res}\sum \left( f\left( z\right) , z\right)$$ We have only one singularity in the contour.
So the Residue will be $$2 \pi i \ \text {Res} \sum(f (z), z)=2 \pi i \left[\lim \limits_{z\to \frac{1}{2} }\left( 2z-1\right) \frac{1}{2i\left( -z+2\right) \left( 2z-1\right) } =\frac{1}{3i} \right]=\frac {2 \pi}{3}$$ So $$\color{Brown }{\int \limits^{2\pi }_{0}\frac{1}{5-4\cos \left( x\right) } dx=\boxed {\frac{2\pi }{3}} }$$

• I came across this integral by reducing to it from the integral of $\frac{1}{2z^2 - 5z + 2}$ about the counter clockwise unit circle. Haven't done the residue theorem yet. – Vik78 Sep 27 '16 at 6:29

Your example shows that a computer algebra system may break the Fundamental theorem of calculus. That is, it may give a different result for $\int_a^bf(x)\;\mathrm dx$ and $F(b)-F(a)$, where $F$ is an antiderivative of $f$, even if $f$ has no singularity. This is a very bad thing.

Since the fundamental theorem of calculus is true, it simply means the antiderivative must be incorrect, or the definite integral, or both.

Here the CAS may be doing what one does by hand: a change of variable $u=\tan \frac x2$ (see Tangent half-angle substitution on Wikipedia).

$$\int \frac{\mathrm dx}{5-4\cos x}= \int \frac{1}{5-4\dfrac{1-u^2}{1+u^2}}\frac{2\mathrm du}{1+u^2} =\int \frac{2\mathrm du}{1+(3u)^2}=\frac23\arctan(3u)\\=\frac23\arctan(3\tan \frac x2)$$

But you can do that only on an interval where $u=\tan \frac x2$ is a continuous and differentiable bijection, so not on $[0,2\pi]$ (it's discontinuous at $\pi$). However, you can do that on $[0,\pi[$, and

$$\int_0^{2\pi} \frac{\mathrm dx}{5-4\cos x}=2\int_0^\pi \frac{\mathrm dx}{5-4\cos x}=\frac43[\arctan(3\tan\frac x2)]_0^{\to\pi^-}=\frac23\pi$$

So what happens is this: when asked for an antiderivative, it gives one that is only valid on an interval, though the function is continuous everywhere, so there should be an antiderivative valid on the whole of $\Bbb R$. This is wrong. However, the CAS is clever enough to handle correctly the definite integral. I tried with Maxima, and it does the same.

The correct antiderivative is not given by a single expression, but a disjunction of cases:

• if $x\in]2k\pi-\pi,2k\pi+\pi[$, $F(x)=\frac23\arctan(3\tan\frac x2)+\frac23k\pi+C$
• if $x=(2k+1)\pi$, $F(x)=\frac13(2k+1)\pi+C$

Where $C$ is the same constant for all values of $x$.

Here is a plot showing the difference. The correct antiderivative (with $C=0$) is in blue, and the expression given by the CAS in red.

Notice that on all intervals $]2k\pi-\pi,2k\pi+\pi[$, the antiderivative given by the CAS is correct. It just has to be shifted properly on each interval to get a function with only removable singularities at $(2k+1)\pi$, and after defining the values at $(2k+1)\pi$, you get a continuous antiderivative on $\Bbb R$. That's how $F$ is defined above.

• Nice answer! Here's an interesting article by D. J. Jeffrey about such matters: jstor.org/stable/2690852 – Hans Lundmark Sep 27 '16 at 8:21
• @HansLundmark Very interesting article! Actually, I was wrong when I stated that the antiderivative is not given by a single expression: this article gives $$\frac13x+\frac23\arctan \frac{\sin x}{2-cos x}$$ I'll have a look at the method he develops in this article. There is the detailed derivation for the same example, $\displaystyle{\int \frac{3\mathrm dx}{5-4\cos x}}$. – Jean-Claude Arbaut Sep 28 '16 at 6:15

A simple way: $$I=\int_{0}^{2\pi}\frac{dx}{5-4\cos x}=\int_{0}^{\pi}\left(\frac{1}{5-4\cos x}+\frac{1}{5+4\cos x}\right)\,dx\tag{1}$$ $$I = 10\int_{0}^{\pi}\frac{dx}{25-16\cos^2 x}=20\int_{0}^{\pi/2}\frac{dx}{25-16\cos^2 x} \tag{2}$$ and now, by setting $x=\arctan t$, $$I = 20 \int_{0}^{+\infty}\frac{dt}{25(1+t^2)-16} = 20 \int_{0}^{+\infty}\frac{dt}{9+25 t^2}\tag{3}$$ so by setting $t=\frac{3}{5}u$, $$I = 20\cdot\frac{3}{5}\cdot\frac{1}{9}\int_{0}^{+\infty}\frac{du}{1+u^2}=\frac{4}{3}\cdot\frac{\pi}{2}=\color{red}{\frac{2\pi}{3}}.\tag{4}$$

• Really like this approach. Love the trick you use to get the first equality. – Vik78 Sep 28 '16 at 2:41
• The first line here is a beautiful observation on the graphs for those two functions. – complexmanifold May 24 '18 at 11:12