Primality Testing for Beginners
Total Page:16
File Type:pdf, Size:1020Kb
STUDENT MATHEMATICAL LIBRARY Volume 70 Primality Testing for Beginners Lasse Rempe-Gillen Rebecca Waldecker http://dx.doi.org/10.1090/stml/070 Primality Testing for Beginners STUDENT MATHEMATICAL LIBRARY Volume 70 Primality Testing for Beginners Lasse Rempe-Gillen Rebecca Waldecker American Mathematical Society Providence, Rhode Island Editorial Board Satyan L. Devadoss John Stillwell Gerald B. Folland (Chair) Serge Tabachnikov The cover illustration is a variant of the Sieve of Eratosthenes (Sec- tion 1.5), showing the integers from 1 to 2704 colored by the number of their prime factors, including repeats. The illustration was created us- ing MATLAB. The back cover shows a phase plot of the Riemann zeta function (see Appendix A), which appears courtesy of Elias Wegert (www.visual.wegert.com). 2010 Mathematics Subject Classification. Primary 11-01, 11-02, 11Axx, 11Y11, 11Y16. For additional information and updates on this book, visit www.ams.org/bookpages/stml-70 Library of Congress Cataloging-in-Publication Data Rempe-Gillen, Lasse, 1978– author. [Primzahltests f¨ur Einsteiger. English] Primality testing for beginners / Lasse Rempe-Gillen, Rebecca Waldecker. pages cm. — (Student mathematical library ; volume 70) Translation of: Primzahltests f¨ur Einsteiger : Zahlentheorie - Algorithmik - Kryptographie. Includes bibliographical references and index. ISBN 978-0-8218-9883-3 (alk. paper) 1. Number theory. I. Waldecker, Rebecca, 1979– author. II. Title. QA241.R45813 2014 512.72—dc23 2013032423 Copying and reprinting. Individual readers of this publication, and nonprofit libraries acting for them, are permitted to make fair use of the material, such as to copy a chapter for use in teaching or research. Permission is granted to quote brief passages from this publication in reviews, provided the customary acknowledgment of the source is given. Republication, systematic copying, or multiple reproduction of any material in this publication is permitted only under license from the American Mathematical Society. Requests for such permission should be addressed to the Acquisitions Department, American Mathematical Society, 201 Charles Street, Providence, Rhode Island 02904- 2294 USA. Requests can also be made by e-mail to [email protected]. c 2014 by the authors. Printed in the United States of America. ∞ The paper used in this book is acid-free and falls within the guidelines established to ensure permanence and durability. Visit the AMS home page at http://www.ams.org/ 10 9 8 7 6 5 4 3 2 1 18 17 16 15 14 For our spouses, Emma and Lars Contents Preface xi Introduction 1 Part 1. Foundations Chapter 1. Natural numbers and primes 13 §1.1. The natural numbers 13 §1.2. Divisibility and primes 26 §1.3. Prime factor decomposition 31 §1.4. The Euclidean algorithm 35 §1.5. The Sieve of Eratosthenes 39 §1.6. There are infinitely many primes 41 Further reading 42 Chapter 2. Algorithms and complexity 43 §2.1. Algorithms 43 §2.2. Decidable and undecidable problems 52 §2.3. Complexity of algorithms and the class P 57 §2.4. The class NP 68 vii viii Contents §2.5. Randomized algorithms 73 Further reading 81 Chapter 3. Foundations of number theory 83 §3.1. Modular arithmetic 84 §3.2. Fermat’s Little Theorem 94 §3.3. A first primality test 104 §3.4. Polynomials 107 §3.5. Polynomials and modular arithmetic 120 Further reading 127 Chapter 4. Prime numbers and cryptography 129 §4.1. Cryptography 129 §4.2. RSA 132 §4.3. Distribution of primes 136 §4.4. Proof of the weak prime number theorem 139 §4.5. Randomized primality tests 143 Further reading 150 Part 2. The AKS Algorithm Chapter 5. The starting point: Fermat for polynomials 153 §5.1. A generalization of Fermat’s Theorem 153 §5.2. The idea of the AKS algorithm 159 §5.3. The Agrawal-Biswas test 163 Chapter 6. The theorem of Agrawal, Kayal, and Saxena 169 §6.1. Statement of the theorem 170 §6.2. The idea of the proof 171 §6.3. The number of polynomials in P 173 §6.4. Cyclotomic polynomials 178 Contents ix Chapter 7. The algorithm 183 §7.1. How quickly does the order of n modulo r grow? 183 §7.2. The algorithm of Agrawal, Kayal, and Saxena 186 §7.3. Further comments 189 Further reading 192 Appendix A. Open questions 193 Further reading 205 Appendix B. Solutions and comments to important exercises 207 Bibliography 233 List of symbols 237 Index 239 Preface “How on earth can you do research in mathematics?”, we are of- ten asked. The idea of ongoing research in other sciences is deeply embedded in the public consciousness, not only in those fields that may lead to self-driving cars or new life-saving drugs, but also in the most theoretical areas such as particle physics, where scientists try to puzzle out the likely nature of matter on the smallest possible scales. In contrast, even among members of the public who profess their enjoyment of mathematics there is little awareness that many mathematical questions remain open and that these are the subject of intensive investigation. One of the difficulties in challenging this perception lies in the highly specialized nature of modern mathematics itself. Even profes- sional mathematicians are usually unable to fully appreciate research advances outside their own branches of mathematics. Of course there are exceptions to this rule, such as Fermat’s Last Theorem,which was proved by Andrew Wiles in the 1990s and could hardly be sim- pler to state: “If n>2, then there are no non-zero integers a, b,and c such that an + bn = cn.” Yet in this case the proof is particularly long and difficult, and only a small number of experts worldwide are able to fully comprehend it. xi xii Preface In the summer of 2002, the computer scientist Manindra Agrawal and his students Neeraj Kayal and Nitin Saxena achieved a remark- able feat: they discovered an efficient and deterministic test for the primality of a natural number. (To learn about the meaning of these notions, keep reading!) We were fascinated by this result not only be- cause it answers a long-standing open question, but because the math- ematics behind it is beautiful and, compared to other modern research advances, extremely accessible. We decided to use this opportunity to get young people in touch with actual mathematical research by offering a course on the subject at a German summer academy for secondary-school students in 2005. Inspired by the participants and their enthusiasm, we started to transform the course material into a book manuscript, the German version of which appeared in 2009. The book you hold in your hands is an English-language edition of this text. During the translation process, we have also corrected a few errors, changed some of the presentation for pedagogical reasons, and updated the content with new results, where appropriate. We thank the students from our original summer course for their motivation and dedication and all those who have since helped us for their comments and suggestions regarding both the German and English editions. We also thank you – our reader – for your interest in this little volume, and we hope that you will enjoy reading the book as much as we did writing it. Lasse Rempe-Gillen and Rebecca Waldecker August 2013 Bibliography [AB] Agrawal, M. and Biswas, S.: Primality and identity testing via Chinese remaindering. Journal of the ACM 50 (2003), no. 4, 429– 443. [AKS] Agrawal, M., Kayal, N., and Saxena, K.: PRIMES is in P. Annals of Math. 160 (2004), no. 2, 781–793. [AO]¨ A˘garg¨un, A. G¨oksel and Ozkan,¨ E. Mehmet: A historical survey of the fundamental theorem of arithmetic. Historia Math. 28 (2001), no. 3, 207–214. [Be] Beutelspacher, A.: Cryptology. Mathematical Association of America, 1994. [Bo] Bornemann, F.: Primes is in P: A breakthrough for “Everyman”. Notices of the AMS 50 (2003), no. 5, 545–552. [Br] Bryant, V.: Yet Another Introduction to Analysis, Cambridge Uni- versity Press, 1990. [Ch] Chen, J. R.: On the representation of a larger even integer as the sum of a prime and the product of at most two primes. Sci. Sinica 16 (1973), 157–176. [Co] Conrey, J. B.: The Riemann Hypothesis. Notices of the AMS 50 (2003), no. 3, 341–353. [CLR] Cormen, T. H., Leiserson, C. E., and Rivest, R. L.: Introduction to Algorithms. Third Edition, MIT Press, 2009. [CM] Coron, J.-S. and May, A.: Deterministic polynomial-time equiva- lence of computing the RSA secret key and factoring. J. Cryptology 20 (2007), 39–50. 233 234 Bibliography [CP] Crandall, R. and Pomerance, C.: Prime Numbers: A Computa- tional Perspective. Springer, 2005. [De] Derbyshire, J.: Prime Obsession: Bernhard Riemann and the Greatest Unsolved Problem in Mathematics. Penguin, 2004. [Dst] Diestel, R.: Graph Theory. Fourth edition, Springer, 2010. [Dtz] Dietzfelbinger, M.: Primality Testing in Polynomial Time: From Randomized Algorithms to “PRIMES Is in P”. Springer, 2004. [Do] Doxiadis, A.K.: Uncle Petros and Goldbach’s Conjecture: A Novel of Mathematical Obsession. Bloomsbury, 2001. [EFT] Ebbinghaus, H.-D., Flum, J., and Thomas, W.: Mathematical Logic. Second edition, Springer, 1994. [Eb] Ebbinghaus et al.: Numbers. Third printing, Springer, 1996. [Ec] Eccles, P.: An Introduction to Mathematical Reasoning: Numbers, Sets and Functions. Cambridge University Press, 1997. [Frl] Fraleigh, J. B.: A First Course in Abstract Algebra. Seventh edi- tion, Pearson, 2003. [Frz] Franz´en, T.: G¨odel’s Theorem: An Incomplete Guide to Its Use and Abuse. Peters, 2005. [F¨u] F¨urer, M.: Faster Integer Multiplication. Proceedings of the 39th Annual ACM Symposium on Theory of Computing (2007), 57–66. [G] Granville, A.: It is easy to determine whether a given integer is prime. Bull.Amer.Math.Soc.42 (2005), no.