<s>[INST] Evaluating the indefinite integral $\int\frac{\sqrt{1-x}}{x\sqrt{1+x}}\,dx$ $$\int\frac{\sqrt{1-x}}{x\sqrt{1+x}}\,dx$$
Looking at the term under the square root, I tried out the subsitution $x = \cos\theta$. This reduced the expression to $\int(1 - \sec\theta)d\theta$. This doesn't tally with the answer provided though. What is happening?  
 [/INST] Let $$\displaystyle I = \int\frac{\sqrt{1-x}}{\sqrt{1+x}}\cdot \frac{1}{x}dx = \int\frac{\sqrt{1-x}}{\sqrt{1+x}}\cdot \frac{\sqrt{1-x}}{\sqrt{1-x}}\cdot \frac{1}{x}dx$$
So $$\displaystyle I = \int\frac{1-x}{x\sqrt{1-x^2}}dx = \int\frac{1}{x\sqrt{1-x^2}}dx-\int\frac{1}{\sqrt{1-x^2}}dx$$
Now Put $1-x^2=t^2$ Then $xdx = -tdt$ in $1^{st}$ and $x=\sin \theta$ and $dx = \cos \theta d\theta $ in $2^{nd}$ Integral
So $$\displaystyle I = \int\frac{1}{(t^2-1)}dt-\sin^{-1}(x)+\mathcal{C}$$
So $$I = \ln \left|\frac{t-1}{t+1}\right|-\sin^{-1}(x)+\mathcal{C}$$
So $$I = \ln \left|\frac{\sqrt{1-x^2}-1}{\sqrt{1-x^2}+1}\right|-\sin^{-1}(x)+\mathcal{C}$$
</s>