Fast inverse square root for computer graphics programming! [1] Popularized by leaked Quake III code (attributed to John Carmack), but dates back much further.
It's a shame you picked q3's fast inverse square root. It's not a great example as it turns out someone else implemented it in Quake 3 and someone else entirely devised the algorithm itself. Though you're right - he's a bit of a hero and deservedly so.
edit: however ... I've just read that article and it is actually the most in-depth and interesting analysis I've read on the subject so thanks!
The same trick (approximating with a first order Taylor series), is also the basis of quake's famous fast inverse square root [1].
I love these methods because they always involve a "magic constant".
Fast inverse square root[0] is something that I encountered in the mid-2000s in the Q3A source code. It took me a really long time to understand it, and I eventually had to show it to some professors before I really understood what was going on and why this worked.
That's really an example of how arbitrary human thought processes are. When you release the constraint that your code has to have some human-comprehensible analog, you might arrive at interesting results.
[0] https://www.youtube.com/watch?v=p8u_k2LIZyo
reply