# evaluate $\int_0^{2\pi} \frac{1}{\cos x + \sin x +2}\, dx$

This is supposed to be a very easy integral, however I cannot get around.

Evaluate:

$$\int_0^{2\pi} \frac{1}{\cos x + \sin x +2}\, dx$$

What I did is:

$$\int_{0}^{2\pi}\frac{dx}{\cos x + \sin x +2} = \int_{0}^{2\pi} \frac{dx}{\left ( \frac{e^{ix}-e^{-ix}}{2i}+ \frac{e^{ix}+e^{-ix}}{2} +2\right )}= \oint_{|z|=1} \frac{dz}{iz \left ( \frac{z-z^{-1}}{2i} + \frac{z+z^{-1}}{2}+2 \right )}$$

Although the transformation is correct I cannot go on from the last equation. After calculations in the denominator there still appears $i$ and other equations of that. How can I proceed?

• This is an excellent candidate for the Weierstrass substitution. en.wikipedia.org/wiki/Tangent_half-angle_substitution – Thomas Andrews Jun 17 '15 at 3:39
• No... !! If you do that you get $0$. Why? Because $\tan \frac{x}{2}$ is not an $1-1$ function. Try it out. – Tolaso Jun 17 '15 at 3:40
• Have you tried with $\cos(x) + \sin(x) = \sqrt{2} \cos(x-\frac{\pi}{4})$? – corindo Jun 17 '15 at 3:47
• @ThomasAndrews, the OP means that both of the limits of integration become $0$, which is problematic. – user230734 Jun 17 '15 at 3:47
• If you do the substitution you get an explicit antiderivative in terms of $\tan(x/2)$. You can then evaluate the resulting improper integral (to take into account the asymptote of $\tan(x/2)$ at $x = \pi$) and get the correct answer. – Rolf Hoyer Jun 17 '15 at 3:56

Via corindo's rearrangement: we have $$I = \int_0^{2 \pi} \frac{1}{\sqrt{2}\cos(x - \pi/4) + 2}\,dx =\\ \frac 1{\sqrt{2}} \int_0^{2 \pi} \frac{1}{\cos(x - \pi/4) + \sqrt{2}}\,dx = \\ \frac 1{\sqrt{2}} \int_0^{2 \pi} \frac{1}{\cos(x) + \sqrt{2}}\,dx =\\ \frac 1{\sqrt{2}} \oint_{|z| = 1} \frac{1}{iz((z + z^{-1})/2 + \sqrt{2})}\,dx = \\ \frac {\sqrt{2}}{i} \oint_{|z| = 1} \frac{1}{(z^2 + 2\sqrt{2}z + 1)}\,dz$$ Note the integrand has one pole inside the unit circle, namely $$z_{0} = 1-\sqrt{2}$$

• There is something I do not follow here. How did the third line come up ? – Tolaso Jun 17 '15 at 4:03
• Both are the integral of the same function over a period – Omnomnomnom Jun 17 '15 at 4:03
• Whoops, made another mistake though – Omnomnomnom Jun 17 '15 at 4:04
• Good! Now that you fixed it , this suits my needs! Although @Thomas Andrews answer is also good and I have upvoted it. – Tolaso Jun 17 '15 at 4:09

Note that: $$\frac{1}{iz \left ( \frac{z-z^{-1}}{2i} + \frac{z+z^{-1}}{2}+2 \right )}$$

is a rational function. Write it as a quotient of polynomials, then factor the denominator and apply partial fractions.

If you change the integral to:

$$\int_{-\pi}^{\pi} \frac{1}{\cos x + \sin x +2}\, dx$$ you can apply the Weierstrass substitution and get:

$$\int_{-\infty}^{\infty} \frac{\frac{2}{1+t^2}}{\frac{1-t^2}{1+t^2}+\frac{2t}{1+t^2}+2}\,dt=\int_{-\infty}^{\infty}\frac{2\,dt}{2+(t+1)^2}\\=\int_{-\infty}^{\infty}\frac{dt}{1+\left(\frac{1+t}{\sqrt 2}\right)^2}$$

Substituting $u=\frac{1+t}{\sqrt{2}}$ gives:

$$=\sqrt{2}\int_{-\infty}^{\infty} \frac{du}{1+u^2}=\sqrt{2}\pi$$

• So you mean to apply partial decomposition? – Tolaso Jun 17 '15 at 4:01
• No idea what partial decomposition is. I said partial fractions, and that is what I meant. @Tolaso – Thomas Andrews Jun 17 '15 at 4:04
• It is exaclty the same. (+1) – Tolaso Jun 17 '15 at 4:07
• Thank you Thomas for providing also the solution with real analysis. – Tolaso Jun 17 '15 at 4:17