 # Implementation of a Near-Optimal Complex Root Clustering Algorithm

We describe Ccluster, a software for computing natural ϵ-clusters of complex roots in a given box of the complex plane. This algorithm from Becker et al. (2016) is near-optimal when applied to the benchmark problem of isolating all complex roots of an integer polynomial. It is one of the first implementations (Irina Voiculescu informed us that her student Dan-Andrei Gheorghe has independently implemented the same algorithm in a Masters Thesis Project (May 18, 2017) at Oxford University. Sewon Park and Martin Ziegler at KAIST, Korea, have implemented a modified version of Becker et al.(2016) for polynomials having only real roots being the eigenvalues of symmetric square matrices with real coefficients) of a near-optimal algorithm for complex roots. We describe some low level techniques for speeding up the algorithm. Its performance is compared with the well-known MPSolve library and Maple.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The problem of root finding for a polynomial is a classical problem from antiquity, but remains the subject of active research to the present . We consider a classic version of root finding:

Local root isolation problem: Given: a polynomial , a box , . Output: a set of pairwise-disjoint discs of radius , each containing a unique root of in .

It is local because we only look for roots in a locality, as specified by . The local problem is useful in applications (especially in geometric computation) where we know where to look for the roots of interest. There are several variants of this problem: in the global version, we are not given , signifying that we wish to find all the roots of . The global version is easily reduced to the local one by specifying a that contains all roots of . If we omit , it amounts to setting , representing the pure isolation problem.

Our main interest is a generalization of root isolation, to the lesser-studied problem of root clustering [10, 12, 8]. It is convenient to introduce two definitions: for any set , let denote the set of roots of in , and let count the total multiplicity of the roots in . Typically, is a disc or a box. For boxes and discs, we may write (for any ) to denote the dilation of by factor , keeping the same center. The following problem was introduced in :

Local root clustering problem: Given: a polynomial , a box , . Output: a set of pairs where ’s are pairwise-disjoint discs of radius , for all , and

This generalization of root isolation is necessary when we consider polynomials whose coefficients are non-algebraic (or when is an analytic function, as in ). The requirement that ensures that our output clusters are natural ; a polynomial of degree has at most natural clusters (see [16, Lemma 1]). The local root clustering algorithm for analytic functions of  has termination proof, but no complexity analysis. By restricting to a polymomial, Becker et al.  succeeded in giving an algorithm and also its complexity analysis based on the geometry of the roots. When applied to the benchmark problem, where is an integer polynomial of degree with -bit coefficients, the algorithm can isolate all the roots of with bit complexity . Pan  calls such bounds near-optimal (at least when ). The clustering algorithm studied in this paper comes from , which in turn is based on . Previously, the Pan-Schönhage algorithm has achieved near-optimal bounds with divide-and-conquer methods , but [2, 1] was the first subdivision algorithm to achieve the near-optimal bound for complex roots. For real roots, Sagraloff-Mehlhorn  had earlier achieved near-optimal bound via subdivision.

Why the emphasis on “subdivision”? It is because such algorithms are implementable and quite practical (e.g., ). Thus the near-optimal real subdivision algorithm of  was implemented shortly after its discovery, and reported in  with excellent results. In contrast, all the asymptotically efficient root algorithms (not necessarily near-optimal) based on divide-and-conquer methods of the last 30 years have never been implemented; a proof-of-concept implementation of Schönhage’s algorithm was reported in Gourdon’s thesis ). Computer algebra systems mainly rely on algorithms with a priori guarantees of correctness. But in practice, algorithms without such guarantees are widely used. For complex root isolation, one of the most highly regarded multiprecision software is MPSolve . The original algorithm in MPSolve was based on Erhlich-Aberth (EA) iteration; but since 2014, a “hybrid” algorithm  was introduced. It is based on the secular equation, and combines ideas from EA and eigensolve  . These algorithms are inherently global solvers (they must approximate all roots of a polynomial simultaneously). Another theoretical limitation is that the global convergence of these methods is not proven.

In this paper, we give a preliminary report about Ccluster, our implementation of the root clustering algorithm from . Figure 1: Left: the connected components isolating all roots of the Bernoulli polynomial of degree 100. Right: the connected components isolating all roots of the Spiral polynomial of degree 64.

To illustrate the performance for the local versus global problem, consider the Bernoulli polynomials where ’s are the Bernoulli numbers. Figure 1(Left) shows the graphical output of Ccluster for . Table 1 has four timings (for ) in seconds: is the time for solving the local problem over a box ; is the time for the global problem over the box (which contains all the roots). The other two timings from MPSolve ( for unisolve, for secsolve) will be explained later. For each instance, we also indicate the numbers of solutions (#Sols) and clusters (#Clus). When #Sols equals #Clus, we know the roots are isolated. Subdivision algorithms like ours naturally solve the local problem, but MPSolve can only solve the global problem. Table 1 shows that MPSolve remains unchallenged for the global problem. But in applications where locality can be exploited, local methods may win, as seen in the last two rows of the table. The corresponding time for Maple’s fsolve is also given; fsolve is not a guaranteed algorithm and may fail.

Overview of Paper In Section 2, we describe the experimental setup for Ccluster. Sections 3-5 describe some techniques for speeding up the basic algorithm. We conclude with Section 6.

## 2 Implementation and Experiments

The main implementation of Ccluster is in C language. We have an interface for Julia222https://julialang.org/. Download our code in https://github.com/rimbach/Ccluster. . We based our big number computation on the arb333http://arblib.org/. Download our code in https://github.com/rimbach/Ccluster.jl. library. The arb library implements ball arithmetic for real numbers, complex numbers and polynomials with complex coefficients. Each arithmetic operation is carried out with error bounds.

### Test Suite

We consider 7 families of polynomials, classic ones as well as some new ones constructed to have interesting clustering or multiple root structure.

1. The Bernoulli polynomial of degree is described in Section 1.

2. The Mignotte polynomial for a positive integer , has two roots whose separation is near the theoretical minimum separation bound.

3. The Wilkinson polynomials .

4. The Spiral Polynomial See Figure 1(Right) for .

5. Wilkinson Multiple: . has degree where the root has multiplicity (for ).

6. Mignotte Cluster: . This polynomial has degree (assuming ) and has a cluster of roots near and a cluster of roots near .

7. Nested Cluster: has degree and is defined by induction on : with roots where . Inductively, if the roots of are , then we define See Figure 2 for the natural -clusters of . Figure 2: Left: 3 clusters of \tt NestClu(3) found with ε=1. Right: Zoomed view of 9 clusters of \tt NestClu(3) found with ε=110. Note: The initial box is in thick lines; the thin lines show the subdivisions tree.

### Timing

Running times are sequential times on a Intel(R) Core(TM) i3 CPU 530 @ 2.93GHz machine with linux. Ccluster implements the algorithm described in  with differences coming from the improvements described in Sections 3-5 below. Unless explicitly specified, the value of for Ccluster is set to ; roughly speaking, it falls back to asking for 15 guaranteed decimal digits.

### MPSolve

For external comparison, we use MPSolve. It was shown to be superior to major software such as Maple or Mathematica . There are two root solvers in MPSolve: the original unisolve  which is based on the Ehrlich-Aberth iteration and the new hybrid algorithm called secsolve . These are called with the commands mpsolve -au -Gi -o -j1 and mpsolve -as -Gi -o -j1 (respectively). -Gi means that MPSolve tries to find for each root a unique complex disc containing it, such that Newton iteration is guaranteed to converge quadratically toward the root starting from the center of the disc. -o means that is used as an escape bound, i.e., the algorithm stops when the complex disc containing the root has radius less that , regardless of whether it is isolating or not. Unless explicitly specified, we set . -j1 means that the process is not parallelized. Although MPSolve does not do general local search, it has an option to search only within the unit disc. This option does not seem to lead to much improvement.

## 3 Improved Soft Pellet Test

The key predicate in  is a form of Pellet test denoted (with implicit ). This is modified in Figure 3 by adding an outer while-loop to control the number of Graeffe-Dandelin iterations. We try to get a definite decision (i.e., anything other than a unresolved) from the soft comparison for the current Graeffe iteration. This is done by increasing the precision for approximating the coefficients of in the innermost while-loop. Thus we have two versions of our algorithm: (V1) uses the original in , and (V2) uses the modified form in Figure 3. Let V1 and V2 be timings for the 2 versions. Table 2 shows the time V1 (in seconds) and the ratio V1/V2. We see that (V2) achieves a consistent 2.3 to 3-fold speed up.

In (V2), as in , we use (defined as ) to prove that a box has no root. We propose a new version (V3) that uses (defined as , where is the degree of ) instead of to achieve this goal: instead of just showing that has no root, it upper bounds . Although counter-intuitive, this yields a substantial improvement because it led to fewer Graeffe iterations overall. The timing for (V3) is V3, but we display only the ratio V1/V3 in the last column of Table 2. This ratio shows that (V3) enjoys a 3.3-7.7 fold speedup. Comparing for (V2) and (V3) explains this speedup.

## 4 Filtering

A technique for speeding up the evaluation of predicates is the idea of filters (e.g., ). The various Pellet tests can be viewed as a box predicate that maps a box to a value555 We treat two-valued predicates for simplicity; the discussion could be extended to predicates (like ) which returns a finite set of values. in . If is another box predicate with property that implies , we call a falsehood filter. If is efficient relatively to , and “efficacious” (informally, is likely to yield ), then it is useful to first compute . If , we do not need to compute . The predicate used in Ccluster  is defined as follows: is true if returns (then contains no root of ) and is false if returns or (then may contain some roots of ). We next present the falsehood filter for .

Let denote the Taylor shift of in , its -th Graeffe iterate, the -th coefficient of , and the absolute value of the -th coefficient. Let be the degree of . The assertion below is a direct consequence of the classical test of Pellet (see [p. 12]) and justify the correctness of our filters:
if then returns or .
Our filter computes , and and checks hypothesis of using IntCompare. and can respectively be computed as and . can be computed with the following well known formula:

 (f[i+1]Δ)k=(−1)k((f[i]Δ)k)2+2k−1∑j=0(−1)j(f[i]Δ)j(f[i]Δ)2k−j (1)

Obtaining with eq. (1) requires to know coefficients of , coefficients of and finally coefficients of . In particular, it requires to compute entirely the iterations such that , and it is possible to do it more efficiently that with eq. (1) (for instance with the formula given in definition 2 of ).

Our filter takes as input a precision , the Taylor shift of the bit approximation of and its -th Graeffe iteration such that and . It computes , and the first coefficients of for with eq. (1). Then it checks the hypothesis of using IntCompare, and returns false if it is verified, and true otherwise. In practice, it is implemented within the procedure implementing .

Incorporating into Version (V3), we obtain (V4) and the speed up can be seen in Table 3. Filtering with becomes more effective as degree grows and this is because one has for smaller (recall that ).

## 5 Escape Bound

The parameter is usually understood as the precision desired for roots. But we can also view it as an escape bound for multiple roots as follows: we do not refine a disc that contains a simple root, even if its radius is . But for clusters of size greater than one, we only stop when the radius is . MPSolve has a similar option. This variant of (V4) is denoted (V4’). We see from Table 4 that (V4’) gives a modest improvement (up to 25% speedup) over (V4) when . This improvement generally grows with (but shows no difference).

## 6 Conclusion

Implementing subdivision algorithms is relatively easy but achieving state-of-art performance requires much optimization and low-level development. This paper explores several such techniques. We do well compared to fsolve in Maple, but the performance of MPSolve is superior to the global version of Ccluster. But Ccluster can still shine when looking for local roots or when is large.

## References

•  R. Becker, M. Sagraloff, V. Sharma, J. Xu, and C. Yap. Complexity analysis of root clustering for a complex polynomial. In Proceedings of the ACM on International Symposium on Symbolic and Algebraic Computation, pages 71–78. ACM, 2016.
•  R. Becker, M. Sagraloff, V. Sharma, and C. Yap. A near-optimal subdivision algorithm for complex root isolation based on the pellet test and newton iteration. Journal of Symbolic Computation, 86:51–96, 2018.
•  D. A. Bini and G. Fiorentino. Design, analysis, and implementation of a multiprecision polynomial rootfinder. Numerical Algorithms, 23(2-3):127–173, 2000.
•  D. A. Bini and L. Robol. Solving secular and polynomial equations: A multiprecision algorithm. Journal of Computational and Applied Mathematics, 272:276–292, 2014.
•  H. Brönnimann, C. Burnikel, and S. Pion. Interval arithmetic yields efficient dynamic filters for computational geometry. Discrete Applied Mathematics, 109(1-2):25–47, 2001.
•  I. Z. Emiris, V. Y. Pan, and E. P. Tsigaridas. Algebraic algorithms. In Computing Handbook, Third Edition: Computer Science and Software Engineering, pages 10: 1–30. Chapman and Hall/CRC, 2014.
•  S. Fortune. An iterated eigenvalue algorithm for approximating roots of univariate polynomials. Journal of Symbolic Computation, 33(5):627–646, 2002.
•  M. Giusti, G. Lecerf, B. Salvy, and J.-C. Yakoubsohn. On location and approximation of clusters of zeros of analytic functions. Foundations of Computational Mathematics, 5(3):257–311, 2005.
•  X. Gourdon. Combinatoire, Algorithmique et Géométrie des Polynomes. PhD thesis, École Polytechnique, 1996.
•  V. Hribernig and H. J. Stetter. Detection and validation of clusters of polynomial zeros. Journal of Symbolic Computation, 24(6):667–681, 1997.
•  A. Kobel, F. Rouillier, and M. Sagraloff. Computing real roots of real polynomials… and now for real! In Proceedings of the ACM on International Symposium on Symbolic and Algebraic Computation, pages 303–310. ACM, 2016.
•  X.-M. Niu, T. Sakurai, and H. Sugiura. A verified method for bounding clusters of zeros of analytic functions. Journal of computational and applied mathematics, 199(2):263–270, 2007.
•  V. Y. Pan. Univariate polynomials: nearly optimal algorithms for numerical factorization and root-finding. Journal of Symbolic Computation, 33(5):701–733, 2002.
•  F. Rouillier and P. Zimmermann. Efficient isolation of polynomial’s real roots. Journal of Computational and Applied Mathematics, 162(1):33–50, 2004.
•  M. Sagraloff and K. Mehlhorn. Computing real roots of real polynomials. Journal of Symbolic Computation, 73:46–86, 2016.
•  C. Yap, M. Sagraloff, and V. Sharma. Analytic root clustering: A complete algorithm using soft zero tests. In Conference on Computability in Europe, pages 434–444. Springer, 2013.