<s>[INST] Integrating $ \int \frac{1}{1-\tan(x)}dx $ $$ \int \frac{dx}{1-\tan(x)} $$
Please help me to solve this problem as I'm trying this since last 1 day...
 [/INST] An alternative is to use the substitution $t=\tan x$ and then expand into partial fractions. 
$$\begin{equation*}
dt=\left( 1+\tan ^{2}x\right) dx=\left( 1+t^{2}\right) dx
\end{equation*}$$
$$\begin{equation*}
I=\int \frac{1}{1-\tan x}dx=\int \frac{1}{\left( 1-t\right) \left(
1+t^{2}\right) }\,dt.
\end{equation*}$$
Since
$$\begin{equation*}
\frac{1}{\left( 1-t\right) \left( 1+t^{2}\right) }=\frac{1}{2\left(
1-t\right) }+\frac{1}{2}\frac{t}{1+t^{2}}+\frac{1}{2}\frac{1}{1+t^{2}},
\end{equation*}$$
we have
$$\begin{eqnarray*}
I &=&\frac{1}{2}\int \frac{1}{1-t}\,dt+\frac{1}{2}\int \frac{t}{1+t^{2}}\,dt+
\frac{1}{2}\int \frac{1}{1+t^{2}}\,dt \\
&=&-\frac{1}{2}\ln \left\vert 1-t\right\vert +\frac{1}{4}\ln \left\vert
1+t^{2}\right\vert +\frac{1}{2}\arctan t+C \\
&=&-\frac{1}{2}\ln \left\vert 1-\tan x\right\vert +\frac{1}{4}\ln \left\vert
1+\tan ^{2}x\right\vert +\frac{x}{2}+C \\
&=&-\frac{1}{2}\ln \left\vert 1-\tan x\right\vert +\frac{1}{2}\ln \left\vert
\sec x\right\vert +\frac{x}{2}+C. 
\end{eqnarray*}$$
This can be written as
$$\begin{eqnarray*}
I &=&-\frac{1}{2}\ln \left\vert \frac{1-\tan x}{\sec x}\right\vert +\frac{x}{
2}+C \\
&=&-\frac{1}{2}\ln \left\vert \cos x-\sin x\right\vert +\frac{x}{2}+C.
\end{eqnarray*}$$
</s>