News for hackers. Stuff that matters.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by stephencanon on Thursday April 20, 2023 @07:41PM (#35648057)
> for that there's still no better approach than using the Q_rsqrt idea

Or you can just take a square root and divide; these are (partially-)pipelined operations on modern CPUs, with _much_ shorter latency than they had when "fast inverse square root" was a thing.

It still has a niche, but that niche is very, very narrow today.

Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by pclmulqdq on Thursday April 20, 2023 @10:40PM (#35649199)
If you're doing ~20 other FP ops (not including division) per inverse square root and not using a huge dependency chain of inverse square roots, you might not even notice the impact of using an exact inverse square root with this method.

Short of functions like exp and the trig functions, DIY approximations are usually not worth it these days.

Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by adgjlsfhk1 on Friday April 21, 2023 @12:56AM (#35649946)
polynomials are still king. a 6th degree polynomial is often enough and will be faster than a 2nd degree rational.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by pclmulqdq on Friday April 21, 2023 @07:46AM (#35652366)
A 6th degree polynomial is firmly in the "fast approximation" category. I think sin/cos are ~15th degree polynomials for 1 ULP of precision.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by moonchild on Friday April 21, 2023 @08:00AM (#35652459)
https://github.com/rutgers-apl/The-RLIBM-Project/blob/main/l... has a lot less and claims to be correctly rounded.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by pclmulqdq on Friday April 21, 2023 @08:12AM (#35652558)
For 32-bit float, yes. For double precision, not so much.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by adgjlsfhk1 on Friday April 21, 2023 @01:09PM (#35656858)
sin/cos commonly use 2 different 5th degree polynomials (depending on quadrant of the sin graph) https://github.com/JuliaLang/julia/blob/bb83df1d61fb649efd15...
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by thegeomaster on Friday April 21, 2023 @06:17AM (#35651795)
What do you mean by "taking the square root"? sqrtps has exactly the same problem, it's not standardized, so you need a custom algorithm.
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by stephencanon on Friday April 21, 2023 @08:26AM (#35652683)
square root is an IEEE 754 basic operation, correctly rounded (and therefore bitwise reproducible) on all compliant systems. What made you think that it isn't?
Re:Revisiting the Fast Inverse Square Root – Is It Still Use... by dooglius on Friday April 21, 2023 @08:28AM (#35652703)
Sqrt is standardized by IEEE, it is required to be the correctly rounded value.