<s>[INST] Ambiguity in Integration done by substitution. I was solving this integral $$I= \int x\sqrt{1-x^2} \mathrm dx$$ My solution is:
Let $x=\sin y$, then $|\cos y|=\sqrt{1-x^2}$ I now use method of substitution for the cases $\cos y\geq 0$ and $\cos y<0$. The correct answer is $-\frac{(1-x^2)^{3/2}}{3} +C$. I am able to obtain this answer for $\cos y\geq 0$ but in the case where $\cos y <0$, we get it to be $\frac{(1-x^2)^{3/2}}{3} +C$. Where have I gone wrong?
 [/INST] I suspect you forgot to include the sign when you substituted $\cos y$ back to get a function in terms of $x$ at the end. Here is the complete derivation.
I'm assuming that you did the substitution and integration correctly: if $x=\sin y$, then $dx = \cos y\,dy$, so we get
$$\int x\sqrt{1-x^2}\,dx = \int\sin y|\cos y|\cos y\,dy.$$
If we are in a situation where $\cos(y)\lt 0$ (e.g., if we are picking $\frac{\pi}{2}\leq x\leq \frac{3\pi}{2}$), then this would become
$$\int -\sin y\cos^2y\,dy.$$
This can be done by substitution (again), letting $u=\cos y$, $du = -\sin y\,dy$, so we get
$$\int \sin y\cos^2y\,dy = \int u^2\,du = \frac{1}{3}u^3+C.$$
Now we need to substitute back, and we get $\frac{1}{3}\cos^3y+C$.
Now, if $x=\sin y$, then $1-x^2 = \cos^2y$. That means that $|\cos y| = \sqrt{\cos^2y} = (1-x^2)^{1/2}$. Since we are assuming that $\cos y\lt 0$, this gives
$ - \cos y = (1-x^2)^{1/2}$; equivalently,
$$\cos y = -(1-x^2)^{1/2}.$$
Note the minus sign!
So substituting back we have
$$\begin{align*}
\int x\sqrt{1-x^2}\,dx &= \frac{1}{3}\cos^3y + C \\
&= \frac{1}{3}\left(-(1-x^2)^{1/2}\right)^3 + C \\
&= \frac{(-1)^3}{3}(1-x^2)^{3/2} + C\\
&= -\frac{1}{3}(1-x^2)^{3/2} + C,
\end{align*}$$
giving the same answer as you got when you assumed $\cos(y)\geq 0$.
</s>