Summary
Fast inverse square root
Highlights
Overview of the Algorithm
The fast inverse square root algorithm estimates 1/√x for 32-bit floating-point numbers. By treating the floating-point representation as an integer, the algorithm performs a bit shift and a subtraction from a 'magic constant' (0x5F3759DF) to generate an initial guess. This guess is then refined using one iteration of Newton's method to provide a sufficiently accurate result for 3D graphics calculations.
Historical Context and Motivation
Developed in the early 1990s and famously implemented in 1999's Quake III Arena, the algorithm was designed to overcome the relative slowness of floating-point division at the time. It enabled high-speed lighting and shading calculations, such as vector normalization, essential for real-time 3D rendering. Its authorship was eventually traced to Greg Walsh.
Mathematical Mechanics
The algorithm leverages the logarithmic properties inherent in the IEEE 754 floating-point format. By aliasing a float to an integer, it performs an approximate logarithmic calculation via bit manipulation. While highly effective during its era, modern hardware (specifically x86 SSE instructions like rsqrtss) has rendered the algorithm largely redundant due to the availability of faster, more precise, and native hardware instructions.