Evaluate $\int\frac{1}{x-\sqrt{1-x^2}}dx$ The integral $I$ in question is defined as follows
$$
I \equiv \int\frac{1}{x-\sqrt{1-x^2}}dx
$$
To solve this, I tried the trig substitution $x = \sin\theta$, with $dx = \cos\theta d\theta$, and rewrote the integral as follows
$$
\int\frac{\cos\theta}{\sin\theta-\sqrt{1-\sin^2\theta}}d\theta
$$
I used to identity $1 - \sin^2\theta = \cos^2\theta$ and simplified the denominator as follows
$$
\int\frac{\cos\theta}{\sin\theta-\cos\theta}d\theta
$$
I then rewrote $\cos\theta$ as $\frac{\sin\theta + \cos\theta}{2} - \frac{\sin\theta - \cos\theta}{2}$ and rewrote the integrand as follows
$$
\int\frac{1}{2}\frac{\sin\theta+\cos\theta}{\sin\theta - \cos\theta} - \frac{1}{2}d\theta
$$
I then split the integral as follows
$$
\frac{1}{2}\int\frac{\sin\theta+\cos\theta}{\sin\theta-\cos\theta}d\theta - \frac{1}{2}\int1d\theta
$$
For the first integral, I substituted $\phi = \sin\theta-\cos\theta$, with $d\theta = \frac{1}{\sin\theta+\cos\theta}d\phi$
We can then rewrite our integral as
$$
\frac{1}{2}\int\frac{1}{\phi}d\phi
$$
This is trivial and after undoing the substitutions we have a result of
$$
\frac{\ln({x - \cos(\arcsin(x))})}{2} 
$$
The second integral is also trivial and just evaluates to $\frac{x}{2}$
Combining everything together gives us a final simplified answer of
$$
I = \frac{\ln({x - \sqrt{1-x^2}})-x}{2} + C
$$
However, both IntegralCalculator and WolframAlpha give very different answers, so if someone could tell me where I made a mistake or another approach entirely that would be greatly appreciated.
 A: You made mistake in the second integral. It should be
$$
I_2 = \frac{\theta}{2} + C_2 = \frac{\arcsin(x)}{2} + C_2 
$$
A: You could also proceed in the following way.
By letting $\;t=x-\sqrt{1-x^2}\;,\;$ we get that
$x=\dfrac12\left(t\pm\sqrt{2-t^2}\right)\;,\quad\mathrm dx=\dfrac12\left(\!\!1\mp\dfrac t{\sqrt{2-t^2}}\!\!\right)\mathrm dt\;\;.$
$\displaystyle\int\frac1{x-\sqrt{1-x^2}}\,\mathrm dx=\frac12\!\int\frac1t\left(\!\!1\mp\frac t{\sqrt{2-t^2}}\!\!\right)\mathrm dt=$
$\displaystyle\quad=\frac12\!\int\frac1t\,\mathrm dt\;\mp\;\frac12\!\int\frac{\mathrm dt}{\sqrt{2-t^2}}\;\;.$
Moreover ,
$\mp\dfrac{\mathrm dt}{\sqrt{2-t^2}}=-\dfrac{\mathrm dt}{2x-t}=-\dfrac{t’(x)\,\mathrm dx}{x+\sqrt{1-x^2}}=$
$\quad=-\dfrac{1+\frac x{\sqrt{1-x^2}}}{\sqrt{1-x^2}\left(\!1+\frac x{\sqrt{1-x^2}}\!\right)}\,\mathrm dx=-\dfrac{\mathrm dx}{\sqrt{1-x^2}}\;\;.$
Hence ,
$\displaystyle\int\frac1{x-\sqrt{1-x^2}}\,\mathrm dx=\frac12\!\int\frac1t\,\mathrm dt\;\mp\;\frac12\!\int\frac{\mathrm dt}{\sqrt{2-t^2}}=$
$\displaystyle\quad=\frac12\ln|t|-\frac12\!\int\!\dfrac{\mathrm dx}{\sqrt{1-x^2}}=$
$\quad=\dfrac12\ln\bigg|x-\sqrt{1-x^2}\bigg|-\dfrac12\arcsin x+C\;\;.$
A: I approached this integral by trigonometric substitution and partial fraction.
Assume the followings:
$x=\sin\theta\ \ldots(1)\\
\text{Hence, }dx=\cos\theta\ d\theta\ \ldots(2)\\
\text{Also, }\cos\theta=\sqrt{1-x^2}\ \ldots(3)\\$
Then,
$\operatorname{\Large\int}\dfrac{1}{x-\sqrt{1-x^2}}dx=\operatorname{\Large\int}\dfrac{\cos\theta}{\sin\theta-\sqrt{1-\sin^2\theta}}d\theta=\operatorname{\Large\int}\dfrac{\cos\theta}{\sin\theta-\cos\theta}d\theta$
$=\operatorname{\Large\int}\dfrac{1}{\tan\theta-1}d\theta=\operatorname{\Large\int}\dfrac{1}{\sec^2\theta\ (\tan\theta-1)}d\tan\theta=\operatorname{\Large\int}\dfrac{1}{(\tan^2\theta+1)(\tan\theta-1)}d\tan\theta$
$\stackrel{\text{partial fraction}}{=}\dfrac{1}{2}\operatorname{\Large\int}(\dfrac{1}{\tan\theta-1}-\dfrac{1+\tan\theta}{1+\tan^2\theta})\ d\tan\theta$
$=\dfrac{1}{2}(\operatorname{\Large\int}\dfrac{1}{\tan\theta-1}d\tan\theta-\operatorname{\Large\int}\dfrac{\sec^2\theta\ (1+\tan\theta)}{1+\tan^2\theta}\ d\theta)$
$=\dfrac{1}{2}(\operatorname{\Large\int}\dfrac{1}{\tan\theta-1}d\tan\theta-\operatorname{\Large\int}(1+\tan\theta)\ d\theta)$
$=\dfrac{1}{2}[\ln|\tan\theta-1|-(\theta-\ln|\cos\theta|)]+C$
$=\dfrac{1}{2}(\ln|\sin\theta-\cos\theta|-\theta)+C$
$=\underline{\underline{\dfrac{1}{2}(\ln|x-\sqrt{1-x^2}|-\arcsin x)+C}}$
