<s>[INST] How do I solve $\int\frac{dx}{\sin x+\cos x-1}$? Please help me find the following indefinite integral:
$$\int\dfrac{dx}{\sin x+\cos x-1}$$
I have tried many different substitutions to no avail. Any help is appreciated.
 [/INST] $$I = \int \frac{1}{\sin x + \cos x - 1}\, dx$$
Apply integral Subtitution
$$u = \tan\left(\frac{x}{2}\right)$$
$$\sin(x) = \frac{2u}{1+u^2},\quad \cos(x) = \frac{1 - u^2}{1 + u^2}\, \quad dx = \frac{2}{1 + u^2}$$
It follows
$$\int\frac{1}{u(-u + 1)}\, du = -\int\frac{1}{u(u - 1)}\, du $$
by partial fraction
$$-\int\left(\frac{1}{(u - 1)}- \frac{1}{u}\right)\, du $$
$$-\left[\int\frac{1}{(u - 1)}\, du -\int \frac{1}{u}\, du\right] $$
$\int \frac{1}{u}\, du = \ln(u)+C $
$\int\frac{1}{(u - 1)}\, du = \ln(u - 1)+C$
$$-\left[\ln(u - 1) - \ln(u)\right]+C $$
$u = \tan\left(\frac{x}{2}\right)$
$$-\ln\big(\tan\left(\frac{x}{2}\right) - 1\big) + \ln\big(\tan\left(\frac{x}{2}\right)\big)+C $$


$$I= \ln\big(\tan\left(\frac{x}{2}\right)\big)-\ln\big(\tan\left(\frac{x}{2}\right) - 1\big) +C $$

</s>