Evaluating$\int {1\over1-\sin2x}dx$ $$
\int {1\over1-\sin 2x}dx = \int {1\over \sin^2 x-2\sin x\cos x+\cos^2x}dx = \int {1\over (\sin x-\cos x)^2}dx
$$
From here I get two different answers, depending on whether I factor out $\sin x$ or $\cos x$.
Factoring out $\sin x$, this one is correct according to WolframAlpha:
$$=\int {1\over [\sin x(1-{\cos x\over \sin x})]^2}dx=\int {1\over \sin^2x(1-{\cos  x\over \sin x})^2}dx = \int {1\over(1-\cot x)^2}d(1-\cot x)$$
$$={1\over \cot x-1}+C$$
But when I factor out $\cos x$:
$$=\int {1\over [\cos x({\sin x\over \cos x}-1)]^2}dx=\int {1\over \cos^2x({\sin x\over \cos x}-1)^2}dx = \int {1\over(\tan x-1)^2}d(\tan x-1)$$
$$={1\over 1-\tan x}+C$$
I bet it's just some stupid typo that I'm missing, I can't figure it out.
Thanks.
 A: There is no typo in what you have done. Indeed,
\begin{equation}\frac{1}{\cot x-1}=\frac{1}{\frac{1}{\tan x}-1}=\frac{\tan x}{1-\tan x}=\frac{1}{1-\tan x}-1
\end{equation}
You simply take $C_2-C_1=-1$ in your constants of integration
A: They are both correct. To see this, you can simply take the derivative of each antiderivative to get your original integral back. This shows that both primitives you found are equal, up to a constant.
$$\frac{d}{dx} \left(\frac{1}{\cot x - 1}\right) = \frac{1}{\left(\cos x - \sin x\right)^2}$$
$$\frac{d}{dx} \left(\frac{1}{\tan x - 1}\right) = \frac{1}{\left(\cos x - \sin x\right)^2}$$
\begin{eqnarray*}
\left(\cos x - \sin x\right)^2 &=& (\cos x - \sin x)(\cos x - \sin x)\\
&=& \cos^2 x - 2 \sin x \cos x + \sin^2 x\\
&=& 1 - \sin 2x 
\end{eqnarray*}
In your first line, you have
\begin{eqnarray*}
(\sin x - \cos x)^2 &=& (\sin x - \cos x)(\sin x - \cos x)\\
&=& \sin^2 x - 2 \sin x \cos x + \cos^2 x\\
&=& 1-\sin 2x
\end{eqnarray*}
As you can see, these are equivalent.
A: How about doing a u-sub  2x = t and then multpliy top and bottom with conjugate 1+sint,
It will become VERY easy then.
A: There is no typo as in the step where you make $(sinx-cosx)^2$ it can be $(cosx-sinx)^2$ .so there is two answer possible.And one more point is the function which we try to integrate is always a result of any function's differentiation. so if any integration gives two answers means if we differentiate those answers that will give us same integrating function.
Differentiation of a function's integration give the same function.
