<s>[INST] 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?
 [/INST] 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.$$
</s>