Modern Computer Arithmetic

Total Page:16

File Type:pdf, Size:1020Kb

Modern Computer Arithmetic Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Version 0.5.2 Copyright c 2003-2010 Richard P. Brent and Paul Zimmermann ° This electronic version is distributed under the terms and conditions of the Creative Commons license “Attribution-Noncommercial-No Derivative Works 3.0”. You are free to copy, distribute and transmit this book under the following conditions: Attribution. You must attribute the work in the manner specified • by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial. You may not use this work for commercial purposes. • No Derivative Works. You may not alter, transform, or build upon • this work. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the web page below. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author’s moral rights. For more information about the license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ Contents Contents iii Preface ix Acknowledgements xi Notation xiii 1 Integer Arithmetic 1 1.1 Representation and Notations . 1 1.2 AdditionandSubtraction . 2 1.3 Multiplication........................... 3 1.3.1 Naive Multiplication . 4 1.3.2 Karatsuba’s Algorithm . 5 1.3.3 Toom–Cook Multiplication . 7 1.3.4 Use of the Fast Fourier Transform (FFT) . 8 1.3.5 Unbalanced Multiplication . 9 1.3.6 Squaring.......................... 12 1.3.7 Multiplication by a Constant . 15 1.4 Division .............................. 15 1.4.1 Naive Division . 16 1.4.2 Divisor Preconditioning . 18 1.4.3 Divide and Conquer Division . 19 1.4.4 Newton’sMethod. 23 1.4.5 Exact Division . 23 1.4.6 Only Quotient or Remainder Wanted . 24 1.4.7 Division by a Single Word . 25 1.4.8 Hensel’s Division . 26 iii iv Modern Computer Arithmetic, version 0.5.2 of July 31, 2010 1.5 Roots ............................... 27 1.5.1 SquareRoot........................ 27 1.5.2 k-thRoot ......................... 29 1.5.3 ExactRoot ........................ 30 1.6 Greatest Common Divisor . 31 1.6.1 NaiveGCD ........................ 32 1.6.2 ExtendedGCD ...................... 35 1.6.3 Half Binary GCD, Divide and Conquer GCD . 36 1.7 BaseConversion.......................... 40 1.7.1 QuadraticAlgorithms . 41 1.7.2 SubquadraticAlgorithms. 41 1.8 Exercises.............................. 43 1.9 NotesandReferences . 48 2 Modular Arithmetic and the FFT 51 2.1 Representation .......................... 51 2.1.1 Classical Representation . 51 2.1.2 Montgomery’s Form . 52 2.1.3 ResidueNumberSystems . 53 2.1.4 MSBvsLSBAlgorithms . 53 2.1.5 Link with Polynomials . 53 2.2 ModularAdditionandSubtraction . 54 2.3 TheFourierTransform . 54 2.3.1 Theoretical Setting . 55 2.3.2 The Fast Fourier Transform . 56 2.3.3 The Sch¨onhage-Strassen Algorithm . 60 2.4 ModularMultiplication. 63 2.4.1 Barrett’sAlgorithm. 63 2.4.2 Montgomery’s Multiplication . 65 2.4.3 McLaughlin’s Algorithm . 68 2.4.4 SpecialModuli ...................... 70 2.5 Modular Division and Inversion . 70 2.5.1 Several Inversions at Once . 72 2.6 ModularExponentiation . 74 2.6.1 Binary Exponentiation . 75 2.6.2 Exponentiation With a Larger Base . 76 2.6.3 Sliding Window and Redundant Representation . 77 2.7 Chinese Remainder Theorem . 79 Modern Computer Arithmetic v 2.8 Exercises.............................. 81 2.9 NotesandReferences . 83 3 Floating-Point Arithmetic 85 3.1 Representation .......................... 85 3.1.1 RadixChoice ....................... 87 3.1.2 ExponentRange ..................... 87 3.1.3 SpecialValues. 88 3.1.4 SubnormalNumbers . 88 3.1.5 Encoding ......................... 90 3.1.6 Precision: Local, Global, Operation, Operand . 91 3.1.7 LinktoIntegers. 92 3.1.8 Ziv’s Algorithm and Error Analysis . 93 3.1.9 Rounding ......................... 94 3.1.10 Strategies ......................... 98 3.2 Addition,Subtraction,Comparison . 99 3.2.1 Floating-Point Addition . 99 3.2.2 Floating-Point Subtraction . 101 3.3 Multiplication . .103 3.3.1 Integer Multiplication via Complex FFT . 107 3.3.2 TheMiddleProduct . .109 3.4 Reciprocal and Division . 110 3.4.1 Reciprocal.........................111 3.4.2 Division ..........................115 3.5 SquareRoot............................120 3.5.1 Reciprocal Square Root . 121 3.6 Conversion.............................124 3.6.1 Floating-Point Output . 124 3.6.2 Floating-Point Input . 127 3.7 Exercises..............................128 3.8 NotesandReferences . .130 4 Elementary and Special Function Evaluation 135 4.1 Introduction............................135 4.2 Newton’sMethod .........................136 4.2.1 Newton’s Method for Inverse Roots . 138 4.2.2 Newton’s Method for Reciprocals . 138 4.2.3 Newton’s Method for (Reciprocal) Square Roots . 139 vi Modern Computer Arithmetic, version 0.5.2 of July 31, 2010 4.2.4 Newton’s Method for Formal Power Series . 140 4.2.5 Newton’s Method for Functional Inverses . 141 4.2.6 Higher Order Newton-like Methods . 142 4.3 ArgumentReduction . .143 4.3.1 Repeated Use of a Doubling Formula . 145 4.3.2 Loss of Precision . 145 4.3.3 GuardDigits .......................146 4.3.4 Doubling versus Tripling . 147 4.4 PowerSeries............................148 4.4.1 Direct Power Series Evaluation . 152 4.4.2 Power Series With Argument Reduction . 152 4.4.3 Rectangular Series Splitting . 153 4.5 AsymptoticExpansions. .157 4.6 Continued Fractions . 163 4.7 Recurrence Relations . 165 4.7.1 Evaluation of Bessel Functions . 166 4.7.2 Evaluation of Bernoulli and Tangent numbers . 167 4.8 Arithmetic-GeometricMean . .171 4.8.1 Elliptic Integrals . 172 4.8.2 First AGM Algorithm for the Logarithm . 173 4.8.3 ThetaFunctions. .174 4.8.4 Second AGM Algorithm for the Logarithm . 175 4.8.5 TheComplexAGM. .177 4.9 BinarySplitting. .178 4.9.1 A Binary Splitting Algorithm for sin, cos . 180 4.9.2 The Bit-Burst Algorithm . 181 4.10 Contour Integration . 184 4.11Exercises..............................185 4.12 Notes and References . 194 5 Implementations and Pointers 201 5.1 SoftwareTools...........................201 5.1.1 CLN ............................201 5.1.2 GNUMP(GMP) .....................202 5.1.3 MPFQ...........................203 5.1.4 MPFR...........................203 5.1.5 Other Multiple-Precision Packages . 203 5.1.6 Computational Algebra Packages . 204 Modern Computer Arithmetic vii 5.2 MailingLists ...........................206 5.2.1 The BNIS Mailing List . 206 5.2.2 TheGMPLists ......................206 5.2.3 TheMPFRList......................206 5.3 On-lineDocuments . .206 Bibliography 209 Index 230 Summary of Complexities 247 Preface This is a book about algorithms for performing arithmetic, and their imple- mentation on modern computers. We are concerned with software more than hardware — we do not cover computer architecture or the design of computer hardware since good books are already available on these topics. Instead we focus on algorithms for efficiently performing arithmetic operations such as addition, multiplication and division, and their connections to topics such as modular arithmetic, greatest common divisors, the Fast Fourier Transform (FFT), and the computation of special functions. The algorithms that we present are mainly intended for arbitrary-precision arithmetic. That is, they are not limited by the computer wordsize of 32 or 64 bits, only by the memory and time available for the computation. We consider both integer and real (floating-point) computations. The book is divided into four main chapters, plus one short chapter (es- sentially an appendix). Chapter 1 covers integer arithmetic. This has, of course, been considered in many other books and papers. However, there has been much recent progress, inspired in part by the application to public key cryptography, so most of the published books are now partly out of date or incomplete. Our aim is to present the latest developments in a concise manner. At the same time, we provide a self-contained introduction for the reader who is not an expert in the field. Chapter 2 is concerned with modular arithmetic and the FFT, and their applications to computer arithmetic. We consider different number represen- tations, fast algorithms for multiplication, division and exponentiation, and the use of the Chinese Remainder Theorem (CRT). Chapter 3 covers floating-point arithmetic. Our concern is with high- precision floating-point arithmetic, implemented in software if the precision provided by the hardware (typically IEEE standard 53-bit significand) is in- adequate. The algorithms described in this chapter focus on correct rounding, extending the IEEE standard to arbitrary precision. x Modern Computer Arithmetic, version 0.5.2 of July 31, 2010 Chapter 4 deals with the computation, to arbitrary precision, of functions such as sqrt, exp, ln, sin, cos, and more generally functions defined by power series or continued fractions. Of course, the computation of special functions is a huge topic so we have had to be selective. In particular, we have con- centrated on methods that are efficient and suitable for arbitrary-precision computations. The last chapter contains pointers to implementations, useful web sites, mailing lists, and so on. Finally, at the end there is a one-page Summary of Complexities which should be a useful aide-m´emoire. The chapters are fairly self-contained, so it is possible to read them out of order. For example, Chapter 4 could be read before Chapters 1–3, and Chapter 5 can be consulted at any time. Some topics, such as Newton’s method, appear in different guises in several chapters. Cross-references are given where appropriate. For details that are omitted we give pointers in the Notes and References sections of each chapter, as well as in the bibliography. We have tried, as far as possible, to keep the main text uncluttered by footnotes and references, so most references are given in the Notes and References sections.
Recommended publications
  • Nominations for President
    ISSN 0002-9920 (print) ISSN 1088-9477 (online) of the American Mathematical Society September 2013 Volume 60, Number 8 The Calculus Concept Inventory— Measurement of the Effect of Teaching Methodology in Mathematics page 1018 DML-CZ: The Experience of a Medium- Sized Digital Mathematics Library page 1028 Fingerprint Databases for Theorems page 1034 A History of the Arf-Kervaire Invariant Problem page 1040 About the cover: 63 years since ENIAC broke the ice (see page 1113) Solve the differential equation. Solve the differential equation. t ln t dr + r = 7tet dt t ln t dr + r = 7tet dt 7et + C r = 7et + C ln t ✓r = ln t ✓ WHO HAS THE #1 HOMEWORK SYSTEM FOR CALCULUS? THE ANSWER IS IN THE QUESTIONS. When it comes to online calculus, you need a solution that can grade the toughest open-ended questions. And for that there is one answer: WebAssign. WebAssign’s patent pending grading engine can recognize multiple correct answers to the same complex question. Competitive systems, on the other hand, are forced to use multiple choice answers because, well they have no choice. And speaking of choice, only WebAssign supports every major textbook from every major publisher. With new interactive tutorials and videos offered to every student, it’s not hard to see why WebAssign is the perfect answer to your online homework needs. It’s all part of the WebAssign commitment to excellence in education. Learn all about it now at webassign.net/math. 800.955.8275 webassign.net/math WA Calculus Question ad Notices.indd 1 11/29/12 1:06 PM Notices 1051 of the American Mathematical Society September 2013 Communications 1048 WHAT IS…the p-adic Mandelbrot Set? Joseph H.
    [Show full text]
  • The Vile, Dopy, Evil and Odious Game Players
    The vile, dopy, evil and odious game players Aviezri S. Fraenkel¤ Department of Computer Science and Applied Mathematics Weizmann Institute of Science Rehovot 76100, Israel February 7, 2010 Wil: We have worked and published jointly, for example on graph focality. Now that one of us is already an octogenarian and the other is only a decade away, let's have some fun; let's play a game. Gert: I'm game. Wil: In the Fall 2009 issue of the MSRI gazette Emissary, Elwyn Berlekamp and Joe Buhler proposed the following puzzle: \Nathan and Peter are playing a game. Nathan always goes ¯rst. The players take turns changing a positive integer to a smaller one and then passing the smaller number back to their op- ponent. On each move, a player may either subtract one from the integer or halve it, rounding down if necessary. Thus, from 28 the legal moves are to 27 or to 14; from 27, the legal moves are to 26 or to 13. The game ends when the integer reaches 0. The player who makes the last move wins. For example, if the starting integer is 15, a legal sequence of moves might be to 7, then 6, then 3, then 2, then 1, and then to 0. (In this sample game one of the players could have played better!) Assuming both Nathan and Peter play according to the best possible strategy, who will win if the starting integer is 1000? 2000?" Let's dub it the Mark game, since it's due to Mark Krusemeyer according to Berlekamp and Buhler.
    [Show full text]
  • Version 0.5.1 of 5 March 2010
    Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Version 0.5.1 of 5 March 2010 iii Copyright c 2003-2010 Richard P. Brent and Paul Zimmermann ° This electronic version is distributed under the terms and conditions of the Creative Commons license “Attribution-Noncommercial-No Derivative Works 3.0”. You are free to copy, distribute and transmit this book under the following conditions: Attribution. You must attribute the work in the manner specified by the • author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial. You may not use this work for commercial purposes. • No Derivative Works. You may not alter, transform, or build upon this • work. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the web page below. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author’s moral rights. For more information about the license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ Contents Preface page ix Acknowledgements xi Notation xiii 1 Integer Arithmetic 1 1.1 Representation and Notations 1 1.2 Addition and Subtraction 2 1.3 Multiplication 3 1.3.1 Naive Multiplication 4 1.3.2 Karatsuba’s Algorithm 5 1.3.3 Toom-Cook Multiplication 6 1.3.4 Use of the Fast Fourier Transform (FFT) 8 1.3.5 Unbalanced Multiplication 8 1.3.6 Squaring 11 1.3.7 Multiplication by a Constant 13 1.4 Division 14 1.4.1 Naive
    [Show full text]
  • Probability and Random Processes ECS 315
    Probability and Random Processes ECS 315 Asst. Prof. Dr. Prapun Suksompong [email protected] 4 Combinatorics Office Hours: BKD, 6th floor of Sirindhralai building Tuesday 9:00-10:00 Wednesday 14:20-15:20 1 Thursday 9:00-10:00 Supplementary References Mathematics of Choice How to count without counting By Ivan Niven permutations, combinations, binomial coefficients, the inclusion-exclusion principle, combinatorial probability, partitions of numbers, generating polynomials, the pigeonhole principle, and much more A Course in Combinatorics By J. H. van Lint and R. M. Wilson 2 Cartesian product The Cartesian product A × B is the set of all ordered pairs where and . Named after René Descartes His best known philosophical statement is “Cogito ergo sum” (French: Je pense, donc je suis; I think, therefore I am) 3 [http://mathemagicalworld.weebly.com/rene-descartes.html] Heads, Bodies and Legs flip-book 4 Heads, Bodies and Legs flip-book (2) 5 Interactive flipbook: Miximal 6 [http://www.fastcodesign.com/3028287/miximal-is-the-new-worlds-cutest-ipad-app] One Hundred Thousand Billion Poems 7 [https://www.youtube.com/watch?v=2NhFoSFNQMQ] One Hundred Thousand Billion Poems Cent mille milliards de poèmes 8 Pokemon Go: Designing how your avatar looks 9 How many chess games are possible? 10 [https://www.youtube.com/watch?v=Km024eldY1A] An Estimate: The Shannon Number 11 [https://www.youtube.com/watch?v=Km024eldY1A] An Estimate: The Shannon Number 12 [https://www.youtube.com/watch?v=Km024eldY1A] An Estimate: The Shannon Number 13 [https://www.youtube.com/watch?v=Km024eldY1A] The Shannon Number: Just an Estimate 14 [https://www.youtube.com/watch?v=Km024eldY1A] Example: Sock It Two Me 15 [Greenes, 1977] Example: Sock It Two Me Jack is so busy that he's always throwing his socks into his top drawer without pairing them.
    [Show full text]
  • Download This PDF File
    International Journal of Electrical and Computer Engineering (IJECE) Vol. 10, No. 2, April 2020, pp. 1469~1476 ISSN: 2088-8708, DOI: 10.11591/ijece.v10i2.pp1469-1476 1469 The new integer factorization algorithm based on fermat’s factorization algorithm and euler’s theorem Kritsanapong Somsuk Department of Computer and Communication Engineering, Faculty of Technology, Udon Thani Rajabhat University, Udon Thani, 41000, Thailand Article Info ABSTRACT Article history: Although, Integer Factorization is one of the hard problems to break RSA, many factoring techniques are still developed. Fermat’s Factorization Received Apr 7, 2019 Algorithm (FFA) which has very high performance when prime factors are Revised Oct 7, 2019 close to each other is a type of integer factorization algorithms. In fact, there Accepted Oct 20, 2019 are two ways to implement FFA. The first is called FFA-1, it is a process to find the integer from square root computing. Because this operation takes high computation cost, it consumes high computation time to find the result. Keywords: The other method is called FFA-2 which is the different technique to find prime factors. Although the computation loops are quite large, there is no Computation loops square root computing included into the computation. In this paper, Euler’s theorem the new efficient factorization algorithm is introduced. Euler’s theorem is Fermat’s factorization chosen to apply with FFA to find the addition result between two prime Integer factorization factors. The advantage of the proposed method is that almost of square root Prime factors operations are left out from the computation while loops are not increased, they are equal to the first method.
    [Show full text]
  • What Comes Next?
    NEWSFOCUS For PRESIDENT What Comes Next? arrangement of toothpicks, in which a new batch is added at each stage, centered on and One of mathematicians’ most beloved at right angles to the exposed tips of the pre- e e e e e ic c ic o i ic ic Web sites is getting ready for a makeover. vious batch (see figure). The picture that (Rank candidates o o o o h h h h in order of choice) h C C C C C The Online Encyclopedia of Integer emerges displays surprising fractal growth. t d d h h s n r t t 1 2 3 4 5 Sequences, established by Neil Sloane at “It’s got beautiful structure,” Sloane says. He Candidate A 1 2 3 4 5 AT&T Labs Research in 1996 and run and his AT&T colleague David Applegate largely as a one-man shop, is poised to go have written a paper on the sequence’s math- Candidate B 1 2 3 4 5 “wiki,” with 50 associate editors taking over ematical properties, and Applegate has con- Candidate C 1 2 3 4 5 much of the workload. tributed a movie of its geometric growth, The OEIS, or simply “Sloane” as it’s linked to its entry in the OEIS. Candidate D 1 2 3 4 5 known to sequence fanatics, is a database of Sloane set up the OEIS Foundation last Candidate E 1 2 3 4 5 nearly 200,000 lists of numbers—a mathe- year and transferred intellectual-property matical equivalent to the FBI’s voluminous rights to the nonprofit organization.
    [Show full text]
  • Modern Computer Arithmetic
    Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Version 0.3 Copyright c 2003-2009 Richard P. Brent and Paul Zimmermann This electronic version is distributed under the terms and conditions of the Creative Commons license “Attribution-Noncommercial-No Derivative Works 3.0”. You are free to copy, distribute and transmit this book under the following conditions: Attribution. You must attribute the work in the manner specified • by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial. You may not use this work for commercial purposes. • No Derivative Works. You may not alter, transform, or build upon • this work. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the web page below. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author’s moral rights. For more information about the license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ Preface This is a book about algorithms for performing arithmetic, and their imple- mentation on modern computers. We are concerned with software more than hardware — we do not cover computer architecture or the design of computer hardware since good books are already available on these topics. Instead we focus on algorithms for efficiently performing arithmetic operations such as addition, multiplication and division, and their connections to topics such as modular arithmetic, greatest common divisors, the Fast Fourier Transform (FFT), and the computation of special functions.
    [Show full text]
  • CABINET       48 the FAX NUMBERS of the BEAST, and OTHER MATHEMATICAL SPORTS: an INTERVIEW with NEIL SLOANE Margaret Wertheim
    CABINET c US $12 CANADA UK £7US $12 $12 ISSUE 57 A QUARTERLY OF ART AND CULTURE CATASTROPHE 48 THE FAX NUMBERS OF THE BEAST, AND OTHER MATHEMATICAL SPORTS: AN INTERVIEW WITH NEIL SLOANE Margaret Wertheim Everyone knows a few integer sequences: the even networks, which are like artificial brains with com- numbers, the odd numbers, the primes. And we’ve puter simulations of neurons. When these “neurons” all heard about the Fibonacci sequence (1, 1, 2, 3, 5, fire, they trigger other neurons, which in turn trig- 8, 13…), where each term is computed by adding ger others—you have to have a certain amount of together the two previous terms. In 1964, mathema- activity before a neuron gets triggered. And the tician Neil Sloane, then working on a PhD at Cornell question was, “If you have a network of these con- University, began to write down interesting sequences figured in a particular way, and you start by making of numbers on file cards. His research on neural net- one fire, will the activity continue to propagate works generated quite a few; he pressed his friends through the network? Will it die out, or will it satu- for examples and consulted mathematics textbooks. rate the network?” I was looking at models of this, As the horde of sequences grew, he transferred them and I could count the number of cells firing at any to punched cards, then magnetic tape, and eventu- given time, and I would come up with a sequence of ally to the web, where today, more than half a century numbers.
    [Show full text]
  • Commencement Program, 2019
    263 rd COMMENCEMENT MAY 20, 2019 20, MAY R D COMMENCEME 263 NT CLA S S O F 2 019 M A Y 20, 20 1 9 CLASS OF 2019 KEEPING FRANKLIN’S PROMISE In the words of one elegiac tribute, “Great men have two lives: one which occurs while they work on this earth; a second which begins at the day of their death and continues as long as their ideas and conceptions remain powerful.” These words befit the great Benjamin Franklin, whose inventions, innovations, ideas, writings, and public works continue to shape our thinking and renew the Republic he helped to create and the institutions he founded, including the University of Pennsylvania. Nowhere does Franklin feel more contemporary, more revolutionary, and more alive than at the University of Pennsylvania. His startling vision of a secular, nonsectarian Academy that would foster an “Inclination join’d with an Ability to serve Mankind, one’s Country, Friends and Family” has never ceased to challenge Penn to redefine the scope and mission of the modern American university. When pursued vigorously and simultaneously, the two missions – developing the inclination to do good and the ability to do well – merge to help form a more perfect university that educates more capable citizens for our democracy. Penn has embodied and advanced Franklin’s revolutionary vision for 279 years. Throughout its history, Penn has extended the frontiers of higher learning and research to produce graduates and scholars whose work has enriched the nation and all of humanity. The modern liberal arts curriculum as we know it can trace its roots to Franklin’s innovation to have Penn students study international commerce and foreign languages.
    [Show full text]
  • 40 Years with Sloane's Integer Sequences
    40 Years with Sloane’s Integer Sequences Jeffrey Shallit School of Computer Science, University of Waterloo Waterloo, Ontario N2L 3G1, Canada [email protected] http://www.cs.uwaterloo.ca/~shallit 1/1 My Christmas Present in 1974 2/1 Sloane’s First Letter to Me 3/1 Modified Engel expansions Kalpazidou, Knopfmacher, and Knopfmacher (1990) studied expansions of the form 1 1 1 1 1 1 α = a0 + + a1 − a1 + 1 · a2 a1 + 1 · a2 + 1 · a3 −··· for real numbers α, where the ai are non-negative integers with ai positive for i 1. ≥ This expansion is essentially unique provided ai ai . +1 ≥ I tried expanding α = 2/5 and found doubly-exponential growth (a0, a1,...)=(0, 2, 3, 7, 13, 97, 193, 18817, 37633, 708158977,...). Although this particular sequence was not in the OEIS at the time, its even-indexed subsequence (2, 7, 97, 18817, 708158977,...) certainly was (as A002812) and led to the discovery that ... 4/1 Modified Engel expansions 1 2i 2i a i = (2 + √3) + (2 √3) 2 +1 2 − and 2i 2i a i = (2+ √3) + (2 √3) 1. 2 +2 − − From this it was easy to deduce the general form of the expansion for 2/(2r + 1). Compare Aho and Sloane’s 1973 paper, “Some Doubly Exponential Sequences”. Open Problem: find a simple closed form for the expansion of 3/7. 5/1 Some confusing quotients Suppose we set c = a, c = b, and for n 2 define cn to be the 0 1 ≥ smallest integer such that c c n > n−1 .
    [Show full text]
  • Modern Computer Arithmetic (Version 0.5. 1)
    Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Version 0.5.1 arXiv:1004.4710v1 [cs.DS] 27 Apr 2010 Copyright c 2003-2010 Richard P. Brent and Paul Zimmermann This electronic version is distributed under the terms and conditions of the Creative Commons license “Attribution-Noncommercial-No Derivative Works 3.0”. You are free to copy, distribute and transmit this book under the following conditions: Attribution. You must attribute the work in the manner specified • by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial. You may not use this work for commercial purposes. • No Derivative Works. You may not alter, transform, or build upon • this work. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the web page below. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author’s moral rights. For more information about the license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ Contents Contents iii Preface ix Acknowledgements xi Notation xiii 1 Integer Arithmetic 1 1.1 RepresentationandNotations . 1 1.2 AdditionandSubtraction . .. 2 1.3 Multiplication . 3 1.3.1 Naive Multiplication . 4 1.3.2 Karatsuba’s Algorithm . 5 1.3.3 Toom-Cook Multiplication . 7 1.3.4 UseoftheFastFourierTransform(FFT) . 8 1.3.5 Unbalanced Multiplication . 9 1.3.6 Squaring.......................... 12 1.3.7 Multiplication by a Constant .
    [Show full text]
  • User's Guide to PARI / GP
    User’s Guide to PARI / GP C. Batut, K. Belabas, D. Bernardi, H. Cohen, M. Olivier Laboratoire A2X, U.M.R. 9936 du C.N.R.S. Universit´eBordeaux I, 351 Cours de la Lib´eration 33405 TALENCE Cedex, FRANCE e-mail: [email protected] Home Page: http://pari.math.u-bordeaux.fr/ Primary ftp site: ftp://pari.math.u-bordeaux.fr/pub/pari/ last updated 11 December 2003 for version 2.2.7 Copyright c 2000–2003 The PARI Group ° Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions, or translations, of this manual under the conditions for verbatim copying, provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. PARI/GP is Copyright c 2000–2003 The PARI Group ° PARI/GP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY WHATSOEVER. Table of Contents Chapter1: OverviewofthePARIsystem . ...........5 1.1Introduction ..................................... ....... 5 1.2ThePARItypes..................................... ...... 6 1.3Operationsandfunctions. ...........9 Chapter 2: Specific Use of the GP Calculator . ............ 13 2.1Defaultsandoutputformats . ............14 2.2Simplemetacommands. ........21 2.3InputformatsforthePARItypes . .............25 2.4GPoperators ....................................... .28 2.5ThegeneralGPinputline . ........31 2.6 The GP/PARI programming language . .............32 2.7Errorsanderrorrecovery. .........42 2.8 Interfacing GP with other languages .
    [Show full text]