Evaluate the following integrals:
$\int \frac{1}{1-\sin x+\cos x} d x$
Given $I=\int \frac{1}{1-\sin x+\cos x} d x$
We know that $\sin \mathrm{x}=\frac{2 \tan \frac{x}{2}}{1+\tan \frac{x}{2}}$ and $\cos \mathrm{x}=\frac{1-\tan ^{2} \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}}$
$\Rightarrow \int \frac{1}{1-\sin x+\cos x} d x=\int \frac{1}{1-\frac{2 \tan \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}}+\frac{1-\tan \frac{2}{2}}{1+\tan ^{2} \frac{2}{2}}} d x$
$=\int \frac{1+\tan ^{2} \frac{x}{2}}{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}}{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}}{2-2 \tan \frac{x}{2}} d x$
$=\int \frac{2 d t}{2-2 t}$
$=\int \frac{1}{1-t} d t$
We know that $\int \frac{1}{x} d x=\log |x|+c$
$\Rightarrow \int \frac{1}{1-t} d t=-\log |1-t|+c$
$=-\log \left|1-\tan \frac{x}{2}\right|+c$
$\therefore \mathrm{I}=\int \frac{1}{1-\sin \mathrm{x}+\cos \mathrm{x}} \mathrm{dx}=-\log \left|1-\tan \frac{\mathrm{x}}{2}\right|+\mathrm{c}$