I was required to find $y'$ when $y=\sin^{-1}(\frac{2x}{1+x^2})$
This is my solution.

Above when I put $\sqrt{x^4-2x+1}=\sqrt{(1-x^2)^2}$ then I get the correct answer but when I put $\sqrt{x^4-2x+1}=\sqrt{(x^2-1)^2}$ then I get something else.
Now my question is that which one is correct and why? How you will come to know that we should put $\sqrt{x^4-2x+1}=\sqrt{(1-x^2)^2}$ and not $\sqrt{x^4-2x+1}=\sqrt{(x^2-1)^2}$
Kindly help me.