I’ve found this article after making a similar search for constants. The best error I got was 0.0006501978 with this code (yours is 0.0006531066):

float inv_sqrt(float x)

{ union { float f; uint32 u; } y = {x};

y.u = 0x5F1FFF77ul – (y.u >> 1);

return 0.703974056f * y.f * (2.38919526f – x * y.f * y.f);

}

The search program can be downloaded on my site (rrrola.wz.cz/inv_sqrt.html). I believe this error is optimal to 5 digits.

]]>Note that the approximation only does some bit manipulation and some floating point multiplications and additions. This is much faster than correctly calculating the square root followed by a floating point divition which are both expensive operations.

]]>