Modified Fast Inverse Square Root and Square Root Approximation Algorithms: The Method of Switching Magic Constants

被引:10
|
作者
Moroz, Leonid V. [1 ]
Samotyy, Volodymyr V. [2 ,3 ]
Horyachyy, Oleh Y. [1 ]
机构
[1] Lviv Polytech Natl Univ, Informat Technol Secur Dept, UA-79013 Lvov, Ukraine
[2] Cracow Univ Technol, Automat & Informat Technol Dept, PL-31155 Krakow, Poland
[3] Lviv State Univ Life Safety, Informat Secur Management Dept, UA-79007 Lvov, Ukraine
关键词
elementary function approximation; fast inverse square root algorithm; IEEE; 754; standard; Newton-Raphson method; fused multiply-add; algorithm design and analysis; maximum relative error; optimization; performance evaluation; processors and microprocessors;
D O I
10.3390/computation9020021
中图分类号
O1 [数学];
学科分类号
0701 ; 070101 ;
摘要
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.
引用
收藏
页码:1 / 23
页数:22
相关论文
共 50 条
  • [1] Fast Differentiable Matrix Square Root and Inverse Square Root
    Song, Yue
    Sebe, Nicu
    Wang, Wei
    arXiv, 2022,
  • [2] Fast Differentiable Matrix Square Root and Inverse Square Root
    Song, Yue
    Sebe, Nicu
    Wang, Wei
    IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, 2023, 45 (06) : 7367 - 7380
  • [3] A Fast FPGA Based Architecture for Computation of Square Root and Inverse Square Root
    Hasnat, Abul
    Bhattacharyya, Tanima
    Dey, Atanu
    Halder, Santanu
    Bhattacharjee, Debotosh
    PROCEEDINGS OF 2ND INTERNATIONAL CONFERENCE ON 2017 DEVICES FOR INTEGRATED CIRCUIT (DEVIC), 2017, : 383 - 387
  • [4] Algorithms for Calculating the Square Root and Inverse Square Root Based on the Second-Order Householder's Method
    Moroz, Leonid
    Samotyy, Volodymyr
    Horyachyy, Oleh
    Dzelendzyak, Ulyana
    PROCEEDINGS OF THE 2019 10TH IEEE INTERNATIONAL CONFERENCE ON INTELLIGENT DATA ACQUISITION AND ADVANCED COMPUTING SYSTEMS - TECHNOLOGY AND APPLICATIONS (IDAACS), VOL. 1, 2019, : 436 - 442
  • [5] Square Root and Inverse Square Root Computation Using a Fast FPGA Based Architecture
    Hasnat, Abul
    Dey, Atanu
    Halder, Santanu
    Bhattacharjee, Debotosh
    JOURNAL OF ACTIVE AND PASSIVE ELECTRONIC DEVICES, 2018, 13 (2-3): : 135 - 147
  • [6] Fast and accurate approximation algorithms for computing floating point square root
    Kokosinski, Zbigniew
    Gepner, Pawel
    Moroz, Leonid
    Samotyy, Volodymyr
    Wegrzyn, Mariusz
    Gavkalova, Nataliia
    NUMERICAL ALGORITHMS, 2024,
  • [7] Fast calculation of inverse square root with the use of magic constant - analytical approach
    Moroz, Leonid V.
    Walczyk, Cezary J.
    Hrynchyshyn, Andriy
    Holimath, Vijay
    Cieslinski, Jan L.
    APPLIED MATHEMATICS AND COMPUTATION, 2018, 316 : 245 - 255
  • [8] A novel approximation scheme for floating-point square root and inverse square root for FPGAs
    Pennestri, Pietro
    Huang, Yanqiu
    Alachiotis, Nikolaos
    2022 11TH INTERNATIONAL CONFERENCE ON MODERN CIRCUITS AND SYSTEMS TECHNOLOGIES (MOCAST), 2022,
  • [9] A Modification of the Fast Inverse Square Root Algorithm
    Walczyk, Cezary J.
    Moroz, Leonid, V
    Cieslinski, Jan L.
    COMPUTATION, 2019, 7 (03)
  • [10] Fast enclosure for a matrix inverse square root
    Miyajima, Shinya
    LINEAR ALGEBRA AND ITS APPLICATIONS, 2015, 467 : 116 - 135