$\int \frac{dx}{1-\sin x+\cos x}$ Solve :$$ \int \frac{dx}{1-\sin x+\cos x} $$
I tried:
$$\int \frac{\text{dx}}{(1+\cos x)-\sin x} \times \frac{(1+\cos x)+\sin x}{(1+\cos x)+ \sin x} dx=\int \frac{1+\cos x+\sin x}{(1+\cos x)^2-(\sin x)^2}$$ $$=\int \frac{1+\cos x+\sin x}{1-\sin x^2+2 \cos x+\cos x^2}=\int \frac{1+\cos x+\sin x}{2 \cos x(\cos x+1)}$$ $$=\int (\frac{1}{2 \cos x}+ \frac{\sin x}{2 \cos x(\cos x+1)})dx=\frac{1}{2} \ln(\sec x+\tan x)+ \int \frac{\sin x}{2\cos x(\cos x+1)}dx$$
$ \cos x=u$ , $du=-\sin xdx$
$$\int \frac{-du}{2u(u+1)}= \frac{-1}{2} \int (\frac{1}{u}-\frac{1}{u+1})= \frac{-1}{2}(\ln(\cos x)-\ln(\cos x+1))$$
final answer : $$\frac{1}{2} \ln(\sec x+\tan x)-\frac{1}{2} \ln(\frac{\cos x}{1+\cos x})+ c$$
First: Is my answer right?
Second: Is there another approach or easier approach to solve this integral?  
 A: Your answer is correct 
You may try the following as well. 
Substitute $$\sin x =\frac {2\tan (x/2)}{1+\tan^2(x/2)}$$ and $$\cos x =\frac {1-\tan^2 (x/2)}{1+\tan^2(x/2)}$$ 
Then let $u=\tan (x/2)$
A: My hint for your question:
$$\int \frac{dx}{1-\sin x+\cos x}$$
If I apply the $t-$substitution $t=\tan(\frac{x}{2})$ you will have $$\int \frac{dx}{1-\sin x+\cos x}=\int \frac{1}{-u+1}du$$
Using another $y-$substitution for last integral of the type $p=-y+1$ you will have:
$$\int \frac{1}{-u+1}du=\int -\frac{1}{p}dp$$
Hence remebering all substitutions $p=-u+1,\,t=\tan  (\frac{x}{2} )$ you will obtain 
$$\int \frac{dx}{1-\sin x+\cos x}=-\ln \left|-\tan \left(\frac{x}{2}\right)+1\right|+k, \quad k\in\mathbb R$$
A: Start by multiplying the top and bottom by $\sec(x)$, which will result in the following:
$$\int{\frac{\sec x}{\sec x-\tan x+1}}$$
Now we can perform a $u-$substitution for the following:
$$u=(\sec x-\tan x)\\du=(\sec x)(-(\sec x-\tan x))dx$$
The resulting integral is then:
$$\int{\frac{-1}{(u+1)(u)}}$$
We can now make use of partial fraction in the same manner that you did, giving us the following:
$$\int{\frac{1}{u+1}}+\int{\frac{-1}{u}}$$
Completing the remaining integrals and plugging back in for our substitution gives the following solution:
$$\ln\left|{\frac{1-\sin x+\cos x}{1-\sin x}}\right|+c$$
