Evaluate the following integrals:
$\int \frac{1}{\sin x+\cos x} d x$
Given $I=\int \frac{1}{\sin x+\cos x} d x$
We know that $\sin x=\frac{2 \tan \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}}$ and $\cos x=\frac{1-\tan ^{2} \frac{x}{2}}{1+\tan ^{2} \frac{2}{2}}$
$\Rightarrow \int \frac{1}{\sin x+\cos x} d x=\int \frac{1}{\frac{2 \tan \frac{x}{2}}{1+\tan \frac{2}{2}}+\frac{1-\tan \frac{2}{2}}{1+\tan \frac{2}{2}}} d x$
$=\int \frac{1+\tan ^{2} \frac{x}{2}}{2 \tan \frac{x}{2}+1-\tan ^{2} \frac{x}{2}} d x$
Replacing $1+\tan ^{2} x / 2$ in numerator by $\sec ^{2} x / 2$ and putting $\tan x / 2=t$ and $\sec ^{2} x / 2 d x=2 d t$,
$\Rightarrow \int \frac{1+\tan ^{2} \frac{x}{2}}{2 \tan \frac{x}{2}+1-\tan ^{2} \frac{x}{2}} d x=\int \frac{\sec ^{2} \frac{x}{2}}{-\tan ^{2} \frac{x}{2}+2 \tan \frac{x}{2}+1} d x$
$=-\int \frac{2 d t}{t^{2}-2 t-1}$
$=-2 \int \frac{1}{(t-1)^{2}-(\sqrt{2})^{2}} d t$
$=2 \int \frac{1}{(\sqrt{2})^{2}-(t-1)^{2}} d t$
We know that $\int \frac{1}{\mathrm{a}^{2}-\mathrm{x}^{2}} \mathrm{dx}=\frac{1}{2 \mathrm{a}} \log \left|\frac{\mathrm{a}+\mathrm{x}}{\mathrm{a}-\mathrm{x}}\right|+\mathrm{c}$
$\Rightarrow 2 \int \frac{1}{(\sqrt{2})^{2}-(t-1)^{2}} d t=\frac{2}{2 \sqrt{2}} \log \left|\frac{\sqrt{2}+t-1}{\sqrt{2}-t+1}\right|+c$
$=\frac{1}{\sqrt{2}} \log \left|\frac{\sqrt{2}+\tan \frac{x}{2}-1}{\sqrt{2}-\tan \frac{x}{2}+1}\right|+c$
$\therefore \mathrm{I}=\int \frac{1}{\sin \mathrm{x}+\cos \mathrm{x}} \mathrm{dx}=\frac{1}{\sqrt{2}} \log \left|\frac{\sqrt{2}+\tan \frac{\mathrm{x}}{2}-1}{\sqrt{2}-\tan \frac{\mathrm{x}}{2}+1}\right|+\mathrm{c}$