Fast reciprocal square root algorithm

Click For Summary
The discussion centers around a fast algorithm for calculating the reciprocal square root, specifically the method used in Quake III, presented by John Carmack. This algorithm significantly outperforms the standard library function, achieving results within 1% accuracy while being over one hundred times faster. The conversation also touches on various numerical approximation techniques and the historical context of such algorithms, suggesting that many numerical functions can be optimized similarly. Participants share links to research and modern modifications of the algorithm, emphasizing the importance of understanding both speed and accuracy in computational methods. The potential for further improvements in algorithm efficiency remains a key interest among contributors.
  • #31
I quoted Fröberg since it was on the required list for my Numerical Algorithms exam back in 1964. After I referred to it, I started to get very unsure of the validity of the algorithm - and, sure enough, it converges badly for a starting value of 1 if a is greater than 1. I have checked and found that the best way is to modify the start value according to this algorithm;
Code:
Start with x0=2
if a>1
   repeat
      x0=x0/2
      t=(3-x0*x0*a)
   until (t<2) and (t>0)
Then use the Fröberg algorithm with the resulting x0.
 
Last edited:
  • Like
Likes Baluncore

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
22
Views
4K
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 19 ·
Replies
19
Views
5K
Replies
11
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 13 ·
Replies
13
Views
6K