Newton's method for sqrt


To find x to make f(x) = 0, Newton said:
  f(x) ~= f(x0) + (x-x0)*f'(x0) = 0
Solving for x and calling the result x1:
  x1 = x0 - f(x0)/f'(x0)
So x1 is better than x0 as an estimate of x to make f(x) = 0.

For sqrt(a):

  f(x) = x2 - a, and f'(x) = 2*x
so:
  x1 = x0 - (x02 - a)/(2*x0)

    = (x0 + a/x0) / 2
is better than x0 as an estimate of sqrt(a).

Starting with an initial estimate, e.g. x = a/2, each iteration of Newton's method produces a better estimate using:

  x = (x + a/x) / 2