Question:
$\frac{1}{1-\tan x}$
Solution:
Let $I=\int \frac{1}{1-\tan x} d x$
$=\int \frac{1}{1-\frac{\sin x}{\cos x}} d x$
$=\int \frac{\cos x}{\cos x-\sin x} d x$
$=\frac{1}{2} \int \frac{2 \cos x}{\cos x-\sin x} d x$
$=\frac{1}{2} \int \frac{(\cos x-\sin x)+(\cos x+\sin x)}{(\cos x-\sin x)} d x$
$=\frac{1}{2} \int 1 d x+\frac{1}{2} \int \frac{\cos x+\sin x}{\cos x-\sin x} d x$
$=\frac{x}{2}+\frac{1}{2} \int \frac{\cos x+\sin x}{\cos x-\sin x} d x$
Put $\cos x-\sin x=t \Rightarrow(-\sin x-\cos x) d x=d t$
$\begin{aligned} \therefore I &=\frac{x}{2}+\frac{1}{2} \int \frac{-(d t)}{t} \\ &=\frac{x}{2}-\frac{1}{2} \log |t|+\mathrm{C} \\ &=\frac{x}{2}-\frac{1}{2} \log |\cos x-\sin x|+\mathrm{C} \end{aligned}$