Subj : Re: sqrt algo To : comp.programming From : CBFalconer Date : Thu Jul 14 2005 11:19 pm "Arthur J. O'Dwyer" wrote: > On Thu, 14 Jul 2005, Martijn wrote: > > [Someone else wrote:] >>> Here is an iterative one (from the ancient Egypt, I have been told): >>> >>> current_estimate = 0.5*(previous_estimate + number/previous_estimate) >>> >>> You'll have to terminate it when you are "close enough". (It >>> converges quite quickly, the number itself may serve as the first >>> estimate.) >> >> In which case you might as well take 1. > > I suspect you've misunderstood the relative precedence of + and / > in the above formula. :) I don't think so. You can plug either 'number' or '1' as 'previous_estimate' into the above formula, and you will get the same result for 'current_estimate'. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson .