// Perform Newton-Raphson iteration to compute the square-root of // a given number // --------------------------------------------------------------------------- // Expect his output (with epsilon =1/100)(ie. sqrt(2) ~= 577/408) // 2 // 999 // 577 // 408 // 0 // Expect his output (with epsilon =1/10000)(ie. sqrt(2) ~= 665857/470832): // 2 // 999 // 665857 // 470832 // 0 // --------------------------------------------------------------------------- class TestNewton { public static void main(String[] a){ System.out.println((new Newton()).test_it(2)); } } class Frac { int num; int den; public boolean init (int x, int y) { boolean ok; ok = true; num = x; den = y; return ok; } public int den () { return den; } public int num () { return num; } public int showFrac() { int rc; rc = 0; System.out.println(num); System.out.println(den); return rc; } //public String toString () { // return ((new Integer(this.num)).toString()+"/"+(new Integer(this.den)).toString()); //} } class Integral { public boolean eq (int x, int y) { return (!(x