// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace Lib { public class Work { public static double SqrtBuiltin(double a) { return Math.Sqrt(a); } public static double SqrtNewton(double a) { double x = a / 2; double xprev; do { xprev = x; x = x + (a - x * x) / (2 * x); } while(Math.Abs(x - xprev) > 0.0000001); return x; } } }