There's rather more to Newton's algorithm than just going from one estimate to a "better estimate". There's some detailed maths behind why the better estimate is what it is.
The idea is that to find the solution to ANY equation of the form f(x) = 0
, (apart from a few exceptional cases), if you have an approximation to x
, you can get a BETTER approximation, by looking at the rate of change of f(x)
, which is often written f'(x)
, and using that to work out how much you have to adjust your estimate by, to get a much better estimate of the true solution.
In the case of a square root, that is, we want to find x=sqrt(n)
, we can write f(x)=x^2-n
and f'(x)=2x
, then use Newton's algorithm to find the right x
to make f(x)=0
. What this means is that if we have an estimate e
, then to work out our next estimate, we look at f(e)=e^2-n
, and we ask how much we have to change e
to get rid of this error. Since the rate of change of f
is f'(x)
, which is 2e
at the point (e,e^2-n)
, we should divide e^2-n
by 2e
to work out how much we have to adjust e
by, to get our next estimate.
That is, our next estimate should be
e - (e^2-n) / 2e
= e - (e / 2) + (n / 2e)
= (e + n / e) / 2
More information on Newton's algorithm can be found at
http://tutorial.math.lamar.edu/Classes/CalcI/NewtonsMethod.aspx (which has a lovely diagram that explains how it works) and at http://www.math.brown.edu/UTRA/linapprox.html which goes into some of the more technical detail.