Fast reciprocal square root algorithm

Click For Summary

Discussion Overview

The discussion centers around a fast algorithm for computing the reciprocal of the square root of a number, specifically the method popularized by John Carmack in the context of the Quake III game engine. Participants explore the efficiency of this algorithm compared to traditional methods, its implications for numerical computations, and related algorithms.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested, Mathematical reasoning

Main Points Raised

  • Some participants describe the fast inverse square root algorithm and its implementation, noting its significant speed advantage over the standard library function for calculating square roots.
  • Others suggest that there are various numerical approximations for functions, indicating that the choice of approximation depends on the required accuracy and computational resources.
  • A few participants mention historical context and research related to square root algorithms, including references to CORDIC and other approximation methods.
  • Some participants express curiosity about the implementation of these algorithms in popular libraries and whether they utilize similar optimizations.
  • There are mentions of modern modifications to the original algorithm and links to research articles that provide further insights into the topic.
  • One participant notes that the original algorithm was attributed to Greg Walsh and discusses the importance of understanding the speed and accuracy of library functions compared to custom implementations.
  • There are suggestions for alternative methods to compute the reciprocal square root, including logarithmic approaches and successive approximations.

Areas of Agreement / Disagreement

Participants express a range of views on the efficiency and applicability of the fast inverse square root algorithm, with some supporting its use while others highlight the existence of alternative methods and approximations. The discussion remains unresolved regarding the best approach to numerical approximations.

Contextual Notes

Some participants reference specific historical algorithms and research without fully resolving the implications of these methods or their accuracy compared to modern techniques. There is also a lack of consensus on the optimal choice of algorithm for different scenarios.

  • #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   Reactions: Baluncore

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
22
Views
5K
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
6K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
11
Views
4K
  • · Replies 13 ·
Replies
13
Views
6K