Sieve algorithms for perfect power testing Eric Bach Jonathan Sorenson Article Received: 13 February 1990 Revised: 10 January 1991 DOI :
10.1007/BF01228507

Cite this article as: Bach, E. & Sorenson, J. Algorithmica (1993) 9: 313. doi:10.1007/BF01228507
6
Citations
134
Downloads
Abstract A positive integern is a perfect power if there exist integersx andk , both at least 2, such thatn=x ^{k} . The usual algorithm to recognize perfect powers computes approximatekth roots fork≤log _{2} n , and runs in time O(log^{3} n log log logn ).

First we improve this worst-case running time toO (log^{3} n ) by using a modified Newton's method to compute approximatek th roots. Parallelizing this gives anNC ^{2} algorithm.

Second, we present a sieve algorithm that avoidsk th-root computations by seeing if the inputn is a perfectk th power modulo small primes. Ifn is chosen uniformly from a large enough interval, the average running time isO (log^{2} n ).

Third, we incorporate trial division to give a sieve algorithm with an average running time ofO (log^{2} n/log^{2} logn ) and a median running time ofO (logn ).

The two sieve algorithms use a precomputed table of small primes. We give a heuristic argument and computational evidence that the largest prime needed in this table is (logn)^{1+O(1)} ; assuming the Extended Riemann Hypothesis, primes up to (logn )^{2+O(1)} suffice. The table can be computed in time roughly proportional to the largest prime it contains.

We also present computational results indicating that our sieve algorithms perform extremely well in practice.

Key words Perfect powers Number theoretic algorithms Riemann hypothesis Newton's method Sieve algorithms Parallel algorithms Average-case analysis This work forms part of the second author's Ph.D. thesis at the University of Wisconsin-Madison, 1991. This research was sponsored by NSF Grants CCR-8552596 and CCR-8504485.

Communicated by Allan Borodin.

References [1]

E. Bach. How to generate factored random numbers.

SIAM J. Comput. ,

2 :179–193, 1988.

Google Scholar [2]

E. Bach, G. Miller and J. Shallit. Sums of Divisors, perfect numbers, and factoring.

SIAM J. Comput. ,

4 :1143–1154, 1986.

Google Scholar [3]

E. Bach and J. Shallit. Factoring with cyclotomic polynomials.

Math. Comp. ,

52 (185):201–219, 1989.

Google Scholar [4]

P. W. Beame, S. A. Cook and H. J. Hoover. Log depth circuits for division and related problems.

SIAM J. Comput. ,

15 :994–1003, 1986.

Google Scholar [5]

R. P. Brent. Multiple precision zero-finding methods and the complexity of elementary function evaluation. In J. F. Traub, editor,

Analytical Computational Complexity , pp. 151–176. Academic Press, New York, 1976.

Google Scholar [6]

A. Cobham. The recognition problem for the set of perfect squares. InProceedings of the 7th Annual Symposium on Switching and Automata Theory , pp. 78–87, 1966.

[7]

G. E. Collins. Computing multiplicative inverses in

GF(p) .

Math. Comp. ,

23 :197–200, 1969.

Google Scholar [8]

H. Davenport.

Multiplicative Number Theory . Springer-Verlag, New York, 1980.

Google Scholar [9]

J. Dixon. Asymptotically fast factorization of integers.

Math. Comp. ,

36 (153):255–260, 1981.

Google Scholar [10]

S. Goldwasser and J. Kilian. Almost all primes can be quickly certified. InProceedings of the 18th Annual ACM Symposium on Theory of Computing , pp. 316–329, 1986.

[11]

S. W. Golomb. A new arithmetic function of combinatorial significance.

J. Number Theory ,

5 :218–223, 1973.

Google Scholar [12]

J. L. Hafner and K. S. McCurley. On the distribution of running times of certain integer factoring algorithms.

J. Algorithms ,

10 (4):531–556, 1989.

Google Scholar [13]

G. H. Hardy and E. M. Wright.

An Introduction to the Theory of Numbers , Oxford University Press, Oxford, 5th edition. 1979.

Google Scholar [14]

K. Ireland and M. Rosen.

A Classical Introduction to Modern Number Theory . Springer-Verlag, New York, 1982.

Google Scholar [15]

W. B. Jurkat and H.-E. Richert. An improvement of Selberg's sieve method I.

Acta. Arith. ,

11 :217–240, 1965.

Google Scholar [16]

R. Karp and V. Ramachandran. Parallel algorithms for shared memory machines. In J. van Leeuwen, editor,

Algorithms and Complexity , Chapter 17, pp. 871–941. Handbook of Theoretical Computer Science Series, Volume A. Elsevier, Amsterdam, and MIT Press, Cambridge, MA, 1990.

Google Scholar [17]

D. E. Knuth.

The Art of Computer Programming: Seminumerical Algorithms , Volume 2, 2nd edition. Addison-Wesley, Reading, MA. 1981.

Google Scholar [18]

D. E. Knuth and L. Trabb Pardo. Analysis of a simple factorization algorithm.

Theoret. Comput. Sci. ,

3 :321–348, 1976.

Google Scholar [19]

A. K. Lenstra, H. W. Lenstra, Jr., M. S. Manasse and J. M. Pollard. The number field sieve. InProceedings of the 22nd Annual ACM Symposium on Theory of Computing , pp. 564–572, 1990.

[20]

H. W. Lenstra, Jr. Factoring integers with elliptic curves.

Ann. of Math. ,

126 :649–673, 1987.

Google Scholar [21]

V. Miller. Private communication, 1989.

[22]

C. A. Neff. Specified precision polynomial root isolation is in NC. InProceedings of 31st Annual IEEE Symposium on Foundations of Computer Science , pp. 152–162, 1990.

[23]

V. Pan. Fast and efficient algorithms for sequential and parallel evaluation of polynomial zeros and of matrix polynomials. InProceedings of the 26th Annual IEEE Symposium on Foundations of Computer Science , pp. 522–531, 1985.

[24]

J. M. Pollard. Theorems on factorization and primality testing.

Math. Proc. Cambridge Philos. Soc. ,

76 :521–528, 1974.

Google Scholar [25]

C. Pomerance. Fast, rigorous factorization and discrete logarithm algorithms. In D. S. Johnson, A. Nishizeke, A. Nozaki, and H. S. Wilf, editors,

Discrete Algorithms and Complexity: Proceedings of the Japan-US Joint Seminar , pp. 119–143. Perspectives in Computing Series, Volume 15, Academic Press, Boston. 1987.

Google Scholar [26]

P. Pritchard. Fast compact prime number sieves (among others).

J. Algorithms ,

4 :332–344, 1983.

Google Scholar [27]

J. B. Rosser and L. Schoenfeld. Approximate formulas for some functions of prime numbers.

Illinois J. Math. ,

6 :64–94, 1962.

Google Scholar [28]

J. Shallit. Course Notes for Number Theory and Algorithms. Dartmouth College, 1989.

[29]

V. Shoup. On the deterministic complexity of factoring polynomials over finite fields.

Inform. Process. Lett. ,

33 :261–267, 1990.

Google Scholar [30]

E. C. Titchmarsh. A divisor problem.

Rend. Circ. Mat. Palermo ,

54 :414–429, 1930.

Google Scholar [31]

S. S. Wagstaff, Jr., Greatest of the least primes in arithmetic progressions having a certain modulus.

Math. Comp. ,

33 :1073–1080, 1979.

Google Scholar © Springer-Verlag New York Inc. 1993

Authors and Affiliations Eric Bach Jonathan Sorenson 1. Computer Sciences Department University of Wisconsin-Madison Madison USA 2. Department of Mathematics and Computer Science Butler University Indianapolis USA