# Integrating $\int\dfrac{\mathrm{d}x}{1+\sin x+\cos x}$

I am having a hard time with this integration: $$\int\frac{\mathrm{d}x}{1+\sin x+\cos x}$$

I would prefer a hint to solve this.

Also, any other method except the conventional method is also welcome.

• You could use the Weierstrass substitution. It's straightforward, but will work for sure. Jun 4, 2014 at 7:10

For problem, of this type, Weierstrass substitution (or tangent half-angle substitution) is extremely useful. Using $t=\tan(x/2)$, you have $$\sin(x)=\frac{2t}{1+t^2}$$ $$\cos(x)=\frac{1-t^2}{1+t^2}$$ $$dx=\frac{2dt}{1+t^2}$$ So, for the integral $$\int\frac{dx}{1+\sin x+\cos x}=\int\frac{dt}{1+t}$$
The $1+\cos x$ suggests replacing it by $2\cos^2\frac x2$. Knowing that $\sin x=2\sin\frac x2\cos\frac x2$, it becomes $$\frac12\int\frac{dx}{\cos\frac x2(\sin\frac x2+\cos\frac x2)}.$$ The next thing we could do is partial fraction decomposition, to get rid of the product in the denominator. Writing $$\frac1{\cos y(\sin y+\cos y)}=\frac{a\sin y +b\cos y}{\sin y+\cos y}+\frac{c\sin y+d\cos y}{\cos y}$$ we find $a=-1$, $b=1$, $c=1$ and $d=0$.
Using this we get $$\int\frac{\cos\frac x2-\sin\frac x2}{\sin\frac x2+\cos\frac x2}\frac{dx}2-\int\frac{-\sin\frac x2}{\cos\frac x2}\frac{dx}2.$$ Coincidentally, this is precisely $$\int\frac{d(\sin\frac x2+\cos\frac x2)}{\sin\frac x2+\cos\frac x2}-\int\frac{d(\cos\frac x2)}{\cos\frac x2}$$ wich is $$\log\left|\sin\frac x2+\cos\frac x2\right|-\log\left|\cos\frac x2\right|=\log\left|1+\tan\frac x2\right|.$$
Multiply and divide by $$1-\sin x - \cos x$$ : $$I=\int \frac{1-\sin x - \cos x} {1-\sin^2 x-\cos^2 x-2\sin x \cos x}\mathrm{d}x= - \int \frac{1-\sin x - \cos x} {2\sin x \cos x}\mathrm{d}x$$ Now you have $$3$$ simple integrals: $$I=-\frac{1}{2}\int \frac{1}{\sin x \cos x} \mathrm{d}x+\frac{1}{2}\left(\int \sec x \mathrm{d}x+\int \csc x \mathrm{d}x\right)$$ To solve the first one, rewrite $$1$$ as $$\sin^2 x+\cos^2x$$, whereas the other two integrals are elementary.