Computing square vs computing square-root? Time complexity I am working on something that requires checking a very large natural number $x$ to determine if it is the square root of an even larger natural number $y$. So I am wondering what are the fastest algorithms for computing square and square root, and how should I be approaching this i.e.

Computing $\sqrt{y}$ and comparing it with $x$
OR
Computing $x^2$ and comparing it with $y$

So as to write a code that has minimum time complexity.
There is a simple randomized test: pick a random 32-bit prime $p$, and test whether $x^2 \equiv y \pmod p$.  Do this a few times for a few random primes $p$.  (You can even pick a random number $p$ without requiring it be prime.)  If there is any error in your square root, then it is likely that it will be detected by this test.  The chances of failing to detect an error is exponentially small.