solve the integration. ∫ 1 dx / (sinx - cosx)

solve the integration. ∫ 1 dx / (sinx - cosx)
Answer
Explanation:
Step1: Use the substitution $t=\tan\frac{x}{2}$
We know that $\sin x=\frac{2t}{1 + t^{2}}$, $\cos x=\frac{1 - t^{2}}{1 + t^{2}}$ and $dx=\frac{2}{1 + t^{2}}dt$. So the integral $\int\frac{1}{\sin x-\cos x}dx=\int\frac{1}{\frac{2t}{1 + t^{2}}-\frac{1 - t^{2}}{1 + t^{2}}}\cdot\frac{2}{1 + t^{2}}dt=\int\frac{2}{2t-(1 - t^{2})}dt=\int\frac{2}{t^{2}+2t - 1}dt$.
Step2: Complete the square for the denominator
$t^{2}+2t - 1=(t + 1)^{2}-2$. Then $\int\frac{2}{t^{2}+2t - 1}dt=2\int\frac{1}{(t + 1)^{2}-(\sqrt{2})^{2}}dt$.
Step3: Use the integral formula $\int\frac{1}{u^{2}-a^{2}}du=\frac{1}{2a}\ln|\frac{u - a}{u + a}|+C$
Here $u=t + 1$ and $a=\sqrt{2}$. So $2\int\frac{1}{(t + 1)^{2}-(\sqrt{2})^{2}}dt=2\cdot\frac{1}{2\sqrt{2}}\ln|\frac{(t + 1)-\sqrt{2}}{(t + 1)+\sqrt{2}}|+C=\frac{1}{\sqrt{2}}\ln|\frac{\tan\frac{x}{2}+1-\sqrt{2}}{\tan\frac{x}{2}+1+\sqrt{2}}|+C$.
Answer:
$\frac{1}{\sqrt{2}}\ln|\frac{\tan\frac{x}{2}+1-\sqrt{2}}{\tan\frac{x}{2}+1+\sqrt{2}}|+C$