Antiderivative of $\frac{1}{1+\sin {x} +\cos {x}}$ How do we arrive at the following integral
$$\displaystyle\int\dfrac{dx}{1+\sin {x}+\cos {x}}=\log {\left(\sin {\frac{x}{2}}+\cos {\frac{x}{2}}\right)}-\log {\left(\cos {\frac{x}{2}}\right)}+C\ ?$$
 A: You can use the standard substitution 
\begin{align}
u=\tan{\frac{x}{2}}
\end{align}
Then
\begin{align}
\sin{x}=\frac{2u}{1+u^2}\\
\cos{x}=\frac{1-u^2}{1+u^2}\\
dx=\frac{2}{1+u^2}du\\
\end{align} 
You will end up with a rational function as an integrand. Use partial fractions to integrate then.

Edit:
The evalaution of this integral isn't too tedious after all. Turns out that the $u^2$ terms cancel so we are left with a linear denominator.
\begin{align}
\int\frac{dx}{1+\sin x+\cos x}
&=2\int\frac{du}{1+u^2+2u+1-u^2}\\
&=\log(1+u)+c\\
&=\log\left(1+\tan{\frac{x}{2}}\right)+c\\
\end{align}
A: Hint :
Rewrite the integrand as
\begin{align}
\frac{1}{1+\color{blue}{\sin x}+\color{red}{\cos x}}&=\frac{1}{\sin^2\frac x2+\cos^2\frac x2+\color{blue}{2\sin\frac x2\cos\frac x2}+\color{red}{\cos^2\frac x2-\sin^2\frac x2}}\\
&=\frac{1}{2\cos\frac x2\left(\sin\frac x2+\cos\frac x2\right)}\\
&=\frac{\sin\frac x2}{2\cos\frac x2}+\frac{\cos\frac x2-\sin\frac x2}{2\left(\sin\frac x2+\cos\frac x2\right)}.
\end{align}
Then use
$$
\int\frac{f'(x)}{f(x)}\ dx=\ln\left|f(x)\right|+C.
$$
I think this way will obtain a shorter way than a standard Weierstrass substitution.
A: Another way :
\begin{align}
\int\frac{1}{1+\color{blue}{\sin x}+\color{red}{\cos x}}\ dx&=\int\frac{1}{\sin^2\frac x2+\cos^2\frac x2+\color{blue}{2\sin\frac x2\cos\frac x2}+\color{red}{\cos^2\frac x2-\sin^2\frac x2}}\ dx\\
&=\int\frac{1}{2\cos\frac x2\left(\sin\frac x2+\cos\frac x2\right)}\ dx\\
&=\int\frac{1}{2\cos^2\frac x2\left(\tan\frac x2+1\right)}\ dx\\
&=\int\frac{\frac12\sec^2\frac x2}{1+\tan\frac x2}\ dx\\
&=\int\frac{d\left(\tan\frac x2\right)}{1+\tan\frac x2}\\
&=\ln\left|1+\tan\frac x2\right|+C,
\end{align}
then use trigonometric identity: $\displaystyle\color{blue}{\tan\frac x2=\frac{\sin\frac x2}{\cos\frac x2}}$ and will, of course, obtain the desired answer.
A: $$1+\cos x=2\cos^2\frac x2$$
$$1+\cos x+\sin x=2\cos^2\frac x2+2\sin\frac x2\cos\frac x2=2\cos\frac x2\left(\sin\frac x2+\cos\frac x2\right)$$
$$=\sqrt2\cos\frac x2\cos\left(\frac\pi4-\frac x2\right)$$
For numerator, $$\cos\frac\pi4=\cos\left[\frac x2-\left(\frac\pi4-\frac x2\right)\right]$$
