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$.
Solution 1:
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.
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:
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).
Solution 2:
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}$$
Solution 3:
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}} }$$