What Can (And Can't) We Do with Sparse Polynomials?
Total Page:16
File Type:pdf, Size:1020Kb
What Can (and Can’t) we Do with Sparse Polynomials? Daniel S. Roche United States Naval Academy Annapolis, Maryland, U.S.A. [email protected] ABSTRACT This sparse representation matches the one used by default for Simply put, a sparse polynomial is one whose zero coefficients are multivariate polynomials in modern computer algebra systems and not explicitly stored. Such objects are ubiquitous in exact computing, libraries such as Magma [83], Maple [73], Mathematica, Sage [84], and so naturally we would like to have efficient algorithms to handle and Singular [81]. them. However, with this compact storage comes new algorithmic challenges, as fast algorithms for dense polynomials may no longer 1.1 Sparse polynomial algorithm complexity be efficient. In this tutorial we examine the state of the art forsparse Sparse polynomials in the distributed representation are also called polynomial algorithms in three areas: arithmetic, interpolation, and lacunary or supersparse [55] in the literature to emphasize that, in factorization. The aim is to highlight recent progress both in theory this representation, the degree of a polynomial could be exponen- and in practice, as well as opportunities for future work. tially larger than its bit-length. This exposes the essential difficulty of computing with sparse polynomials, in that efficient algorithms KEYWORDS for dense polynomials may cost exponential-time in the sparse setting. sparse polynomial, interpolation, arithmetic, factorization Specifically, when analyzing algorithms for dense polynomials, the most important measure is the degree bound D 2 N such that ACM Reference Format: Daniel S. Roche. 2018. What Can (and Can’t) we Do with Sparse Polyno- deg f < D. The size of the dense representation of a univariate poly- mials?. In ISSAC ’18: 2018 ACM International Symposium on Symbolic and nomial is D ring elements, and many operations can be performed ¹ º ¹ º Algebraic Computation, July 16–19, 2018, New York, NY, USA. ACM, New in DO 1 ring operations, or even D¹log DºO 1 . York, NY, USA, 6 pages. https://doi.org/10.1145/3208976.3209027 In the sparse representation, we need to also consider the num- ber of nonzero terms t, and the bit-length of the exponents. For 1 SPARSE POLYNOMIALS a multivariate (sparse) polynomial, the representation size is O¹tº Sparse polynomials are found in the core of nearly every com- ring elements plus O¹nt log Dº bits, where n is the number of vari- puter algebra system or library, and polynomials with many zero ables and D is now an upper bound on the maximum degree. The coefficients frequently occur in practical settings. goal, then, is to develop new sparse polynomial algorithms which Mathematically, the dividing line between a sparse and dense minimize the cost in terms of n, t, and log D. polynomial is not well-defined. From a computer science stand- The coefficient ring R makes a difference for some algorithms. point, there is a clear distinction, depending on the representation In the general setting we let R be an arbitrary integral domain, and of that polynomial in memory: A dense representation stores zero count ring operations. Another important setting is when R = Z, coefficients explicitly and exponents implicitly, whereas a sparse the ring of integers, in which case we also account for the size of representation does not store zero coefficients at all, but stores coefficients. Write H¹f º for the height of a polynomial, which is the exponents explicitly. maximum magnitude maxi jci j of its coefficients; then a fast algo- There are many variants of sparse representations [25]. This rithm on f should have a small running time in terms of log H¹f º. tutorial considers algorithms for the most compact representation, For simplicity of presentation, and because the algorithmic work the so-called distributed sparse storage [72]. Let f 2 R»x1;:::; xn¼ with sparse polynomials is still at a much more coarse level than, be an n-variate polynomial with coefficients in a ring R. The repre- say, that of integers and dense polynomials, we frequently use sentation of f is by a list of t nonzero terms the soft-oh notation O¹γ º := O γ · ¹logγ ºO¹1º , where γ is some arXiv:1807.08289v1 [cs.SC] 22 Jul 2018 e ¹c1; e1;1;:::; e1;nº; ¹c2; e2;1;:::; e2;nº;:::; ¹ct ; et;1;:::; et;nº running-time function. such that 1.2 Overview e1;1 ··· e1;n e2;1 ··· e2;n ··· et;1 ··· et;n f = c1x1 xn + c2x1 xn + + ct x1 xn The basic challenge of sparse polynomial algorithms is to match with each coefficient ci 2 R nonzero and all exponent tuples the complexity of dense polynomial algorithms for the same task. n ¹ei;1;:::; ei;nº 2 N distinct. We also assume that the terms are In some cases, interestingly, this is (provably) not possible — for sorted according to their exponents in some consistent way. a few problems, even a polynomial-time algorithm in the sparse representation size would imply that P = NP. This paper is authored by an employee(s) of the United States Government and is in the public domain. Non-exclusive copying or redistribution is allowed, provided that Where algorithms are possible, one interesting feature is that the article citation is given and the authors and agency are clearly identified as its they must usually take into account not only the coefficient arith- source. metic over R, but also the exponent arithmetic over Z. In fact, the ISSAC ’18, July 16–19, 2018, New York, NY, USA 2018. ACM ISBN 978-1-4503-5550-6/18/07. latter frequently poses the most difficulty in the design of efficient https://doi.org/10.1145/3208976.3209027 algorithms. 25 ISSAC ’18, July 16–19, 2018, New York, NY, USA Daniel S. Roche This tutorial aims to outline the state of sparse polynomial algo- and a careful analysis. They point out that, while the asymptotic rithms, dividing roughly into the three areas of arithmetic, interpo- runtime is the same, the space for intermediate results is only O¹tº, lation, and factorization. We highlight where essentially-optimal no matter how many terms are in the output. This has tremendous algorithms are already known, where they are known not to exist, practical performance benefits, and it seems that many computer and the numerous cases of open problems in between. algebra systems now use this approach in at least some cases. In fact, there seems to be considerable interest in the fastest practical 2 ARITHMETIC speeds for sparse polynomial multiplication on a variety of hard- Polynomials stored in the dense representation can be added and ware platforms including parallel computing [10, 29, 30, 70, 77]. subtracted in linear-time. Dense polynomial multiplication costs Still, this is unsatisfying from an algorithmic perspective since O D2 ring operations using the classical algorithm, but consider- the number of ring and bit-operations is still quadratic in every able research effort has gone to reducing this complexity, which case, meaning that even the heap-based algorithms will have a hard we now denote as simply M¹Dº. The most general result of [16] cut-off with the speed of dense multiplication as polynomials start gives M¹Dº 2 O¹D log D loglognº, and more recent work [27, 44] to fill-in with nonzero coefficients. reduces this even further for most commonly-used rings. Another approach is to consider the size of the output as a pa- Many other polynomial computations can be reduced to mul- rameter in the complexity. In the worst case, this can be quadratic tiplication. In particular, Euclidean division with remainder costs in the input size, but in cases where the output is smaller, we can O¹M¹Dºº, and (extended) gcd, multi-point evaluation, interpola- hope for faster computation. Furthermore, considering the output tion, Chinese remaindering, and rational reconstruction all cost size allows for a smooth transition to dense algorithms, where the O¹M¹Dº log Dº ring operations [14, §2–6] [32, §8–11]. Note that all output is guaranteed to have at most 2D nonzero terms. these operations take quasi-linear time in the input size Oe¹Dº. Open Problem 1. Develop an algorithm to multiply two sparse As discussed previously, these algorithms are not polynomial- polynomials f ;д 2 R»x¼ using Oe¹t log Dº ring and bit operations, time in the size of the sparse representation. where t is the number of terms in f , д, and f д, and D is an upper bound on their degrees. 2.1 Addition and subtraction Adding or subtracting sparse polynomials is a matter of combining Considerable progress has been made toward this open problem, like terms, which amounts to a merge operation on the two lists of and it seems now nearly within reach. Some authors have looked at nonzero terms. From our assumption that terms are stored in sorted special cases, when the support of nonzero coefficients has a certain order, this costs O¹t log Dº bit operations and O¹tº ring additions, structure, to reduce to dense multiplication and achieve the desired where t is the number of terms in the two input polynomials. This complexity in those cases [45, 79, 80]. matches the size of the input and is therefore optimal. A more general solution approach is to use sparse interpolation Notice, however, that the size of the output can grow much more algorithms, which we examine in further detail in the next section. quickly than with dense polynomials. When adding two dense poly- First, [46] showed that the open problem is essentially solved when nomials with degrees less than D, the cost is O¹Dº and the output the support of the product is already known.