(edit, 9 years later... hello smart contract developers, I know that's why you're here lol)
What is the fastest algorithm for finding the square root of a number?
I created one that can find the square root of "$987654321$" to $16$ decimal places in just $20$ iterations
I've now tried Newton's method as well as my own method (Newtons code as seen below)
What is the fastest known algorithm for taking the second root of a number?
My code for Newton's Method (*Edit: there was an error in my code, it is fixed in the comments below):
a=2 //2nd root
b=97654321 //base
n=1 //initial guess
c=0 //current iteration (this is a changing variable)
r=500000 //total number of iterations to run
while (c<r)
{
m = n-(((n^a)-b)/(a*b)) //Newton's algorithm
n=m
c++;
trace(m + " <--guess ... iteration--> " + c)
}
a*n
instead ofa*b
in the denominator. $\endgroup$