Skip to content

Comment on Fast inverse square root

Comments

I hope someday to actually understand this. It seems to come up once a year or so, and each time I understand a bit more... so hopefully in a few years...

It's really just Newton's method for successive approximations: http://en.wikipedia.org/wiki/Newtons_method

And a very clever zeroth approximation.

Exactly, that's the key to the whole thing.

After all if your first approximation is 'in the ballpark' you get a lot of precision in one go. Newtons method would run 'infinitely long' to reach an arbitrary precision, normally the cutoff is some acceptable error.

By getting within the ballpark on the first try you can get within acceptable error with one more approximation step.

(acceptable depends on the use of the result of course).

If you Google for that magic number, you will find a large number of explanations, requiring various levels of understanding. No doubt there is one clear enough for you; perhaps stack a few of them.

Good tip, thanks -- now on to making my brain hurt!

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.