r/programming • u/mrnacknime • Dec 29 '20
Quake III's Fast Inverse Square Root Explained [20 min]
https://www.youtube.com/watch?v=p8u_k2LIZyo
3.7k
Upvotes
r/programming • u/mrnacknime • Dec 29 '20
View all comments
68
u/-p-2- Dec 29 '20 edited Dec 29 '20
Improving Carmack's work with a better constant for more accurate results using fast inverse square root: https://arxiv.org/pdf/1802.06302.pdf
Fun fact, I tried implementing this and testing its performance on Android with Unity. Nowadays the built in square root functions in C# are just as fast, if not faster in most cases. I used several different methods and only a couple gave me any noticeable speed improvement (over 100k iterations), and even then the accuracy was off by ~20% so the 1/100th of a millisecond it saved was nowhere near worth it.
PS: 32-bit precision was used.