POV-Ray : Newsgroups : povray.off-topic : Fast Inverse Square Root explained : Re: Fast Inverse Square Root explained Server Time
28 Jul 2024 22:24:22 EDT (-0400)
  Re: Fast Inverse Square Root explained  
From: clipka
Date: 15 Sep 2012 21:23:40
Message: <50552a1c$1@news.povray.org>
Am 15.09.2012 19:30, schrieb Darren New:
> I even followed this one.
>
> http://blog.quenta.org/2012/09/0x5f3759df.html

What the...

... well, no fuck indeed. Makes perfect sense, even to me.


Which begs the question: Would it be worth to use this approximation - 
maybe with a few more steps of newton - in POV-Ray, or at least in an 
experimental patch thereof?

I suspect that if you complement this approximation with enough newton 
steps to obtain full precision, it'll be no faster than the "sqrt" and 
"pow" runtime library functions - after all, if it would be both fast 
and precise enough, the RTL functions would already make use of this 
very approach (for exponents in range -1..1), wouldn't they?

With a little tweaking of sigma the approach could be modified to 
compute upper or lower bounds to sqrt(x) or 1/sqrt(x) instead, which 
could theoretically be used for quick checks involving square roots. 
However, the classic approach of replacing sqrt(x)<y checks with x<y*y 
checks is probably in the same ballpark as far as speed is concerned, 
without any loss of accuracy, no need for type casting (which might 
actually incur a speed penalty for moving data between floating-point 
and integer registers), and much better portability characteristics.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.