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?
 A: $$\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)}$$
A: 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: 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.
A: 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.$$
A: 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
A: $$
\begin{aligned}
\int \frac{d x}{1+\sin x+\cos x} 
= & \int \frac{d x}{2 \cos ^2 \frac{x}{2}+2 \sin \frac{x}{2} \cos \frac{x}{2}}\\ &=\frac{1}{2} \int \frac{\sec ^2 \frac{x}{2}}{1+\tan \frac{x}{2}} d x\\&=\int \frac{d\left(\tan \frac{x}{2}\right)}{1+\tan \frac{x}{2}}
\\&=\ln \left|1+\tan \frac{x}{2}\right|+C
\end{aligned}
$$
