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.
 A: HINT: multiplying numerator and denominator of your Integrand by $$\sin(x)+\cos(x)+1$$ we get
$$\frac{\sin(x)+\cos(x)+1}{\sin(x)^2+\cos(x)^2+2\sin(x)\cos(x)-1}=\frac{\sin(x)+\cos(x)+1}{2\sin(x)\cos(x)}$$
A: Following Lord Shark the Unknown's hint, let $t=\tan(x/2)$ then
$$dx=\frac{2dt}{1+t^2},\quad\cos(x)=\frac{1-t^2}{1+t^2},\quad\sin(x)=\frac{2t}{1+t^2}.$$
Hence
$$\int\dfrac{1}{\sin\left(x\right)+\cos\left(x\right)-1}\,dx=
\int\dfrac{1}{\frac{2t}{1+t^2}+\frac{1-t^2}{1+t^2}-1}\cdot\frac{2dt}{1+t^2}=\int\dfrac{dt}{t(1-t)}\\=\int\left(\dfrac{1}{t}-\dfrac{1}{t-1}\right) dt.
$$
Can you take it from here?
A: Another way, using trigonometric identities 
$$\sin{2x} = 2 \cdot \sin{x} \cdot \cos{x}$$
$$1 - \cos{x} = 2 \cdot \sin^2\frac{x}{2}$$
is as follows:
$$\int\dfrac{dx}{\sin x+\cos x-1}$$
$$= \int\dfrac{dx}{\sin x-(1 - \cos x)}$$
$$= \int\dfrac{dx}{2 \cdot \sin\frac{x}{2} \cdot \cos\frac{x}{2}-(2\cdot sin^2\frac{x}{2})}$$
$$= \int\dfrac{dx}{2 \cdot \sin\frac{x}{2}\cdot \big(\cos\frac{x}{2}-sin\frac{x}{2}\big)}$$
$$= \frac{1}{2}\int\dfrac{cosec\frac{x}{2} \cdot dx}{\big(\cos\frac{x}{2}-sin\frac{x}{2}\big)}$$
$$= \frac{1}{2}\int\dfrac{cosec^2\frac{x}{2} \cdot dx}{\big(\cot\frac{x}{2}-1\big)}$$
$$= \int\dfrac{cosec^2\frac{x}{2} \cdot \frac{dx}{2}}{\big(\cot\frac{x}{2}-1\big)}$$
$$ = -ln\bigg(cot\bigg(\frac{x}{2}\bigg) - 1\bigg) + C$$
Hence
$$\int\dfrac{dx}{\sin x+\cos x-1}= \boxed{- ln\bigg(cot\bigg(\frac{x}{2}\bigg) - 1\bigg) + C}$$
A: $$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 $$

A: $$\int\frac{1}{\sin{x}+\cos{x}-1}dx=\int\frac{1}{2\sin\frac{x}{2}\cos\frac{x}{2}-2\sin^2\frac{x}{2}}dx=$$
$$=\int\frac{\sin^2\frac{x}{2}+\cos^2\frac{x}{2}}{2\sin\frac{x}{2}\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}dx=\int\frac{\sin^2\frac{x}{2}+\sin\frac{x}{2}\cos\frac{x}{2}-\sin\frac{x}{2}\cos\frac{x}{2}+\cos^2\frac{x}{2}}{2\sin\frac{x}{2}\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}dx=$$
$$=\int\frac{\sin\frac{x}{2}\left(\sin\frac{x}{2}+\cos\frac{x}{2}\right)+\cos\frac{x}{2}\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}{2\sin\frac{x}{2}\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}dx=$$
$$=\int\left(\frac{\sin\frac{x}{2}+\cos\frac{x}{2}}{2\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}+\frac{\cos\frac{x}{2}}{2\sin\frac{x}{2}}\right)dx=$$
$$=\int\left(-\frac{d\left(\cos\frac{x}{2}-\sin\frac{x}{2}\right)}{\cos\frac{x}{2}-\sin\frac{x}{2}}+\frac{d\left(\sin\frac{x}{2}\right)}{\sin\frac{x}{2}}\right)=\ln\left|\frac{\sin\frac{x}{2}}{\cos\frac{x}{2}-\sin\frac{x}{2}}\right|+C$$
A: \begin{align}
I&=\int \frac{dx}{\sin x+\cos x-1}=\int \frac{\frac{dx}{\cos x-1}}{\frac{\sin x}{\cos x-1}+1}=\int \frac{-d\left(\frac{\sin x}{\cos x-1}+1\right)}{\frac{\sin x}{\cos x-1}+1}\\
&=-\ln \left|\frac{\sin x}{\cos x-1}+1\right|+C=\ln \left|\frac{\cos x-1}{\sin x+\cos x-1}\right|+C
\end{align}
