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.

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\;\;.$
