TITLE: Square root algorithm
QUESTION [5 upvotes]: I would like an efficient algorithm for square root of a positive integer.  Is there a reference that compares various square root algorithms?

REPLY [6 votes]: If you want the square root of an odd perfect square then one approach is to find the square root 2-adically. 
Suppose you want the square root of $n$. You can use the usual Newton-Raphson algorithm for the equation $f(x)=x-n/x=0$, working modulo $2^N$, for some large enough $N$. That's the iteration $x \rightarrow -x(-3n+x^2)/(2n)$. However, that requires division by $n$. You can achieve this by first using Newton-Raphson to solve for $g(x) = 1/x-n = 0$ to find $n^{-1}$ modulo $2^N$. That's $x\rightarrow x(2-nx)$. So two Newton-Raphson solves are required.
Requires only addition, subtraction and multiplication modulo $2^N$. Note also that it may converge to $-\sqrt n$.