# Evaluate $\int \frac{dx}{1+\sin x+\cos x}$

Evaluate $$\int \frac{1}{1+\sin x+\cos x}\:dx$$

I tried several ways but all of them didn't work

I tried to use Integration-By-Parts method but it's going to give me a more complicated integral

I also tried u-substitution but all of my choices of u didn't work

Any suggestions?

• Did you try substitutions related to $t = \tan x/2$? – Simon S Apr 11 '15 at 16:16
• No!. But how is this substitution going to make the intgeral simpler? – Maher Apr 11 '15 at 16:34

$$\int \frac{1}{1+\sin x+\cos x}\:dx\stackrel{t=\tan(x/2)}=\int\frac{dt}{1+t}=\ln |1+t|+c=\ln|1+\tan(x/2)|+c$$

As $dt=\frac12\sec^2(x/2)dx\implies 2dt=(1+\tan^2(x/2))dx\implies 2dt=(1+t^2)dx$ where: $$\frac{1}{1+\sin x+\cos x}=\frac{1}{1+\frac{2t}{1+t^2}+\frac{1-t^2}{1+t^2}}=\frac{1+t^2}{1+t^2+2t+1-t^2}=\frac{1+t^2}{2t+2}=\frac{\frac{2dt}{dx}}{2(1+t)}$$

• why is $tan(x/2)$? how did you change the denominator? – Maher Apr 11 '15 at 16:33
• @Maher $\tan (\frac12 x)$ is an all-purpose trick when deal with integrals involving $\sin, \cos, \tan$ in a rational combination. – Vim Apr 11 '15 at 16:43
• @Maher edited . – RE60K Apr 11 '15 at 16:44
• why -1? who? why? – RE60K Apr 12 '15 at 5:24

Write $\sin(x)$ in the denominator as $2\sin(x/2)\cos(x/2)$ and $\cos(x)$ as $2(\cos(x/2))^2-1$. Now the 1s get cancelled. Take $(\cos(x/2))^2$ out from the denominator and send it to numerator as $(\sec(x/2))^2$. Now you arrived at $\frac{\sec(x/2)^2}{2 \tan(x/2) + 2}$. Proceed.

• A good answer for those that are not already familiar with the power of the $t=\tan(x/2)$ substitution. I fixed your formatting to use MathJax. – Ian Apr 11 '15 at 16:23
• Please use latex for your maths text next time.. See here. – Mattos Apr 11 '15 at 16:23
• Without properly typing your answer it has a light chance it will even get read by many in the site: meta.math.stackexchange.com/questions/5020/… – Timbuc Apr 11 '15 at 16:23
• Duly noted.Will do next time. – GrandAlpha Apr 11 '15 at 16:25
• Personally I hate using the Weierstrass substitution, and only as a last-ditch effort, because you end up with really messy rational functions. – Dylan Apr 12 '15 at 0:17

It is easy to recall the half-angle identities \begin{align*} \sin \frac{x}{2} &= \sqrt{\frac{1-\cos x}{2}}, \\ \cos \frac{x}{2} &= \sqrt{\frac{1+\cos x}{2}}, \end{align*} from which the tangent half-angle identity can be written $$\tan^2 \frac{x}{2} = \frac{1-\cos x}{1+\cos x} = \frac{\sin^2 x}{(1+\cos x)^2},$$ and it follows that $$\color{red}{\boxed{\displaystyle \tan \frac{x}{2} = \frac{\sin x}{1+\cos x}, \quad \sec^2 \frac{x}{2} = \frac{2}{1+\cos x}}}.$$ (Indeed, there are numerous methods of proving the boxed identities.) Hence $$\frac{1}{1 + \sin x + \cos x} = \frac{\frac{1}{1+\cos x}}{1 + \frac{\sin x}{1+\cos x}} = \frac{\frac{1}{2} \sec^2 \frac{x}{2}}{1 + \tan \frac{x}{2}}$$ and the substitution $$u = \tan \frac{x}{2}, \quad du = \frac{1}{2} \sec^2 \frac{x}{2} \, dx$$ immediately leads to $$\int \frac{dx}{1+\sin x + \cos x} = \int \frac{du}{1+u} = \log |1+u| + C = \log \left| 1 + \tan \frac{x}{2} \right| + C.$$

If you want to avoid the Weierstrass substitution ($t = \tan(\frac{x}{2})$), you can multiply the top and bottom by $1+ \sin(x) - \cos(x)$. $$\int \frac{dx}{1+\sin(x) + \cos(x)} = \int \frac{(1 + \sin(x) - \cos(x))dx}{1 + 2\sin(x) + \sin^2(x) - \cos^2(x)}$$ $$= \int \frac{1 + \sin(x)dx}{2\sin(x) + 2\sin^2(x)} - \int \frac{\cos(x)dx}{2\sin(x) + 2\sin^2(x)}$$ $$= \int {\frac{\csc(x)dx}{2}}- \frac{1}{2}\int \Big(\frac{\cos(x)}{\sin(x)} - \frac{\cos(x)}{(1 + \sin(x))}\Big)dx = \cdots$$ The last two integrals can be solved using the methods you already know.

• by u-substitution? last one? – RE60K Apr 12 '15 at 5:26
• @ADG. The integral of $\csc(x)$ is a common trig integral and the OP has probably seen it before and the integral of $\Big(\frac{\cos(x)}{\sin(x)} - \frac{\cos(x)}{(1 + \sin(x))}\Big)$ can be solved with a u-substitution. – user222031 Apr 12 '15 at 17:25
• why don't we use u at the beginning, what do we acheive with this manipulation? was my question actually. – RE60K Apr 13 '15 at 10:38
• @ADG. Based on the OP's comment they probably have not seen that substitution before, so it might have seemed unintuitive. I guess it's basically the same thing except the $t = \tan(\frac{x}{2})$ substitution is more versatile. – user222031 Apr 13 '15 at 15:03

Notice $\sin{x}+\cos{x}=\sqrt{2}\sin(x+\frac{\pi}{4})$

Setting $x+\frac{\pi}{4}=v$ it remains to evaluate

$\int \frac{1}{1+\sqrt{2}\sin{v}}dv$

Now we use Weierstrauss and it remains to compute

$\int \frac{2}{t^2+2\sqrt{2}t+1}dt=\int \frac{2}{(t+\sqrt{2})^2-1}dt$

And the rest is a basic partial fraction and we're done