Modern Computer Arithmetic (Version 0.5. 1)

Total Page:16

File Type:pdf, Size:1020Kb

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 . 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.1 of April 28, 2010 1.5 Roots ............................... 27 1.5.1 SquareRoot........................ 27 1.5.2 k-thRoot ......................... 29 1.5.3 ExactRoot ........................ 30 1.6 GreatestCommonDivisor . 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 Quadratic Algorithms . 41 1.7.2 Subquadratic Algorithms . 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’sForm . 52 2.1.3 ResidueNumberSystems . 53 2.1.4 MSBvsLSBAlgorithms . 53 2.1.5 Link with Polynomials . 53 2.2 Modular Addition and Subtraction . 54 2.3 TheFourierTransform . 54 2.3.1 TheoreticalSetting . 55 2.3.2 TheFastFourierTransform . 56 2.3.3 The Sch¨onhage-Strassen Algorithm . 60 2.4 Modular Multiplication . 63 2.4.1 Barrett’s Algorithm . 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 SeveralInversionsatOnce . 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 ChineseRemainderTheorem. 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 ReciprocalSquareRoot . .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’sMethodforInverse 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.1 of April 28, 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 LossofPrecision .....................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 ContinuedFractions . .163 4.7 RecurrenceRelations . .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 Binary Splitting . 178 4.9.1 A Binary Splitting Algorithm for sin, cos . 180 4.9.2 The Bit-Burst Algorithm . 181 4.10 ContourIntegration. .184 4.11Exercises..............................185 4.12 NotesandReferences . .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 ComputationalAlgebraPackages . 204 Modern Computer Arithmetic vii 5.2 Mailing Lists . 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.1 of April 28, 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. The book is intended for anyone interested in the design and implemen- tation of efficient algorithms for computer arithmetic, and more generally efficient numerical algorithms.
Recommended publications
  • Quadratic Reciprocity and Computing Modular Square Roots.Pdf
    12 Quadratic reciprocity and computing modular square roots In §2.8, we initiated an investigation of quadratic residues. This chapter continues this investigation. Recall that an integer a is called a quadratic residue modulo a positive integer n if gcd(a, n) = 1 and a ≡ b2 (mod n) for some integer b. First, we derive the famous law of quadratic reciprocity. This law, while his- torically important for reasons of pure mathematical interest, also has important computational applications, including a fast algorithm for testing if an integer is a quadratic residue modulo a prime. Second, we investigate the problem of computing modular square roots: given a quadratic residue a modulo n, compute an integer b such that a ≡ b2 (mod n). As we will see, there are efficient probabilistic algorithms for this problem when n is prime, and more generally, when the factorization of n into primes is known. 12.1 The Legendre symbol For an odd prime p and an integer a with gcd(a, p) = 1, the Legendre symbol (a j p) is defined to be 1 if a is a quadratic residue modulo p, and −1 otherwise. For completeness, one defines (a j p) = 0 if p j a. The following theorem summarizes the essential properties of the Legendre symbol. Theorem 12.1. Let p be an odd prime, and let a, b 2 Z. Then we have: (i) (a j p) ≡ a(p−1)=2 (mod p); in particular, (−1 j p) = (−1)(p−1)=2; (ii) (a j p)(b j p) = (ab j p); (iii) a ≡ b (mod p) implies (a j p) = (b j p); 2 (iv) (2 j p) = (−1)(p −1)=8; p−1 q−1 (v) if q is an odd prime, then (p j q) = (−1) 2 2 (q j p).
    [Show full text]
  • 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]
  • Radix-8 Design Alternatives of Fast Two Operands Interleaved
    International Journal of Advanced Network, Monitoring and Controls Volume 04, No.02, 2019 Radix-8 Design Alternatives of Fast Two Operands Interleaved Multiplication with Enhanced Architecture With FPGA implementation & synthesize of 64-bit Wallace Tree CSA based Radix-8 Booth Multiplier Mohammad M. Asad Qasem Abu Al-Haija King Faisal University, Department of Electrical Department of Computer Information and Systems Engineering, Ahsa 31982, Saudi Arabia Engineering e-mail: [email protected] Tennessee State University, Nashville, USA e-mail: [email protected] Ibrahim Marouf King Faisal University, Department of Electrical Engineering, Ahsa 31982, Saudi Arabia e-mail: [email protected] Abstract—In this paper, we proposed different comparable researches to propose different solutions to ensure the reconfigurable hardware implementations for the radix-8 fast safe access and store of private and sensitive data by two operands multiplier coprocessor using Karatsuba method employing different cryptographic algorithms and Booth recording method by employing carry save (CSA) and kogge stone adders (KSA) on Wallace tree organization. especially the public key algorithms [1] which proved The proposed designs utilized robust security resistance against most of the attacks family with target chip device along and security halls. Public key cryptography is with simulation package. Also, the proposed significantly based on the use of number theory and designs were synthesized and benchmarked in terms of the digital arithmetic algorithms. maximum operational frequency, the total path delay, the total design area and the total thermal power dissipation. The Indeed, wide range of public key cryptographic experimental results revealed that the best multiplication systems were developed and embedded using hardware architecture was belonging to Wallace Tree CSA based Radix- modules due to its better performance and security.
    [Show full text]
  • Appendices A. Quadratic Reciprocity Via Gauss Sums
    1 Appendices We collect some results that might be covered in a first course in algebraic number theory. A. Quadratic Reciprocity Via Gauss Sums A1. Introduction In this appendix, p is an odd prime unless otherwise specified. A quadratic equation 2 modulo p looks like ax + bx + c =0inFp. Multiplying by 4a, we have 2 2ax + b ≡ b2 − 4ac mod p Thus in studying quadratic equations mod p, it suffices to consider equations of the form x2 ≡ a mod p. If p|a we have the uninteresting equation x2 ≡ 0, hence x ≡ 0, mod p. Thus assume that p does not divide a. A2. Definition The Legendre symbol a χ(a)= p is given by 1ifa(p−1)/2 ≡ 1modp χ(a)= −1ifa(p−1)/2 ≡−1modp. If b = a(p−1)/2 then b2 = ap−1 ≡ 1modp,sob ≡±1modp and χ is well-defined. Thus χ(a) ≡ a(p−1)/2 mod p. A3. Theorem a The Legendre symbol ( p ) is 1 if and only if a is a quadratic residue (from now on abbre- viated QR) mod p. Proof.Ifa ≡ x2 mod p then a(p−1)/2 ≡ xp−1 ≡ 1modp. (Note that if p divides x then p divides a, a contradiction.) Conversely, suppose a(p−1)/2 ≡ 1modp.Ifg is a primitive root mod p, then a ≡ gr mod p for some r. Therefore a(p−1)/2 ≡ gr(p−1)/2 ≡ 1modp, so p − 1 divides r(p − 1)/2, hence r/2 is an integer. But then (gr/2)2 = gr ≡ a mod p, and a isaQRmodp.
    [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]
  • Primality Testing for Beginners
    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.
    [Show full text]
  • Dividing Whole Numbers
    Dividing Whole Numbers INTRODUCTION Consider the following situations: 1. Edgar brought home 72 donut holes for the 9 children at his daughter’s slumber party. How many will each child receive if the donut holes are divided equally among all nine? 2. Three friends, Gloria, Jan, and Mie-Yun won a small lottery prize of $1,450. If they split it equally among all three, how much will each get? 3. Shawntee just purchased a used car. She has agreed to pay a total of $6,200 over a 36- month period. What will her monthly payments be? 4. 195 people are planning to attend an awards banquet. Ruben is in charge of the table rental. If each table seats 8, how many tables are needed so that everyone has a seat? Each of these problems can be answered using division. As you’ll recall from Section 1.2, the result of division is called the quotient. Here are the parts of a division problem: Standard form: dividend ÷ divisor = quotient Long division form: dividend Fraction form: divisor = quotient We use these words—dividend, divisor, and quotient—throughout this section, so it’s important that you become familiar with them. You’ll often see this little diagram as a continual reminder of their proper placement. Here is how a division problem is read: In the standard form: 15 ÷ 5 is read “15 divided by 5.” In the long division form: 5 15 is read “5 divided into 15.” 15 In the fraction form: 5 is read “15 divided by 5.” Dividing Whole Numbers page 1 Example 1: In this division problem, identify the dividend, divisor, and quotient.
    [Show full text]
  • Unit Name: Powers and Multiples of 10
    Dear Parents, We will begin our next unit of study in math soon. The information below will serve as an overview of the unit as you work to support your child at home. If you have any questions, please feel free to contact me. I appreciate your on-going support. Sincerely, Your Child’s Teacher Unit Name: Powers and Multiples of 10 Common Core State Standards: 5.NBT.1 Recognize that in a multi-digit number, a digit in one place represents 10 times as much as it represents in the place to its right and 1/10 of what it represents in the place to its left. 5.NBT.2 Explain patterns in the number of zeros of the product when multiplying a number by powers of 10, and explain patterns in the placement of the decimal point when a decimal is multiplied or divided by a power of 10. Use whole-number exponents to denote powers of 10. Essential Vocabulary: place value decimal number powers of 10 expanded form Unit Overview: Students extend their understanding of the base-ten system by looking at the relationship among place values. Students are required to reason about the magnitude of numbers. Students should realize that the tens place is ten times as much as the ones place, and the ones place is 1/10th the size of the tens place. New at Grade 5 is the use of whole number exponents to represent powers of 10. Students should understand why multiplying by a power of 10 shifts the digits of a whole number that many places to the left.
    [Show full text]
  • A Family of Sequences Generating Smith Numbers
    1 2 Journal of Integer Sequences, Vol. 16 (2013), 3 Article 13.4.6 47 6 23 11 A Family of Sequences Generating Smith Numbers Amin Witno Department of Basic Sciences Philadelphia University 19392 Jordan [email protected] Abstract Infinitely many Smith numbers can be constructed using sequences which involve repunits. We provide an alternate method of construction by introducing a generaliza- tion of repunits, resulting in new Smith numbers whose decimal digits are composed of zeros and nines. 1 Introduction We work with natural numbers in their decimal representation. Let S(N) denote the “digital sum” (the sum of the base-10 digits) of the number N and let Sp(N) denote the sum of all the digital sums of the prime factors of N, counting multiplicity. For instance, S(2013) = 2+0+1+3 = 6 and, since 2013 = 3 × 11 × 61, we have Sp(2013) = 3+1+1+6+1 = 12. The quantity Sp(N) does not seem to have a name in the literature, so let us just call Sp(N) the p-digit sum of N. The natural number N is called a Smith number when N is composite and S(N)= Sp(N). For example, since 22 = 2 × 11, we have both S(22) = 4 and Sp(22) = 4. Hence, 22 is a Smith number—thus named by Wilansky [4] in 1982. Several different ways of constructing Smith numbers are already known. (See our 2010 article [5], for instance, which contains a brief historical account on the subject as well as a list of references.
    [Show full text]
  • Advanced Synthesis Cookbook
    Advanced Synthesis Cookbook Advanced Synthesis Cookbook 101 Innovation Drive San Jose, CA 95134 www.altera.com MNL-01017-6.0 Document last updated for Altera Complete Design Suite version: 11.0 Document publication date: July 2011 © 2011 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX are Reg. U.S. Pat. & Tm. Off. and/or trademarks of Altera Corporation in the U.S. and other countries. All other trademarks and service marks are the property of their respective holders as described at www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordance with Altera’s standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes no responsibility or liability arising out of the application or use of any information, product, or service described herein except as expressly agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products or services. Advanced Synthesis Cookbook July 2011 Altera Corporation Contents Chapter 1. Introduction Blocks and Techniques . 1–1 Simulating the Examples . 1–1 Using a C Compiler . 1–2 Chapter 2. Arithmetic Introduction . 2–1 Basic Addition . 2–2 Ternary Addition . 2–2 Grouping Ternary Adders . 2–3 Combinational Adders . 2–3 Double Addsub/ Basic Addsub . 2–3 Two’s Complement Arithmetic Review . 2–4 Traditional ADDSUB Unit . 2–4 Compressors (Carry Save Adders) . 2–5 Compressor Width 6:3 .
    [Show full text]
  • Obtaining More Karatsuba-Like Formulae Over the Binary Field
    1 Obtaining More Karatsuba-Like Formulae over the Binary Field Haining Fan, Ming Gu, Jiaguang Sun and Kwok-Yan Lam Abstract The aim of this paper is to find more Karatsuba-like formulae for a fixed set of moduli polynomials in GF (2)[x]. To this end, a theoretical framework is established. We first generalize the division algorithm, and then present a generalized definition of the remainder of integer division. Finally, a previously generalized Chinese remainder theorem is used to achieve our initial goal. As a by-product of the generalized remainder of integer division, we rediscover Montgomery’s N-residue and present a systematic interpretation of definitions of Montgomery’s multiplication and addition operations. Index Terms Karatsuba algorithm, polynomial multiplication, Chinese remainder theorem, Montgomery algo- rithm, finite field. I. INTRODUCTION Efficient GF (2n) multiplication operation is important in cryptosystems. The main advantage of subquadratic multipliers is that their low asymptotic space complexities make it possible to implement VLSI multipliers for large values of n. The Karatsuba algorithm, which was invented by Karatsuba in 1960 [1], provides a practical solution for subquadratic GF (2n) multipliers [2]. Because time and space complexities of these multipliers depend on low-degree Karatsuba-like formulae, much effort has been devoted to obtain Karatsuba-like formulae with low multiplication complexity. Using the Chinese remainder theorem (CRT), Lempel, Seroussi and Winograd obtained a quasi-linear upper bound of the multiplicative complexity of multiplying Haining Fan, Ming Gu, Jiaguang Sun and Kwok-Yan Lam are with the School of Software, Tsinghua University, Beijing, China. E-mails: {fhn, guming, sunjg, lamky}@tsinghua.edu.cn 2 two polynomials over finite fields [3].
    [Show full text]