I am recently learning integration and I came across trigonometrical substituition but I am confused that how is it working? For example: For integrating
$\int \frac{1}{\sqrt{1-x^2}} dx$
We put $x=\sin y$
as per my teacher told, we assume x and a (any constant and here in this case a=1) as sides of a right triangle and y an angle in it and then we substitute the values as per it but I am confused if we can do that then why don't we put
$x=\cos y $
I tried solving the integral substituting $x=\cos y $ but I got the answer negative.
If you do $x=\sin y$ and $\mathrm dx=\cos(y)\,\mathrm dy$, then $\int\frac1{\sqrt{1-x^2}}\,\mathrm dx$ becomes$$\int\frac{\cos(y)}{\sqrt{1-\sin^2(y)}}\,\mathrm dy=\int1\,\mathrm dy=y+C=\arcsin(x)+C.$$And if you do $x=\cos y$ and $\mathrm dx=-\sin(y)\,\mathrm dy$, then $\int\frac1{\sqrt{1-x^2}}\,\mathrm dx$ becomes$$-\int\frac{\sin(y)}{\sqrt{1-\cos^2(y)}}\,\mathrm dy=-\int1\,\mathrm dy=-y+C=-\arccos(x)+C.$$Since $\arcsin+\arccos$ is constant (it is equal to $\frac\pi2$), theses answers are the same.