<s>[INST] 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.
 [/INST] You made mistake in the second integral. It should be
$$
I_2 = \frac{\theta}{2} + C_2 = \frac{\arcsin(x)}{2} + C_2 
$$
</s>