Abstract
Many low-cost platforms that support floating-point arithmetic, such as microcontrollers and field-programmable gate arrays, do not include fast hardware or software methods for calculating the square root and/or reciprocal square root. Typically, such functions are implemented using direct lookup tables or polynomial approximations, with a subsequent application of the Newton–Raphson method. Other, more complex solutions include high-radix digit-recurrence and bipartite or multipartite table-based methods. In contrast, this article proposes a simple modification of the fast inverse square root method that has high accuracy and relatively low latency. Algorithms are given in C/C++ for single- and double-precision numbers in the IEEE 754 format for both square root and reciprocal square root functions. These are based on the switching of magic constants in the initial approximation, depending on the input interval of the normalized floating-point numbers, in order to minimize the maximum relative error on each subinterval after the first iteration—giving 13 correct bits of the result. Our experimental results show that the proposed algorithms provide a fairly good trade-off between accuracy and latency after two iterations for numbers of type float, and after three iterations for numbers of type double when using fused multiply–add instructions—giving almost complete accuracy.
Subject
Applied Mathematics,Modeling and Simulation,General Computer Science,Theoretical Computer Science
Reference40 articles.
1. A root of less evil [digital signal processing
2. Computer Arithmetic: Algorithms and Hardware Designs;Parhami,2010
3. A fast FPGA based architecture for computation of square root and Inverse Square Root
4. The Mathematical-Function Computation Handbook: Programming Using the MathCW Portable Software Library;Beebe,2017
5. The GNU C Library Reference Manual for Version 2.31;Loosemore,2020
Cited by
10 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献