Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, it should read "repeat step three".

Oops, quite right.

So it looks like the algorithm calculates an inverse square root instead, and then multiplies it by the original number (step 5.)

Exactly. The nice thing about this method is that it converges nicely even if you make errors (arithmetical or rounding) along the way -- so you can start by working with only a few digits and only use full precision right at the end.

You could compute square roots using a direct NR iteration (Y := (Y + X/Y) / 2), but that requires that you perform a division at each step -- most people find multiplications to be easier and faster.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: