public class Sqrt
{
public static void main(String[] args)
{
double EPS = 1E-15;
double c = Double.parseDouble(args[0]);
double t = c;
while (Math.abs(t - c/t) > t * EPS)
{ t = (c/t + t) / 2.0; }
System.out.println(t);
}
}
Above is one version of Newton Raphson i found in Java.
I suppose it works but I'm having a hard time wrapping my head around how it actually works. { t = (c/t + t) / 2.0; }
really confuses me.
I'm familiar with x_n+1 = x_n - f(x_n)/ f'(x_n)
but not the one implemented in the code above..