

Understanding Quake's Fast Inverse Square Root - ed
http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/

======
russell
IIRC (it's been a long time) the Cray 1 could do inverse, multiply, and square
root in single cycle instructions. Isqrt would take two cycles as wood divide.
(Back to the rocking chair.)

~~~
marcus
Actually it didn't <http://klausler.com/cray2.txt> it had a command for a
square root approximation and a command to iteratively get closer to the real
square root.

But even if a certain computer did compute a square root (or even an
approximation) in a single cycle, that would mean CPU speed was reduced by
slowing down the clock to enable a more complex action to complete within the
timeframe of a single cycle, and other simpler actions like
adding/subtracting/moving memory we're sacrificed in its favor.

~~~
wwalker3
Not necessarily. The square root hardware could be heavily pipelined to get
each stage short enough for one cycle. This increases latency, but lets you
keep a one-per-cycle throughput without slowing down the clock.

------
nx
It's really easy to understand if you know what the Newton Method for
computing roots of a polynomial is.

~~~
statictype
Its easy to understand the algorithm. But that initial guess there is where
the magic is. Thats what makes the algorithm work so efficiently.

------
jballanc
Cool, but if you really want to blow your mind, look at some of the tricks for
diagonallizing Hessians!

------
ComputerGuru
John Carmack FTW.

~~~
jmagar
Carmack or Michael Abrash? Read Graphics Programming Black Book (
[http://www.amazon.com/Michael-Abrashs-Graphics-
Programming-S...](http://www.amazon.com/Michael-Abrashs-Graphics-Programming-
Special/dp/1576101746) )

Abrash did amazing things with assembly to get Quake to run on the 486.

I don't know if Carmack, Abrash, or someone at SGI (it's in OpenGL source code
too) came up with it; but it seems like witch craft to me.

~~~
dangrover
The _486_!? Wow

~~~
MikeCapone
Yeah, I actually played it (choppily) for a while on my 486.

