Table of Contents
Fetching ...

A square root algorithm faster than Newton's method for multiprecision numbers, using floating-point arithmetic

Fabio Romano

TL;DR

The work targets efficient computation of integer square roots for multiprecision numbers by reworking Bombelli's shift-and-subtract method to guess entire digits in constant time using floating-point arithmetic. It derives a numerically stable digit-guess formula, $y_i = \left\lfloor \frac{(R_{i+1} x_{2i+1} x_{2i})_b}{\sqrt{(b Y_{i+1})^2 + (R_{i+1} x_{2i+1} x_{2i})_b} + b Y_{i+1}} \right\rfloor$, and provides an implementation strategy in Java with a BigInt-like class and a specialized Floating type, along with a rigorous error analysis and precision requirements. The paper demonstrates that, despite theoretical $O(n^2)$ behavior, the digit-guessing approach dramatically reduces practical constants and outperforms Newton's method in empirical tests on large multiprecision inputs. The results suggest a significant performance impact for high-precision square-root computations in software that relies on big-integer arithmetic.

Abstract

In this paper, an optimized version of classical Bombelli's algorithm for computing integer square roots is presented. In particular, floating-point arithmetic is used to compute the initial guess of each digit of the root, following similar ideas to those used in "The Art of Computer Programming" Vol. 2, p. 4.3.1 for division. A program with an implementation of the algorithm in Java is also presented, and its running time is compared with that of the algorithm provided by the Java standard library, which uses the Newton's method. From tests, the algorithm presented here turns out to be much faster.

A square root algorithm faster than Newton's method for multiprecision numbers, using floating-point arithmetic

TL;DR

The work targets efficient computation of integer square roots for multiprecision numbers by reworking Bombelli's shift-and-subtract method to guess entire digits in constant time using floating-point arithmetic. It derives a numerically stable digit-guess formula, , and provides an implementation strategy in Java with a BigInt-like class and a specialized Floating type, along with a rigorous error analysis and precision requirements. The paper demonstrates that, despite theoretical behavior, the digit-guessing approach dramatically reduces practical constants and outperforms Newton's method in empirical tests on large multiprecision inputs. The results suggest a significant performance impact for high-precision square-root computations in software that relies on big-integer arithmetic.

Abstract

In this paper, an optimized version of classical Bombelli's algorithm for computing integer square roots is presented. In particular, floating-point arithmetic is used to compute the initial guess of each digit of the root, following similar ideas to those used in "The Art of Computer Programming" Vol. 2, p. 4.3.1 for division. A program with an implementation of the algorithm in Java is also presented, and its running time is compared with that of the algorithm provided by the Java standard library, which uses the Newton's method. From tests, the algorithm presented here turns out to be much faster.
Paper Structure (15 sections, 2 theorems, 35 equations, 1 algorithm)

This paper contains 15 sections, 2 theorems, 35 equations, 1 algorithm.

Key Result

Proposition 2.1

For each $x \in \mathbb{N}$, it holds that $x - \lfloor \sqrt x \rfloor^2 \le 2\lfloor \sqrt x \rfloor$.

Theorems & Definitions (12)

  • Definition 2.1: Square root
  • Definition 2.2: Remainder of the square root
  • Proposition 2.1
  • proof
  • Theorem 3.1: Soundness
  • proof
  • Definition 5.1: Floating-point numbers
  • Definition 5.2: Round toward $-\infty$
  • Definition 5.3: Round to nearest
  • Definition 5.4: Next up and next down
  • ...and 2 more