I pulled this code from http://blog.shay.co/newtons-method/:
//a - the number to square root
//times - the number of iterations
public double Sqrt(double a, int times)
{
if (a < 0)
throw new Exception("Can not sqrt a negative number");
double x = 1;
while (times-- > 0)
x = x / 2 + a / (2 * x);
return x;
}
What is a good rule of thumb for the number of iterations on a number, if one exists? (For example, "Use n/2 iterations".)