# Integral with two different answers using real and complex analysis

The integral is$$\int_0^{2\pi}\frac{\mathrm dθ}{2-\cosθ}.$$Just to skip time, the answer of the indefinite integral is $$\dfrac2{\sqrt{3}}\tan^{-1}\left(\sqrt3\tan\left(\dfracθ2\right)\right)$$.

Evaluating it from $$0$$ to $$2 \pi$$ yields$$\frac2{\sqrt3}\tan^{-1}(\sqrt3 \tanπ)-\frac2{\sqrt3}\tan^{-1}(\sqrt3 \tan0)=0-0=0.$$But using complex analysis, the integral is transformed into$$2i\int_C\frac{\mathrm dz}{z^2-4z+1}=2i\int_C\frac{\mathrm dz}{(z-2+\sqrt3)(z-2-\sqrt3)},$$ where $$C$$ is the boundary of the circle $$|z|=1$$. Then by Cauchy's integral formula, since $$z=2-\sqrt3$$ is inside the domain of the region bounded by $$C$$, then: $$2i\int_C\frac{\mathrm dz}{(z-2+\sqrt3)(z-2-\sqrt3)}=2πi\frac{2i}{2-\sqrt3-2-\sqrt3}=2πi\frac{2i}{-2\sqrt3}=\frac{2π}{\sqrt3}.$$

Using real analysis I get $$0$$, using complex analysis I get $$\dfrac{2π}{\sqrt3}$$. What is wrong?

• OK, so I only spotted this after I already knew what the answer was, but nonetheless: notice that the integrand is always strictly positive, so the integral can't possibly be 0. – Ben Millwood Jan 2 at 12:56

The problem with the real approach is that you make the change of variable $$t=\tan\left(\dfrac{\theta}{2}\right)$$ for $$0 < \theta < 2 \pi$$.

This is problematic since your substitution need to be defined and continuous for all $$\theta$$, but you have a problem when $$\theta=\pi$$.

Edit: Note that if you split the integral into $$\int_0^\pi+\int_\pi^{2 \pi}$$, you are going to get the right answer, as for one integral you are going to get $$\arctan(- \infty)$$ and for the other $$\arctan(+\infty)$$:

$$\int_0^{2 \pi} \frac{\mathrm{d}θ}{2-\cos \theta}=\int_0^\pi \frac{\mathrm{d}θ}{2-\cos \theta}+\int_\pi ^{2 \pi} \frac{\mathrm{d}θ}{2-\cos \theta}\\ = \lim_{r \to \pi_-} \int_0^r \frac{\mathrm{d}θ}{2-\cos \theta}+ \lim_{w \to \pi_+} \int_w^{2 \pi} \frac{\mathrm{d}θ}{2-\cos \theta}\\= \lim_{r \to \pi_-} \left(\frac{2\tan^-1( \sqrt{3} \tan( \frac{ r}{2}))}{ \sqrt{3}}-0\right)+ \lim_{w \to \pi_+}\left(0- \frac{2\tan^-1( \sqrt{3} \tan( \frac{ r}{2}))}{ \sqrt{3}}\right).$$

• Oh I see, so I have to solve it without this substitution? Or could I keep this substitution and change something else? – khaled014z Jan 2 at 0:26
• @khaled014z See the edit. Let me know if you want more details. – N. S. Jan 2 at 0:27
• Brilliant, that was kind of a tricky substitution, thank you – khaled014z Jan 2 at 0:31
• When this is next edited, you want tan^{-1} twice in the last line. – Teepeemm Jan 2 at 14:12

Note that that tangent function, $$\tan(x)$$, is discontinuous when $$x=\pi/2+n\pi$$. So, the antiderivative $$\frac2{\sqrt{3}} \arctan\left(\sqrt 3 \tan(\theta/2)\right)$$ is not valid over the interval $$[0,2\pi]$$.

$$\int_0^{2\pi}\frac{1}{2-\cos(\theta)}\,d\theta=2\int_0^\pi\frac{1}{2-\cos(\theta)}\,d\theta=\frac{4}{\sqrt3}\left.\left(\arctan\left(\sqrt 3 \tan(\theta/2)\right)\right)\right|_0^\pi=\frac{2\pi}{\sqrt3}$$
• Don't you mean $x = \frac{\pi}{2} + n\pi$? – user150203 Jan 2 at 3:18