6

$$\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$.

Jean-Claude Arbaut
  • 23,601
  • 7
  • 53
  • 88
Vik78
  • 3,963

6 Answers6

12

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.

enter image description here

Edit:

With Maple, the indefinite integral fails as expected, by giving the simpler $\frac23\arctan(3\tan(\frac x2))$. However, it seems smart enough to give a correct solution for the definite integral, with int(1/(5-4*cos(t)), t=0..x, AllSolutions);

The result, with no editing apart from translation to LaTeX:

$$\frac13\left\{\begin{array}{lr} 2\pi\lceil-\frac{\pi-x}{2\pi}\rceil+\left\{\begin{array}{lr} \pi, & -\frac{\pi-x}{2\pi}\in\Bbb Z \\ 2\arctan(3\tan\frac x2), & \mathrm{otherwise} \end{array}\right., & 0<x\\ 2\pi\lfloor-\frac{\pi-x}{2\pi}\rfloor+2\pi-\left\{\begin{array}{lr} \pi, & -\frac{\pi-x}{2\pi}\in\Bbb Z\\ -2\arctan(3\tan\frac x2) & \mathrm{otherwise} \end{array}\right., & x\le0 \end{array}\right.$$

It's not the simpler answer $\frac x3+\frac23\arctan(\frac{\sin x}{2-\cos x})$, but at least it will give the correct result for the integral on $[0,2\pi]$, when evaluating $F(2\pi)-F(0)$, where $F(x)$ is the expression above.

And here is the plot of the expression above in blue, together with the computed indefinite integral in red:

enter image description here

Other computer algebra systems may be able to do the same, possibly with extra options (here AllSolutions is required for Maple to give the full answer).

Jean-Claude Arbaut
  • 23,601
  • 7
  • 53
  • 88
  • Nice answer! Here's an interesting article by D. J. Jeffrey about such matters: http://www.jstor.org/stable/2690852 – Hans Lundmark Sep 27 '16 at 08: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 06:15
8

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}$$

Jack D'Aurizio
  • 361,689
  • 1
    Really like this approach. Love the trick you use to get the first equality. – Vik78 Sep 28 '16 at 02:41
  • The first line here is a beautiful observation on the graphs for those two functions. –  May 24 '18 at 11:12
5

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 06:29
1

Sorry for being late

By ‘Rationalisation’

$$ \begin{aligned} \int_0^{2 \pi} \frac{d x}{5-4 \cos x}=&2 \int_0^\pi \frac{d x}{5-4 \cos x} \\ = & 2 \int_0^\pi \frac{5+4 \cos x}{25-16 \cos ^2 x} d x \\ = & 10 \int_0^\pi \frac{d x}{25-16 \cos ^2 x}+8 \int_0^\pi \frac{\cos x}{25-16 \cos ^2 x} d x \\ = & 20 \int_0^{\frac{\pi}{2}} \frac{\sec ^2 x}{25 \sec ^2 x-16} d x+8 \int_0^\pi \frac{d(\sin x)}{9+\sin ^2 x} \\ = & 4 \int_0^{\frac{\pi}{2}} \frac{d(5 \tan x)}{(5 \tan x)^2+3^2}+\frac{8}{3}\left[\tan ^{-1}\left(\frac{\sin x}{3}\right)\right]_0^\pi \\ = & \frac{4}{3}\left[\tan ^{-1}\left(\frac{5 \tan x}{3}\right)\right]_0^{\frac{\pi}{2}} \\ = & \frac{2 \pi}{3} \end{aligned} $$

Lai
  • 31,615
0

By Weierstrass Substitution:

By symmetry, we can half the integration interval as

$$ \int_0^{2 \pi} \frac{1}{5-4 \cos x} d x=2 \int_0^\pi \frac{1}{5-4 \cos x} d x $$

Putting $t=\tan \frac{x}{2}$ transforms the integral into $$ \begin{aligned} I & =2 \int_0^\pi \frac{1}{5-\frac{4\left(1-t^2\right)}{1+t^2}} \cdot \frac{2 d t}{1+t^2} \\ & =4 \int_0^{ \infty} \frac{d t}{9 t^2+1} \\ & =\frac{4}{3}\left[\tan ^{-1}(3 t)\right]_0^{\infty} \\ & =\frac{2 \pi}{3} \end{aligned} $$

Lai
  • 31,615
0

Utilize the vanishing integral $I(r)=\int_0^{2\pi} \ln(1-2r\cos x+r^2)dx=0$ $$4\int^{2\pi }_{0}\frac{1-2\cos x}{5-4\cos x} dx \overset{r=\frac12}= \int^{2\pi }_{0}\frac{2r-2\cos x}{1-2r\cos x+r^2} dx = I’(r)=0 $$ Then $$\int_0^{2\pi}\frac{1}{5-4\cos x}dx = \frac23\int_0^{2\pi}\left( \frac12-\frac{1-2\cos x}{5-4\cos x}\right)dx =\frac{2\pi}3$$

Quanto
  • 120,125