Fast Inverse Square Root

The cluster centers on the Quake III fast inverse square root algorithm and related performance hacks for computing square roots, reciprocals, and trigonometric functions using techniques like CORDIC, Chebyshev approximations, Newton-Raphson, and lookup tables.

📉 Falling 0.5x Gaming
3,170
Comments
20
Years Active
5
Top Authors
#6409
Topic ID

Activity Over Time

2007
2
2008
5
2009
36
2010
36
2011
59
2012
90
2013
61
2014
123
2015
141
2016
105
2017
197
2018
182
2019
149
2020
261
2021
342
2022
299
2023
343
2024
455
2025
267
2026
19

Keywords

SQRTPS CPU FP DIY V1 ROM ULP FMA uwplse.org DIVPS square root square inverse root floating point floating multiplication fast multiply rows

Sample Comments

bla3 • Dec 9, 2021 • View on HN

Recent post on the same topic that gets the same information across with fewer words: https://kristerw.github.io/2021/10/19/fast-math/

speedgoose • Apr 28, 2022 • View on HN

Do we have another example than the famous quake fast square root function?

enriquto • Jul 7, 2021 • View on HN

Fast inverse square root is an ultra-fancy hack for a very particular processor. Apollo's trigonometric functions are the most natural optimal approximation that could be done.

ficklepickle • Dec 21, 2020 • View on HN

How do you compute the reciprocal without division? A precomputed lookup table?

EliRivers • Jun 5, 2017 • View on HN

Fast inverse square root as seen in Quake (as mentioned in other comments)https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overv...

bee_rider • Nov 30, 2023 • View on HN

I tried 1/sqrt(9x-6) from .7 to 1e308, and got as one alternativesqrt(-.16666…)It did correctly mark this as 0% accurate, but I’m kinda curious as to where it came from.It does have a 1.1x speedup apparently. None of the other (more accurate) options provide a speedup. Maybe there aren’t any value options that provide a speedup, but the tool allows increasingly reduced accuracy (down to zero) until it finds a speedup?

fegu • Oct 31, 2022 • View on HN

The doom square root trick. Reducing an expensive function to almost nothing with low error. Many writeups on the web far better than I could give.

jacobolus • Apr 12, 2017 • View on HN

Nitpick: inverse square root is not a transcendental function.

pclmulqdq • Apr 18, 2025 • View on HN

Oof this is bad. If you're going to ask people to approximate, use a Chebyshev approximation please. You will do sin(x) faster than this and more accurately.

LarsDu88 • Nov 1, 2022 • View on HN

Fast inverse square root. Commonly attributed to john carmack, it actually predates his application of it by several years