A Binary Recursive Gcd Algorithm

Size: px
Start display at page:

Download "A Binary Recursive Gcd Algorithm"

Transcription

1 A Binary Recursive Gcd Algorithm Damien Stehlé and Paul Zimmermann LORIA/INRIA Lorraine, 615 rue du jardin otanique, BP 101, F-5460 Villers-lès-Nancy, France, Astract. The inary algorithm is a variant of the Euclidean algorithm that performs well in practice. We present a quasi-linear time recursive algorithm that computes the greatest common divisor of two integers y simulating a slightly modified version of the inary algorithm. The structure of our algorithm is very close to the one of the well-known Knuth-Schönhage fast gcd algorithm; although it does not improve on its O(M(n) log n) complexity, the description and the proof of correctness are significantly simpler in our case. This leads to a simplification of the implementation and to etter running times. 1 Introduction Gcd computation is a central task in computer algera, in particular when computing over rational numers or over modular integers. The well-known Euclidean algorithm solves this prolem in time quadratic in the size n of the inputs. This algorithm has een extensively studied and analyzed over the past decades. We refer to the very complete average complexity analysis of Vallée for a large family of gcd algorithms, see [10]. The first quasi-linear algorithm for the integer gcd was proposed y Knuth in 1970, see [4]: he showed how to calculate the gcd of two n-it integers in time O(n log 5 n log log n). The complexity of this algorithm was improved y Schönhage [6] to O(n log n log log n). A comprehensive description of the Knuth-Schönhage algorithm can e found in [1]. The correctness of this algorithm is quite hard to estalish, essentially ecause of the technical details around the so-called fix-up procedure, and a formal proof is y far out of reach. As an example, several mistakes can e noticed in the proof of [1] and can e found at yap/ook/errata.html. This fix-up procedure is a tedious case analysis and is quite difficult to implement. This usually makes the implementations of this algorithm uninteresting except for very large numers (of length significantly higher than 10 5 its). In this paper, we present a variant of the Knuth-Schönhage algorithm that does not have the fix-up procedure drawack. To achieve this, we introduce a new division (GB for Generalized Binary), which can e seen as a natural generalization of the inary division and which has some natural meaning over the -adic integers. It does not seem possile to use the inary division itself in a Knuth-Schönhage-like algorithm, ecause its definition is asymmetric: it eliminates least significant its ut it also considers most significant its to perform

2 comparisons. There is no such asymmetry in the GB division. The recursive GB Euclidean algorithm is much simpler to descrie and to prove than the Knuth- Schönhage algorithm, while admitting the same asymptotic complexity. This simplification of the description turns out to e an important advantage in practice: we implemented the algorithm in GNU MP, and it ran etween three and four times faster than the implementations of the Knuth-Schönhage algorithm in Magma and Mathematica. The rest of the paper is organized as follows. In we introduce the GB division and give some of its asic properties. In 3, we descrie precisely the new recursive algorithm. We prove its correctness in 4 and analyze its complexity in 5. Some implementation issues are discussed in 6. Notations: The standard notation O(.) is used. The complexity is measured in elementary operations on its. Unless specified explicitly, all the logarithms are taken in ase. If a is a non-zero integer, l(a) denotes the length of the inary representation of a, i.e. l(a) = log a + 1; ν (a) denotes the -adic valuation of a, i.e. the numer of consecutive zeroes in the least significant its of the inary representation of a; y definition, ν (0) =. r := a cmod denotes the centered remainder of a modulo, i.e. a = r mod and < r. We recall that M(n) = Θ(n log n log log n) is the asymptotic time required to multiply two n-it integers with Schönhage-Strassen multiplication [7]. We assume the reader is familiar with asic arithmetic operations such as fast multiplication and fast division ased on Newton s iteration. We refer to [11] for a complete description of these algorithms. The Generalized Binary Division In this section we first recall the inary algorithm. Then we define the generalized inary division GB division for short and give some asic properties aout it. Susection.4 explains how to compute modular inverses from the output of the Euclidean algorithm ased on the GB division..1 The Binary Euclidean Algorithm The inary division is ased on the following properties: gcd(a, ) = gcd(a, ), gcd(a + 1, ) = gcd(a + 1, ), and gcd(a + 1, + 1) = gcd( + 1, a ). It consists of eliminating the least significant it at each loop iteration. Fig. 1 is a description of the inary algorithm. The ehavior of this algorithm is very well understood (see [1] and the references there). Although it is still quadratic in the size of the inputs, there is a significant gain over the usual Euclidean algorithm, in particular ecause there is no need to compute any quotient.. The Generalized Binary Division In the case of the standard Euclidean division of a y with a >, one computes a quotient q such that when q is added to a, the otained remainder

3 Algorithm Binary-Gcd. Input: a, Z. Output: gcd(a, ). 1. If > a, return Binary-Gcd(, a).. If = 0, return a. 3. If a and are oth even then return Binary-Gcd(a/, /). 4. If a is even and is odd then return Binary-Gcd(a/, ). 5. If a is odd and is even then return Binary-Gcd(a, /). 6. Otherwise return Binary-Gcd(( a )/, ). Fig. 1. The inary Euclidean algorithm. is smaller than. Roughly speaking, left shifts of are sutracted from a as long as possile, that is to say until a has lost its l(a) l() most significant its (approximately). The GB division is the dual: in order to GB-divide a y with a >, where a := ν(a) is the -adic norm of a, one computes a quotient q such that when q is added to a, the otained remainder is smaller k k than for the -adic norm. Roughly speaking, right shifts of are sutracted from a as long as possile, that is to say until a has lost its ν () ν (a) least significant its. Lemma 1 (GB Division). Let a, e non-zero integers with ν (a) < ν (). Then there exists a unique pair of integers (q, r) such that: r = a + q, ν() ν(a) (1) q < ν() ν(a), () ν (r) > ν (). (3) The integers q and r are called respectively the GB quotient and the GB remainder of (a, ). We define GB(a, ) as the pair (q, r). a Proof. From (1), q = ( ) 1 mod ν() ν(a)+1. Since q is odd, the ν (a) ν () second condition is fulfilled and gives the uniqueness of q. As a consequence, r is uniquely defined y (1). Moreover, since r = a + q, we have ν () ν (a) r = 0 mod ν()+1, which gives condition (3). The GB division resemles Hensel s odd division, which was introduced y Hensel around A description can e found in [8]. For two integers a and with odd, it computes q and r in Z, such that: a = q + p r and r <, where p = l(a) l() is the difference etween the it lengths of a and. In other words, Hensel s odd division computes r := ( p a) mod, which may e found efficiently as shown in [5]. Besides, there is also some similarity with the PM algorithm of Brent and Kung []. When ν (a) = 0 and ν () = 1, i.e. a is

4 odd and = with odd, the GB division finds q = ±1 such that (a + q )/ is even, which is exactly the PM algorithm. Unlike the inary, Hensel and PM algorithms, the GB division considers only low order its of a and : there is no need comparing a and nor computing their it lengths. It can e seen as a natural operation when considering a and as -adic integers. We now give two algorithms to perform the GB division. The first one is the equivalent of the naive division algorithm, and is asymptotically slower than the second one, which is the equivalent of the fast division algorithm. For most of the input pairs (a, ), the Euclidean algorithm ased on the GB division performs almost all its divisions on pairs (c, d) for which ν (d) ν (c) is small. For this reason the first algorithm suffices in practice. Algorithm Elementary-GB. Input: Two integers a, satisfying ν (a) < ν () <. Output: (q, r) = GB(a, ). 1. q := 0, r := a.. While ν (r) ν () do 3. q := q ν (r) ν (a), 4. r := r ν (r) ν (). 5. q := q cmod ν () ν (a)+1, r := q + a. ν () ν (a) 6. Return (q, r). Fig.. Algorithm Elementary-GB. Lemma. The algorithm Elementary-GB of Fig. is correct and if the input (a, ) satisfies l(a), l() n, then it finishes in time O(n [ν () ν (a)]). It is also possile to compute GB(a, ) in quasi-linear time, in the case of Schönhage-Strassen multiplication, y using Hensel s lifting (which is the p-adic dual of Newton s iteration). Lemma 3. The algorithm Fast-GB of Fig. 3 is correct and with Schönhage- Strassen multiplication, if a and satisfy the conditions l(a), l() n and ν () ν (a) n, then it finishes in time O(M(n))..3 The GB Euclidean Algorithm A GB Euclidean algorithm can e derived very naturally from the definition of the GB division, see Fig. 4. Lemma 4. The GB Euclidean algorithm of Fig. 4 is correct, and if we use the algorithm Elementary-GB of Fig., then for any input (a, ) satisfying l(a), l() n, it finishes in time O(n ).

5 Algorithm Fast-GB. Input: Two integers a, satisfying ν (a) < ν () <. Output: (q, r) = GB(a, ). 1. A := a, B :=, n := ν ν (a) ν () ν (a) + 1. (). q := For i from 1 to log n do 4. q := q + q(1 Bq) mod i. 5. q := Aq cmod n. 6. r := a + q. n 1 7. Return (q, r). Fig. 3. Algorithm Fast-GB. Algorithm GB-gcd. Input: Two integers a, satisfying ν (a) < ν (). g Output: The odd part of the greatest common divisor g of a and. ν (g) a ν (a). 1. If = 0, return. (q, r) := GB(a, ). 3. Return GB-gcd (, r). Fig. 4. The GB Euclidean algorithm. Proof. Let r 0 = a, r 1 =, r,... e the sequence of remainders that appear in the execution of the algorithm. We first show that this sequence is finite and thus that the algorithm terminates. For any k 0, Eqs. (1) and () give r k+ r k+1 + r k, so that r k n+1 ( 1+ 5 ) k. Moreover, k divides r k, which gives k r k n+1 ( 1+ 5 and (1 log 1+ 5 )k n+1. Therefore there are O(n) remainders in the remainder sequence. Let t = O(n) e the length of the remainder sequence. Suppose that r t is the last non-zero remainder. From Lemma, we know that each of the calls to a GB-division involves a numer of it operations ounded y O(log r k [ν (r k+1 ) ν (r k )]) = O(n [ν (r k+1 ) ν (r k )]), so that the overall complexity is ounded y O(n ν (r t )). For the correctness, remark that the GB remainder r from a and satisfies r = a mod where = is the odd part of, thus gcd(a, ) = gcd(r, ). ν () Remark. For a practical implementation, one should remove factors of two in Algorithm GB-gcd. If one replaces the return value in Step 1 y a, and in Step 3 y ν(a) r GB-gcd(, ), the algorithm directly computes g = gcd(a, ). ν () ν () A etter ound on r k and thus on t is proved in 5.1. Nonetheless the present ound is sufficient to guarantee the quasi-linear time complexity of the recursive ) k

6 algorithm. The improved ound only decreases the multiplying constant of the asymptotic complexity. ( ) 0 For n 1 and q [ n + 1, n n 1] we define the matrix [q] n = n. q Let r 0, r 1 e two non-zero integers with 0 = ν (r 0 ) < ν (r 1 ), and r 0, r 1, r,... e their GB remainder sequence, and q 1, q,... e the corresponding quotients: r r i+1 = r i 1 + q i i for any i 1. Then the following relation holds ν (r i ) ν (r i 1 ) for any i 1: ( ) ri = 1 ( ) r i+1 [q r0 i] ν(ri) ni... [q 1 ] n1, r 1 where n j = ν (r j ) ν (r j 1 ) 1 for any j 1. In what follows, we use implicitly the following simple fact several times. Lemma 5. Let r 0, r 1 e two non-zero integers with 0 = ν (r 0 ) < ν (r 1 ), and r 0, r 1, r,... e their GB remainder sequence. Let d 0. Then there exists a unique i 0 such that ν (r i ) d < ν (r i+1 )..4 Computing Modular Inverses This susection is independent of the remainder of the paper ut is justified y the fact that computing modular inverses is a standard application of the Euclidean algorithm. Let a, e two non-zero integers with 0 = ν (a) < ν () and l(a), l() n. Suppose that we want to compute the inverse of modulo a, y using an extended version of the Euclidean algorithm ased on the GB division. The execution of the extended GB Euclidean algorithm gives two integers A and B such that Aa + B = α g, where α = O(n) and g = gcd(a, ). From such a relation, it is easy to check that g = 1. Suppose now that the inverse B of modulo a does exist. From the relation Aa + B = α, we know that: B = B mod a. α Therefore, in order to otain B, it is sufficient to compute the inverse of α modulo a. By using Hensel s lifting (like in the algorithm Fast-GB of Fig. 3), we otain the inverse of a modulo α. This gives x and y satisfying: xa+y α = 1. Clearly y is the inverse of α modulo a. Since multiplication, Hensel s lifting and division on numers of size O(n) can e performed in time O(M(n)) (see [11]), given two n-it integers a and, the additional cost to compute the inverse of modulo a given the output of an extended Euclidean algorithm ased on the GB division is O(M(n)). 3 The Recursive Algorithm We now descrie the recursive algorithm ased on the GB division. This description closely resemles the one of [1]. It uses two routines: the algorithm

7 Half-GB-gcd and the algorithm Fast-GB-gcd. Given two non-zero integers r 0 and r 1 with 0 = ν (r 0 ) < ν (r 1 ), the algorithm Half-GB-gcd outputs the GB remainders r i and r i+1 of the GB remainder sequence of (r 0, r 1 ) that satisfy ν (r i ) l(r 0 )/ < ν (r i+1 ). It also outputs the corresponding matrix (n1+...+ni) [q i ] ni... [q 1 ] n1. Then we descrie the algorithm Fast-GB-gcd, which, given two integers a and, outputs the gcd of a and y making successive calls to the algorithm Half-GB-gcd. The algorithm Half-GB-gcd works as follows: a quarter of the least significant its of a and are eliminated y doing a recursive call on the low l(a)/ of the its of a and. The crucial point is that the GB quotients computed for the truncated numers are exactly the same as the first GB quotients of a and. Therefore, y multiplying a and y the matrix otained recursively one gets two remainders (a, ) of the GB remainder sequence of (a, ). A single step of the GB Euclidean algorithm is performed on (a, ), which gives a new remainder pair (, r). Then there is a second recursive call on approximately l(a)/ of the least significant its of (, r). The size of the inputs of this second recursive call is similar to the one of the first recursive call. Finally, the corresponding remainders (c, d) of the GB remainder sequence of (a, ) are computed using the returned matrix R, and the output matrix R is calculated from R 1, R and the GB quotient of (a, ). Fig. 5 illustrates the execution of this algorithm. Note that in the description of the algorithm Half-GB-gcd in Fig. 6, a routine GB is used. This is a simple modification of the GB division: given a r ν () and as input with 0 = ν (a) < ν (), it outputs their GB quotient q, and if r is their GB remainder. The algorithm Fast-GB-gcd uses several times the algorithm Half-GB-gcd to decrease the lengths of the remainders quickly. The main advantage over the other quasi-linear time algorithms for the integer gcd is that if a matrix R is returned y a recursive call of the algorithm Half-GB-gcd, then it contains only correct quotients. There is no need to go ack in the GB remainder sequence in order to make the quotients correct, and thus no need to store the sequence of quotients. The underlying reason is that the remainders are shortened y the least significant its, and since the carries go in the direction of the most significant its, these two phenomena do not interfere. For that reason, the algorithm is as simple as the Knuth-Schönhage algorithm in the case of polynomials. 4 Correctness of the Recursive Algorithm In this section, we show that the algorithm Fast-GB-gcd of Fig. 7 is correct. We first give some results aout the GB division, and then we show the correctness of the algorithm Half-GB-gcd which clearly implies the correctness of the algorithm Fast-GB-gcd. 4.1 Some Properties of the GB Division The properties descried elow are very similar to the ones of the standard Euclidean division that make the Knuth-Schönhage algorithm possile. The first

8 n 3n/4 n/ n/4 0 a, Truncation a0,0 Recursive Call R1 c1,d1 x R1 a, GB Division,r Truncation 0,r0 Recursive Call R c,d x R c,d Fig. 5. The recursive structure of the algorithm Half-GB-gcd. result states that the ν () ν (a) + 1 last non-zero its of a and of suffice to compute the GB quotient of two integers a and. Lemma 6. Let a,, a and e such that a = a mod l and = mod l with l ν () + 1. Assume that 0 = ν (a) < ν (). Let (q, r) = GB(a, ) and (q, r ) = GB(a, ). Then q = q and r = r mod l ν(). Proof. By definition, q := a ( ) 1 ν cmod ν ()+1. Therefore, since l () ν ()+1, = ν () ν ( ) mod ν()+1, we have a = a mod ν()+1 and q = q. Moreover, r = a+q and r = a +q ν () ν ( ). Consequently r = r mod l ν(). This result can e seen as a continuity statement: two pairs of -adic integers (a, ) and (a, ) which are sufficiently close for the -adic norm (i.e. some least

9 Algorithm Half-GB-gcd. Input: a, satisfying 0 = ν (a) < ν (). Output: An integer j, an integer «matrix R and «two integers c and d with c a 0 = ν (c) < ν (d), such that = j R, and c = j c, d = j d d are the two consecutive remainders of the GB remainder sequence of (a, ) that satisfy ν (c ) l(a)/ < ν (d ). 1. k := l(a)/.. If ν () > k, then return 0, «1 0, a, k 1 := k/. 4. a := a 1 k1+1 + a 0, := 1 k with 0 a 0, 0 < k j 1, R 1, c 1, d 1 := Half-GB-gcd(a 0, 0). 6. «a := k 1+1 j 1 R 1 a1 1 «+ c1 d 1 «, j 0 := ν ( ). 7. If j 0 + j 1 > k, then return j 1, R 1, a,. 8. (q, r) := GB (a, ). 9. k := k (j 0 + j 1). 10. j 0 := 1 k+1 + 0, r := r 1 k+1 + r 0 with 0 0, r 0 < k j, R «, c, d := Half-GB-gcd( «0, r 0). c 1. := k +1 j R 1 c + d r 1 d «. 13. Return j 1 + j 0 + j, R [q] j0 R 1, c, d. Fig. 6. Algorithm Half-GB-gcd. significant its of a and a, and some of and are equal) have the same quotient and similar remainders (the closer the pairs, the closer the remainders). The second lemma extends this result to the GB continued fraction expansions: if (a, ) and (a, ) are sufficiently close, their first GB quotients are identical. We otain this result y applying the first one several times. Lemma 7. Let a,, a and such that a = a mod k+1 and = mod k+1, with k 0. Suppose that 0 = ν (a) < ν (). Let r 0 = a, r 1 =, r,... e the GB remainder sequence of (a, ), and let q 1, q,... e the corresponding GB quotients: r r j+1 = r j 1 + q j j n j, with n j = ν (r j ) ν (r j 1 ). Let r 0 = a, r 1 =, r,... e the GB remainder sequence of (a, ), and let q 1, q,... e the corresponding GB r j quotients: r j+1 = r j 1 + q j, with n n j = ν (r j ) ν (r j 1 ). j Then, if r i+1 is the first remainder such that ν (r i+1 ) > k, we have q j = q j and r j+1 = r j+1 mod k+1 ν(rj), for any j i.

10 Algorithm Fast-GB-gcd. Input: a, satisfying 0 = ν (a) < ν (). Output: g = gcd(a, ). 1. j, R, a, := Half-GB-gcd(a, ).. If = 0, return a. 3. (q, r) := GB (a, ). 4. Return Fast-GB-gcd(, r ). Fig. 7. Algorithm Fast-GB-gcd. Proof. We prove this result y induction on j 0. This is true for j = 0, ecause a = a mod k+1 and = mod k+1. Suppose now that 1 j i. We use r j 1 r, j r, j 1, ν (r j 1 ) ν (r j 1 ) ν (r j 1 ) Lemma 6 with and l = k+1 ν ν (r j 1 ) (r j 1 ). By induction, modulo k+1 ν(rj 1), r j 1 = r j 1 and r j = r j. Since j i, we have, y definition of i, k +1 ν (r j 1 ) (ν (r j ) ν (r j 1 ))+1, and consequently we can apply Lemma 6. Thus q j = q j and r j+1 = r j+1 mod k+1 ν(rj). Practically, this lemma says that k its can e gained as regard to the initial pair (a, ) y using only k its of a and k its of. This is the advantage of using the GB division instead of the standard division: in the case of the standard Euclidean division, this lemma is only almost true, ecause some of the last quotients efore gaining k its can differ, and have to e repaired. r j 4. Correctness of the Half-GB-gcd Algorithm To show the correctness of the algorithm Fast-GB-gcd, it suffices to show the correctness of the algorithm Half-GB-gcd, which is estalished in the following theorem. (Since each call to Fast-GB-gcd which does not return in Step performs at least one GB division, the termination is ensured.) Theorem 1. The algorithm Half-GB-gcd of Fig. 6 is correct. Proof. We prove the correctness of the algorithm y induction on the size of the inputs. If l(a) = 1, then the algorithm finishes at Step ecause ν () 1. Suppose now that k and that ν () k. Since k + 1 < l(a), Step 5 is a recursive call ( (its ) inputs satisfy ( the ) input c1 a0 conditions). By induction j 1, R 1, c 1 and d 1 satisfy = d j1 R 1, and 1 0 j1 c 1 and j1 d 1 are the consecutive remainders r i 1 and r i 1+1 of the GB remainder sequence of r 0 = a 0 and r 1 = 0 that satisfy ν (r i 1 ) k 1 < ν (r i 1+1 ). From ( ) a Lemma 7, we know that j1 R 1 are two consecutive remainders j1 a = r i1 and j1 = r i1+1 of the GB remainder sequence of r 0 = a and r 1 =, and they

11 satisfy r i1 = r i 1 and r i1+1 = r i modulo 1+1 k1+1. From these last equalities, we have that ν (r i1 ) = ν (r i 1 ) k 1 < ν (r i1+1) ν (r i 1+1 ). Thus, if the execution of the algorithm stops at Step 7, the output is correct. Otherwise, r i1+ is computed at Step 8. At Step 9 we compute k = k ν (r i1+1). Step 7 ensures that k 0. Since ν (r i1+1) > k/, we have k k/ 1. Therefore Step 11 is a recursive call (and( the) inputs satisfy the) input c conditions). By induction, j, S, c and d satisfy: = d j R 0 (, and r 0 j c and j d are the consecutive remainders r i and r i +1 of the GB remainder sequence of ( 0, r 0 ). Moreover, ν (r i ) k < ν (r i +1 ). From Lemma 7, ( ) j 1 we know that j S j1 r are two consecutive remainders r i and r i+1 r (with i = i 1 + i + 1) of the GB remainder sequence of (a, ), that i j 1 +ν ( ) = j c mod k+ r and that i+1 j 1 +ν ( ) = j d mod k+1. Therefore the following sequence of inequalities is valid: ν (r i ) = j 1 + j + ν ( ) k < ν (r i+1 ). This ends the proof of the theorem. 5 Analysis of the Algorithms In this section, we first study the GB Euclidean algorithm. In particular we give a worst-case ound regarding the length of the GB remainder sequence. Then we ound the complexity of the recursive algorithm in the case of the use of Schönhage-Strassen multiplication, and we give some intuition aout the average complexity. 5.1 Length of the GB Remainder Sequence In this susection, we ound the size of the matrix 1 ν (r i ) [q i ] ni... [q 1 ] n1, where the q j s are the GB quotients of a truncated GB remainder sequence r 0,..., r i+1 with ν (r i ) ν (r 0 ) + d < ν (r i+1 ) for some d 0. This will make possile the analysis of the lengths and the numer of the GB remainders. As mentioned in, this susection is not necessary to prove the quasi-linear time complexity of the algorithm. Theorem. Let d 1. Let r 0, r 1 with 0 = ν (r 0 ) < ν (r 1 ), and r 0, r 1,..., r i+1 their first GB remainders, where i is such that ν (r i ) d < ν (r i+1 ). We consider the matrix [q 1 ν (r i ) i ] ni... [q 1 ] n1, where the q j s are the GB quotients and n j = ν (r j ) ν (r j 1 ) for any 1 j i. Let M e the maximum of the asolute values of the four entries of this matrix. Then we have: If d = 0 or 1, M = 1, If d = 3, M 11/8, If d = 5, M 67/3, ( ( If d =, 4 or d 6, M 1+ ) d+1 ( 4 1 ) ) d+1 4.

12 Moreover, all these ounds are reached, in particular, the last one is reached when n j = 1 and q j = 1 for any 1 j i. The proof resemles the worst case analysis of the Gaussian algorithm in [9]. Proof. We introduce a partial order on the matrices: A < B if and only if for any coordinate [i, j], A[i, j] B[i, j]. First, the proof can e restricted to the case where the q j s are non-negative integers, ecause we have the inequality [q i ] ni... [q 1 ] n1 [ q i ] ni... [ q 1 ] n1. This can e easily showed y induction on i y using the properties: A B A B, and if the entries of A, A, B, B are non-negative, A A and B B implies A B A B. Consequently we are looking for the maximal elements for the partial order > in the set: {Π n1+...+n i d [q i ] ni... [q 1 ] n1 / 1 j i, 0 < q j nj 1 and n j 1}. We can restrict the analysis to the case where n n i = d and all the q j s are maximal, which gives the set: {Π n1+...+n i=d [ ni 1] ni... [ n1 1] n1 }. Remark now that [ n 1] n [1] n 1 for any n 3. Therefore, it is sufficient to consider the case where the n j s are in {1, }. Moreover, for any integer j 0, [3] [1] j 1 [3] [1] j+4 1, and we also have the inequalities [3] [1]4 1, [1]51 [3] [1] 7, [3] [1] 5 1 [1]7 and [1] 1 [3] [1] 1 [1]6 1. From these relations, we easily otain the maximal elements: For d = 1, [1] 1. For d =, [1] 1 and [3]. For d = 3, [1] 3 1, [3] [1] 1 and [1] 1 [3]. For d = 4, [1] 4 1, [3] [1] 1, [1] 1 [3] [1] 1 and [1] 1 [3]. For d = 5, [1] 5 1, [3] [1] 3 1, [1] 1 [3] [1] 1, [1] 1 [3] [1] 1 and [1]3 1 [3]. For d = 6, [1] 6 1, [3] [1] 4 1, [1]3 1 [3] [1] 1, [1] 1 [3] [1] 3 1 and [1]4 1 [3]. For d = 7, [1] 7 1, [1] 1 [3] [1] 4 1 and [1] 4 1 [3] [1] 1. For d 8, [1] d 1. ( ) The end of the proof is ovious once we note that d [1] d 1 = ud 1 u d, u d u d+1 where u 0 = 0, u 1 = 1 and u i = u i + 1 u i 1. From this result on the quotient matrices, we can easily deduce the following on the size of the remainders and on the length of the remainder sequence. Theorem 3. Let r 0, r 1 e two non-zero integers with 0 = ν (r 0 ) < ν (r 1 ), and r 0, r 1,..., r t+1 their complete GB remainder sequence, i.e. with r t+1 = 0. Assume that 9 j t. Then: ν(rj) r j ( r 0 ( + r ) ν(r j) 1 ( ) ν(r j) ( 4 1 ) ν(r j) ) ν(r j) 4.

13 ( ) r0 The upper ound is reached y = [1] t r 1 1 ( t 0 ). Moreover, if l(r 0 ), l(r 1 ) n, then we have: t n/ log( 1 ). Proof. (Sketch) For the inequations concerning r j, use the maximal element [1] d 1 from the proof of Theorem, with d = ν (r i ), where i = j 1. Remark then that the upper ound grows far slower with ν (r j ) than the lower ound: this fact gives an upper ound on ν (r t ) and therefore on t. As a comparison, we recall that the worst case for the standard Euclidean division corresponds to the Fionacci sequence, with d n/ log( 1+ 5 ) + o(n). Remark that 1/ log( 1+ 5 ) and 1/ log( 1 ) Complexity Bound for the Recursive Algorithm In what follows, H(n) and G(n) respectively denote the maximum of the numer of it operations performed y the algorithms Half-GB-gcd and Fast-GB-gcd, given as inputs two integers of lengths at most n. Lemma 8. Let c = 1 log The following two relations hold: G(n) = H(n) + G( cn ) + O(n), H(n) = H( n + 1) + O(M(n)). Proof. The first relation is an ovious consequence of Theorem. We now prove the second relation. The costs of Steps 1,, 3, 4, 7, 9 and 10 are negligile. Steps 5 and 11 are recursive calls and the cost of each one is ounded y H( n + 1). Steps 6, 1 and 13 consist of multiplications of integers of size O(n). Finally, Step 8 is a single GB division, and we proved in Lemma 3 that it can e performed in time O(M(n)). From this result and the fact that c < 1, one easily otains the following theorem: Theorem 4. The algorithm Fast-GB-gcd of Fig. 7 runs in quasi-linear time. More precisely, G(n) = O(M(n) log n). The constants that one can derive from the previous proofs are rather large, and not very significant in practice. In fact, for randomly chosen n-it integers, the quotients of the GB remainder sequence are O(1), and therefore Step 8 of the algorithm Half-GB-gcd has a negligile cost. Moreover, the worst-case analysis on the size of the coefficients of the returned matrices gives a worst-case (( ound O 1+ ) n ), which happens to e O( n ) in practice. With these two heuristics, the practical cost of the algorithm Half-GB-gcd satisfies the same recurrence than the Knuth-Schönhage algorithm: H(n) H( n ) + km(n), where the constant k depends from the implementation [11].

14 6 Implementation Issues We have implemented the algorithms descried in this paper in GNU MP [3]. In this section, we first give some tricks that we implemented to improve the efficiency of the algorithm, and then we give some enchmarks. 6.1 Some Savings First of all, note that some multiplications can e saved easily from the fact that when the algorithm Fast-GB-gcd calls the algorithm Half-GB-gcd, the returned matrix is not used. Therefore, for such top-level calls to the algorithm Half-GB-gcd, there is no need to compute the product R [q] j0 R 1. Note also that for interesting sizes of inputs (our implementation of the recursive algorithm is faster than usual Euclidean algorithms for several thousands of its), we are in the domains of Karatsua and Toom-Cook multiplications, and elow the domain of FFT-ased multiplication. This leads to some improvements. For example, the algorithm Fast-GB-gcd should use calls to the algorithm Half-GB-gcd in order to gain γn its instead of n, with a constant γ 1 that has to e optimized. Below a certain threshold in the size of the inputs (namely several hundreds of its), a naive quadratic algorithm that has the requirements of algorithm Half-GB-gcd is used. Moreover, each time the algorithm has to compute a GB quotient, it computes several of them in order to otain a matrix with entries of length as close to the size of machine words as possile. This is done y considering only the two least significant machine words of the remainders (which gives a correct result, ecause of Lemma 6). 6. Comparison to Other Implementations of Suquadratic Gcd Algorithms We compared our implementation in GNU MP using the ordinary integer interface mpz with those of Magma V.10-1 and Mathematica 5.0, which oth provide a suquadratic integer gcd. This comparison was performed on laurent3.medicis.polytechnique.fr, an Athlon MP 00+. Our implementation wins over the quadratic gcd of GNU MP up from aout 500 words of 3 its, i.e. aout 4000 digits. We used as test numers oth the worst case of the classical suquadratic gcd, i.e. consecutive Fionacci numers F n and F n 1, and the worst case of the inary variant, i.e. G n and G n 1, where G 0 = 0, G 1 = 1, G n = G n 1 + 4G n, which gives all inary quotients equal to 1. Our experiments show that our implementation in GNU MP of the inary recursive gcd is 3 to 4 times faster than the implementations of the classical recursive gcd in Magma or Mathematica. This ratio does not vary much with the inputs. For example, ratios for F n and G n are quite similar.

15 type, n Magma V.10-1 Mathematica 5.0 Fast-GB-gcd (GNU MP) F n, F n, F n, F n, G n, G n, Fig. 8. Timings in seconds of the gcd routines of Magma, Mathematica and our implementation in GNU MP. Acknowledgements. The first author thanks Brigitte Vallée for introducing him to fast gcd algorithms and for very helpful discussions on that topic. We thank Jean Vuillemin for the pointer to Hensel s odd division, the Medicis center for allowing the comparison to Magma and Mathematica, and Richard Brent for his comments, which helped to improve oth the contents and the form of the paper. References 1. R. P. Brent. Twenty years analysis of the inary Euclidean algorithm. In A. W. Roscoe J. Davies and J. Woodcock, editors, Millenial Perspectives in Computer Science: Proceedings of the 1999 Oxford-Microsoft Symposium in honour of Professor Sir Antony Hoare, pages 41 53, Palgrave, New York, R. P. Brent and H. T. Kung. A systolic VLSI array for integer GCD computation. In K. Hwang, editor, Proceedings of the 7th Symposium on Computer Arithmetic (ARITH-7). IEEE CS Press, T. Granlund. GNU MP: The GNU Multiple Precision Arithmetic Lirary, 4.1. edition, D. Knuth. The analysis of algorithms. In Actes du Congrès International des Mathématiciens de 1970, volume 3, pages 69 74, Paris, Gauthiers-Villars. 5. P. L. Montgomery. Modular multiplication without trial division. Math. Comp., 44(0):519 51, A. Schönhage. Schnelle Berechnung von Kettenruchentwicklungen. Acta Informatica, 1: , A. Schönhage and V. Strassen. Schnelle Multiplikation grosser Zahlen. Computing, 7:81 9, M. Shand and J. E. Vuillemin. Fast implementations of RSA cryptography. In E. E. Swartzlander, M. J. Irwin, and J. Jullien, editors, Proceedings of the 11th IEEE Symposium on Computer Arithmetic (ARITH-11), pages IEEE Computer Society Press, Los Alamitos, CA, B. Vallée. Gauss algorithm revisited. Journal of Algorithms, 1:556 57, B. Vallée. Dynamical analysis of a class of Euclidean algorithms. Th. Computer Science, 97(1-3): , J. von zur Gathen and J. Gerhard. Modern Computer Algera. Camridge University Press, nd edition, C. K. Yap. Fundamental Prolems in Algorithmic Algera. Oxford University Press, 000.

The Mixed Binary Euclid Algorithm

The Mixed Binary Euclid Algorithm Electronic Notes in Discrete Mathematics 35 (009) 169 176 www.elsevier.com/locate/endm The Mixed Binary Euclid Algorithm Sidi Mohamed Sedjelmaci LIPN CNRS UMR 7030 Université Paris-Nord Av. J.-B. Clément,

More information

Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

More information

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009. Notes on Algebra

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009. Notes on Algebra U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009 Notes on Algebra These notes contain as little theory as possible, and most results are stated without proof. Any introductory

More information

The van Hoeij Algorithm for Factoring Polynomials

The van Hoeij Algorithm for Factoring Polynomials The van Hoeij Algorithm for Factoring Polynomials Jürgen Klüners Abstract In this survey we report about a new algorithm for factoring polynomials due to Mark van Hoeij. The main idea is that the combinatorial

More information

A simple and fast algorithm for computing exponentials of power series

A simple and fast algorithm for computing exponentials of power series A simple and fast algorithm for computing exponentials of power series Alin Bostan Algorithms Project, INRIA Paris-Rocquencourt 7815 Le Chesnay Cedex France and Éric Schost ORCCA and Computer Science Department,

More information

Basic Algorithms In Computer Algebra

Basic Algorithms In Computer Algebra Basic Algorithms In Computer Algebra Kaiserslautern SS 2011 Prof. Dr. Wolfram Decker 2. Mai 2011 References Cohen, H.: A Course in Computational Algebraic Number Theory. Springer, 1993. Cox, D.; Little,

More information

Factoring & Primality

Factoring & Primality Factoring & Primality Lecturer: Dimitris Papadopoulos In this lecture we will discuss the problem of integer factorization and primality testing, two problems that have been the focus of a great amount

More information

Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

More information

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z DANIEL BIRMAJER, JUAN B GIL, AND MICHAEL WEINER Abstract We consider polynomials with integer coefficients and discuss their factorization

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and Breaking The Code Ryan Lowe Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and a minor in Applied Physics. As a sophomore, he took an independent study

More information

11 Ideals. 11.1 Revisiting Z

11 Ideals. 11.1 Revisiting Z 11 Ideals The presentation here is somewhat different than the text. In particular, the sections do not match up. We have seen issues with the failure of unique factorization already, e.g., Z[ 5] = O Q(

More information

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl)

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl) Subsets of Euclidean domains possessing a unique division algorithm Andrew D. Lewis 2009/03/16 Abstract Subsets of a Euclidean domain are characterised with the following objectives: (1) ensuring uniqueness

More information

Integer Factorization using the Quadratic Sieve

Integer Factorization using the Quadratic Sieve Integer Factorization using the Quadratic Sieve Chad Seibert* Division of Science and Mathematics University of Minnesota, Morris Morris, MN 56567 seib0060@morris.umn.edu March 16, 2011 Abstract We give

More information

CONTINUED FRACTIONS AND FACTORING. Niels Lauritzen

CONTINUED FRACTIONS AND FACTORING. Niels Lauritzen CONTINUED FRACTIONS AND FACTORING Niels Lauritzen ii NIELS LAURITZEN DEPARTMENT OF MATHEMATICAL SCIENCES UNIVERSITY OF AARHUS, DENMARK EMAIL: niels@imf.au.dk URL: http://home.imf.au.dk/niels/ Contents

More information

Primality - Factorization

Primality - Factorization Primality - Factorization Christophe Ritzenthaler November 9, 2009 1 Prime and factorization Definition 1.1. An integer p > 1 is called a prime number (nombre premier) if it has only 1 and p as divisors.

More information

Lecture 13: Factoring Integers

Lecture 13: Factoring Integers CS 880: Quantum Information Processing 0/4/0 Lecture 3: Factoring Integers Instructor: Dieter van Melkebeek Scribe: Mark Wellons In this lecture, we review order finding and use this to develop a method

More information

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom. Some Polynomial Theorems by John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.com This paper contains a collection of 31 theorems, lemmas,

More information

Faster deterministic integer factorisation

Faster deterministic integer factorisation David Harvey (joint work with Edgar Costa, NYU) University of New South Wales 25th October 2011 The obvious mathematical breakthrough would be the development of an easy way to factor large prime numbers

More information

Prime Numbers and Irreducible Polynomials

Prime Numbers and Irreducible Polynomials Prime Numbers and Irreducible Polynomials M. Ram Murty The similarity between prime numbers and irreducible polynomials has been a dominant theme in the development of number theory and algebraic geometry.

More information

PROBLEM SET 6: POLYNOMIALS

PROBLEM SET 6: POLYNOMIALS PROBLEM SET 6: POLYNOMIALS 1. introduction In this problem set we will consider polynomials with coefficients in K, where K is the real numbers R, the complex numbers C, the rational numbers Q or any other

More information

Section 4.2: The Division Algorithm and Greatest Common Divisors

Section 4.2: The Division Algorithm and Greatest Common Divisors Section 4.2: The Division Algorithm and Greatest Common Divisors The Division Algorithm The Division Algorithm is merely long division restated as an equation. For example, the division 29 r. 20 32 948

More information

Counting Primes whose Sum of Digits is Prime

Counting Primes whose Sum of Digits is Prime 2 3 47 6 23 Journal of Integer Sequences, Vol. 5 (202), Article 2.2.2 Counting Primes whose Sum of Digits is Prime Glyn Harman Department of Mathematics Royal Holloway, University of London Egham Surrey

More information

Computing Cubic Fields in Quasi-Linear Time

Computing Cubic Fields in Quasi-Linear Time Computing Cubic Fields in Quasi-Linear Time K. Belabas Département de mathématiques (A2X) Université Bordeaux I 351, cours de la Libération, 33405 Talence (France) belabas@math.u-bordeaux.fr Cubic fields

More information

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2. Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

More information

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion CHAPTER 5 Number Theory 1. Integers and Division 1.1. Divisibility. Definition 1.1.1. Given two integers a and b we say a divides b if there is an integer c such that b = ac. If a divides b, we write a

More information

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12 CONTINUED FRACTIONS AND PELL S EQUATION SEUNG HYUN YANG Abstract. In this REU paper, I will use some important characteristics of continued fractions to give the complete set of solutions to Pell s equation.

More information

Computer and Network Security

Computer and Network Security MIT 6.857 Computer and Networ Security Class Notes 1 File: http://theory.lcs.mit.edu/ rivest/notes/notes.pdf Revision: December 2, 2002 Computer and Networ Security MIT 6.857 Class Notes by Ronald L. Rivest

More information

Discrete Mathematics, Chapter 4: Number Theory and Cryptography

Discrete Mathematics, Chapter 4: Number Theory and Cryptography Discrete Mathematics, Chapter 4: Number Theory and Cryptography Richard Mayr University of Edinburgh, UK Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 4 1 / 35 Outline 1 Divisibility

More information

Revisiting the Binary Euclidean Algorithm Richard P. Brent Computing Laboratory University of Oxford rpb@comlab.ox.ac.uk http://www.comlab.ox.ac.uk Presented at University of Warwick, 12 June 1998. Copyright

More information

On Generalized Fermat Numbers 3 2n +1

On Generalized Fermat Numbers 3 2n +1 Applied Mathematics & Information Sciences 4(3) (010), 307 313 An International Journal c 010 Dixie W Publishing Corporation, U. S. A. On Generalized Fermat Numbers 3 n +1 Amin Witno Department of Basic

More information

MOP 2007 Black Group Integer Polynomials Yufei Zhao. Integer Polynomials. June 29, 2007 Yufei Zhao yufeiz@mit.edu

MOP 2007 Black Group Integer Polynomials Yufei Zhao. Integer Polynomials. June 29, 2007 Yufei Zhao yufeiz@mit.edu Integer Polynomials June 9, 007 Yufei Zhao yufeiz@mit.edu We will use Z[x] to denote the ring of polynomials with integer coefficients. We begin by summarizing some of the common approaches used in dealing

More information

Elementary factoring algorithms

Elementary factoring algorithms Math 5330 Spring 013 Elementary factoring algorithms The RSA cryptosystem is founded on the idea that, in general, factoring is hard. Where as with Fermat s Little Theorem and some related ideas, one can

More information

Modélisation et résolutions numérique et symbolique

Modélisation et résolutions numérique et symbolique Modélisation et résolutions numérique et symbolique via les logiciels Maple et Matlab Jeremy Berthomieu Mohab Safey El Din Stef Graillat Mohab.Safey@lip6.fr Outline Previous course: partial review of what

More information

MATH 289 PROBLEM SET 4: NUMBER THEORY

MATH 289 PROBLEM SET 4: NUMBER THEORY MATH 289 PROBLEM SET 4: NUMBER THEORY 1. The greatest common divisor If d and n are integers, then we say that d divides n if and only if there exists an integer q such that n = qd. Notice that if d divides

More information

Unique Factorization

Unique Factorization Unique Factorization Waffle Mathcamp 2010 Throughout these notes, all rings will be assumed to be commutative. 1 Factorization in domains: definitions and examples In this class, we will study the phenomenon

More information

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm. Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm. We begin by defining the ring of polynomials with coefficients in a ring R. After some preliminary results, we specialize

More information

9. POLYNOMIALS. Example 1: The expression a(x) = x 3 4x 2 + 7x 11 is a polynomial in x. The coefficients of a(x) are the numbers 1, 4, 7, 11.

9. POLYNOMIALS. Example 1: The expression a(x) = x 3 4x 2 + 7x 11 is a polynomial in x. The coefficients of a(x) are the numbers 1, 4, 7, 11. 9. POLYNOMIALS 9.1. Definition of a Polynomial A polynomial is an expression of the form: a(x) = a n x n + a n-1 x n-1 +... + a 1 x + a 0. The symbol x is called an indeterminate and simply plays the role

More information

GREATEST COMMON DIVISOR

GREATEST COMMON DIVISOR DEFINITION: GREATEST COMMON DIVISOR The greatest common divisor (gcd) of a and b, denoted by (a, b), is the largest common divisor of integers a and b. THEOREM: If a and b are nonzero integers, then their

More information

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Why? A central concept in Computer Science. Algorithms are ubiquitous. Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

Factorization Methods: Very Quick Overview

Factorization Methods: Very Quick Overview Factorization Methods: Very Quick Overview Yuval Filmus October 17, 2012 1 Introduction In this lecture we introduce modern factorization methods. We will assume several facts from analytic number theory.

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

1 Sets and Set Notation.

1 Sets and Set Notation. LINEAR ALGEBRA MATH 27.6 SPRING 23 (COHEN) LECTURE NOTES Sets and Set Notation. Definition (Naive Definition of a Set). A set is any collection of objects, called the elements of that set. We will most

More information

-4- Algorithm Fast LU Decomposition

-4- Algorithm Fast LU Decomposition Appears in SIGSAM Bulletin 22(2):4-49 (April 988). Analysis of the Binary Complexity of Asymptotically Fast Algorithms for Linear System Solving* Introduction Brent Gregory and Erich Kaltofen Department

More information

Faster Cryptographic Key Exchange on Hyperelliptic Curves

Faster Cryptographic Key Exchange on Hyperelliptic Curves Faster Cryptographic Key Exchange on Hyperelliptic Curves No Author Given No Institute Given Abstract. We present a key exchange procedure based on divisor arithmetic for the real model of a hyperelliptic

More information

An example of a computable

An example of a computable An example of a computable absolutely normal number Verónica Becher Santiago Figueira Abstract The first example of an absolutely normal number was given by Sierpinski in 96, twenty years before the concept

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

More information

Arithmetic algorithms for cryptology 5 October 2015, Paris. Sieves. Razvan Barbulescu CNRS and IMJ-PRG. R. Barbulescu Sieves 0 / 28

Arithmetic algorithms for cryptology 5 October 2015, Paris. Sieves. Razvan Barbulescu CNRS and IMJ-PRG. R. Barbulescu Sieves 0 / 28 Arithmetic algorithms for cryptology 5 October 2015, Paris Sieves Razvan Barbulescu CNRS and IMJ-PRG R. Barbulescu Sieves 0 / 28 Starting point Notations q prime g a generator of (F q ) X a (secret) integer

More information

Notes on Factoring. MA 206 Kurt Bryan

Notes on Factoring. MA 206 Kurt Bryan The General Approach Notes on Factoring MA 26 Kurt Bryan Suppose I hand you n, a 2 digit integer and tell you that n is composite, with smallest prime factor around 5 digits. Finding a nontrivial factor

More information

A New Euclidean Division Algorithm for Residue Number Systems

A New Euclidean Division Algorithm for Residue Number Systems A New Euclidean Division Algorithm for Residue Number Systems Jean-Claude Bajard and Laurent Stéphane Didier Laboratoire d Informatique de Marseille CMI, Université de Provence, 39 rue Joliot-Curie, 3453

More information

Determining the Optimal Combination of Trial Division and Fermat s Factorization Method

Determining the Optimal Combination of Trial Division and Fermat s Factorization Method Determining the Optimal Combination of Trial Division and Fermat s Factorization Method Joseph C. Woodson Home School P. O. Box 55005 Tulsa, OK 74155 Abstract The process of finding the prime factorization

More information

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test Math Review for the Quantitative Reasoning Measure of the GRE revised General Test www.ets.org Overview This Math Review will familiarize you with the mathematical skills and concepts that are important

More information

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem) Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem) In order to understand the details of the Fingerprinting Theorem on fingerprints of different texts from Chapter 19 of the

More information

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any. Algebra 2 - Chapter Prerequisites Vocabulary Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any. P1 p. 1 1. counting(natural) numbers - {1,2,3,4,...}

More information

Handout NUMBER THEORY

Handout NUMBER THEORY Handout of NUMBER THEORY by Kus Prihantoso Krisnawan MATHEMATICS DEPARTMENT FACULTY OF MATHEMATICS AND NATURAL SCIENCES YOGYAKARTA STATE UNIVERSITY 2012 Contents Contents i 1 Some Preliminary Considerations

More information

= 2 + 1 2 2 = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

= 2 + 1 2 2 = 3 4, Now assume that P (k) is true for some fixed k 2. This means that Instructions. Answer each of the questions on your own paper, and be sure to show your work so that partial credit can be adequately assessed. Credit will not be given for answers (even correct ones) without

More information

The Goldberg Rao Algorithm for the Maximum Flow Problem

The Goldberg Rao Algorithm for the Maximum Flow Problem The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }

More information

Continued Fractions. Darren C. Collins

Continued Fractions. Darren C. Collins Continued Fractions Darren C Collins Abstract In this paper, we discuss continued fractions First, we discuss the definition and notation Second, we discuss the development of the subject throughout history

More information

FACTORING LARGE NUMBERS, A GREAT WAY TO SPEND A BIRTHDAY

FACTORING LARGE NUMBERS, A GREAT WAY TO SPEND A BIRTHDAY FACTORING LARGE NUMBERS, A GREAT WAY TO SPEND A BIRTHDAY LINDSEY R. BOSKO I would like to acknowledge the assistance of Dr. Michael Singer. His guidance and feedback were instrumental in completing this

More information

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case. Algorithms Efficiency of algorithms Computational resources: time and space Best, worst and average case performance How to compare algorithms: machine-independent measure of efficiency Growth rate Complexity

More information

THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0

THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0 THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0 RICHARD J. MATHAR Abstract. We count solutions to the Ramanujan-Nagell equation 2 y +n = x 2 for fixed positive n. The computational

More information

Is n a Prime Number? Manindra Agrawal. March 27, 2006, Delft. IIT Kanpur

Is n a Prime Number? Manindra Agrawal. March 27, 2006, Delft. IIT Kanpur Is n a Prime Number? Manindra Agrawal IIT Kanpur March 27, 2006, Delft Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 1 / 47 Overview 1 The Problem 2 Two Simple, and Slow, Methods

More information

On the largest prime factor of x 2 1

On the largest prime factor of x 2 1 On the largest prime factor of x 2 1 Florian Luca and Filip Najman Abstract In this paper, we find all integers x such that x 2 1 has only prime factors smaller than 100. This gives some interesting numerical

More information

Lecture 13 - Basic Number Theory.

Lecture 13 - Basic Number Theory. Lecture 13 - Basic Number Theory. Boaz Barak March 22, 2010 Divisibility and primes Unless mentioned otherwise throughout this lecture all numbers are non-negative integers. We say that A divides B, denoted

More information

The Quadratic Sieve Factoring Algorithm

The Quadratic Sieve Factoring Algorithm The Quadratic Sieve Factoring Algorithm Eric Landquist MATH 488: Cryptographic Algorithms December 14, 2001 1 Introduction Mathematicians have been attempting to find better and faster ways to factor composite

More information

k, then n = p2α 1 1 pα k

k, then n = p2α 1 1 pα k Powers of Integers An integer n is a perfect square if n = m for some integer m. Taking into account the prime factorization, if m = p α 1 1 pα k k, then n = pα 1 1 p α k k. That is, n is a perfect square

More information

International Journal of Information Technology, Modeling and Computing (IJITMC) Vol.1, No.3,August 2013

International Journal of Information Technology, Modeling and Computing (IJITMC) Vol.1, No.3,August 2013 FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED Omar Akchiche 1 and Omar Khadir 2 1,2 Laboratory of Mathematics, Cryptography and Mechanics, Fstm, University of Hassan II Mohammedia-Casablanca,

More information

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may Number Theory Divisibility and Primes Definition. If a and b are integers and there is some integer c such that a = b c, then we say that b divides a or is a factor or divisor of a and write b a. Definition

More information

Computation of 2700 billion decimal digits of Pi using a Desktop Computer

Computation of 2700 billion decimal digits of Pi using a Desktop Computer Computation of 2700 billion decimal digits of Pi using a Desktop Computer Fabrice Bellard Feb 11, 2010 (4th revision) This article describes some of the methods used to get the world record of the computation

More information

Factoring Algorithms

Factoring Algorithms Institutionen för Informationsteknologi Lunds Tekniska Högskola Department of Information Technology Lund University Cryptology - Project 1 Factoring Algorithms The purpose of this project is to understand

More information

Adaptive Online Gradient Descent

Adaptive Online Gradient Descent Adaptive Online Gradient Descent Peter L Bartlett Division of Computer Science Department of Statistics UC Berkeley Berkeley, CA 94709 bartlett@csberkeleyedu Elad Hazan IBM Almaden Research Center 650

More information

Two Binary Algorithms for Calculating the Jacobi Symbol and a Fast Systolic Implementation in Hardware

Two Binary Algorithms for Calculating the Jacobi Symbol and a Fast Systolic Implementation in Hardware Two Binary Algorithms for Calculating the Jacobi Symbol and a Fast Systolic Implementation in Hardware George Purdy, Carla Purdy, and Kiran Vedantam ECECS Department, University of Cincinnati, Cincinnati,

More information

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)! Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

More information

MapReduce and Distributed Data Analysis. Sergei Vassilvitskii Google Research

MapReduce and Distributed Data Analysis. Sergei Vassilvitskii Google Research MapReduce and Distributed Data Analysis Google Research 1 Dealing With Massive Data 2 2 Dealing With Massive Data Polynomial Memory Sublinear RAM Sketches External Memory Property Testing 3 3 Dealing With

More information

it is easy to see that α = a

it is easy to see that α = a 21. Polynomial rings Let us now turn out attention to determining the prime elements of a polynomial ring, where the coefficient ring is a field. We already know that such a polynomial ring is a UF. Therefore

More information

Factorization Theorems

Factorization Theorems Chapter 7 Factorization Theorems This chapter highlights a few of the many factorization theorems for matrices While some factorization results are relatively direct, others are iterative While some factorization

More information

PRIME FACTORS OF CONSECUTIVE INTEGERS

PRIME FACTORS OF CONSECUTIVE INTEGERS PRIME FACTORS OF CONSECUTIVE INTEGERS MARK BAUER AND MICHAEL A. BENNETT Abstract. This note contains a new algorithm for computing a function f(k) introduced by Erdős to measure the minimal gap size in

More information

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = 36 + 41i.

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = 36 + 41i. Math 5A HW4 Solutions September 5, 202 University of California, Los Angeles Problem 4..3b Calculate the determinant, 5 2i 6 + 4i 3 + i 7i Solution: The textbook s instructions give us, (5 2i)7i (6 + 4i)(

More information

A simple criterion on degree sequences of graphs

A simple criterion on degree sequences of graphs Discrete Applied Mathematics 156 (2008) 3513 3517 Contents lists available at ScienceDirect Discrete Applied Mathematics journal homepage: www.elsevier.com/locate/dam Note A simple criterion on degree

More information

Chapter 3. if 2 a i then location: = i. Page 40

Chapter 3. if 2 a i then location: = i. Page 40 Chapter 3 1. Describe an algorithm that takes a list of n integers a 1,a 2,,a n and finds the number of integers each greater than five in the list. Ans: procedure greaterthanfive(a 1,,a n : integers)

More information

Short Programs for functions on Curves

Short Programs for functions on Curves Short Programs for functions on Curves Victor S. Miller Exploratory Computer Science IBM, Thomas J. Watson Research Center Yorktown Heights, NY 10598 May 6, 1986 Abstract The problem of deducing a function

More information

Two Integer Factorization Methods

Two Integer Factorization Methods Two Integer Factorization Methods Christopher Koch April 22, 2014 Abstract Integer factorization methods are algorithms that find the prime divisors of any positive integer. Besides studying trial division

More information

RN-Codings: New Insights and Some Applications

RN-Codings: New Insights and Some Applications RN-Codings: New Insights and Some Applications Abstract During any composite computation there is a constant need for rounding intermediate results before they can participate in further processing. Recently

More information

Integer roots of quadratic and cubic polynomials with integer coefficients

Integer roots of quadratic and cubic polynomials with integer coefficients Integer roots of quadratic and cubic polynomials with integer coefficients Konstantine Zelator Mathematics, Computer Science and Statistics 212 Ben Franklin Hall Bloomsburg University 400 East Second Street

More information

The Mathematics of the RSA Public-Key Cryptosystem

The Mathematics of the RSA Public-Key Cryptosystem The Mathematics of the RSA Public-Key Cryptosystem Burt Kaliski RSA Laboratories ABOUT THE AUTHOR: Dr Burt Kaliski is a computer scientist whose involvement with the security industry has been through

More information

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by SUBGROUPS OF CYCLIC GROUPS KEITH CONRAD 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by g = {g k : k Z}. If G = g, then G itself is cyclic, with g as a generator. Examples

More information

Notes 11: List Decoding Folded Reed-Solomon Codes

Notes 11: List Decoding Folded Reed-Solomon Codes Introduction to Coding Theory CMU: Spring 2010 Notes 11: List Decoding Folded Reed-Solomon Codes April 2010 Lecturer: Venkatesan Guruswami Scribe: Venkatesan Guruswami At the end of the previous notes,

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

2.1 Complexity Classes

2.1 Complexity Classes 15-859(M): Randomized Algorithms Lecturer: Shuchi Chawla Topic: Complexity classes, Identity checking Date: September 15, 2004 Scribe: Andrew Gilpin 2.1 Complexity Classes In this lecture we will look

More information

Introduction to Modern Algebra

Introduction to Modern Algebra Introduction to Modern Algebra David Joyce Clark University Version 0.0.6, 3 Oct 2008 1 1 Copyright (C) 2008. ii I dedicate this book to my friend and colleague Arthur Chou. Arthur encouraged me to write

More information

I. Introduction. MPRI Cours 2-12-2. Lecture IV: Integer factorization. What is the factorization of a random number? II. Smoothness testing. F.

I. Introduction. MPRI Cours 2-12-2. Lecture IV: Integer factorization. What is the factorization of a random number? II. Smoothness testing. F. F. Morain École polytechnique MPRI cours 2-12-2 2013-2014 3/22 F. Morain École polytechnique MPRI cours 2-12-2 2013-2014 4/22 MPRI Cours 2-12-2 I. Introduction Input: an integer N; logox F. Morain logocnrs

More information

Factoring Polynomials

Factoring Polynomials Factoring Polynomials Sue Geller June 19, 2006 Factoring polynomials over the rational numbers, real numbers, and complex numbers has long been a standard topic of high school algebra. With the advent

More information

http://wrap.warwick.ac.uk/

http://wrap.warwick.ac.uk/ Original citation: Hart, William B.. (2012) A one line factoring algorithm. Journal of the Australian Mathematical Society, Volume 92 (Number 1). pp. 61-69. ISSN 1446-7887 Permanent WRAP url: http://wrap.warwick.ac.uk/54707/

More information

How To Prove The Dirichlet Unit Theorem

How To Prove The Dirichlet Unit Theorem Chapter 6 The Dirichlet Unit Theorem As usual, we will be working in the ring B of algebraic integers of a number field L. Two factorizations of an element of B are regarded as essentially the same if

More information

Oligopoly Games under Asymmetric Costs and an Application to Energy Production

Oligopoly Games under Asymmetric Costs and an Application to Energy Production Oligopoly Games under Asymmetric Costs and an Application to Energy Production Andrew Ledvina Ronnie Sircar First version: July 20; revised January 202 and March 202 Astract Oligopolies in which firms

More information

An Efficient and Secure Key Management Scheme for Hierarchical Access Control Based on ECC

An Efficient and Secure Key Management Scheme for Hierarchical Access Control Based on ECC An Efficient and Secure Key Management Scheme for Hierarchical Access Control Based on ECC Laxminath Tripathy 1 Nayan Ranjan Paul 2 1Department of Information technology, Eastern Academy of Science and

More information

ON HENSEL S ROOTS AND A FACTORIZATION FORMULA IN Z[[X]]

ON HENSEL S ROOTS AND A FACTORIZATION FORMULA IN Z[[X]] #A47 INTEGERS 4 (204) ON HENSEL S ROOTS AND A FACTORIZATION FORMULA IN Z[[X]] Daniel Birmaer Department of Mathematics, Nazareth College, Rochester, New Yor abirma6@naz.edu Juan B. Gil Penn State Altoona,

More information

GENERATING SETS KEITH CONRAD

GENERATING SETS KEITH CONRAD GENERATING SETS KEITH CONRAD 1 Introduction In R n, every vector can be written as a unique linear combination of the standard basis e 1,, e n A notion weaker than a basis is a spanning set: a set of vectors

More information