Binary GCD Like Algorithms for Some Complex Quadratic Rings
Total Page:16
File Type:pdf, Size:1020Kb
Binary GCD Like Algorithms for Some Complex Quadratic Rings Saurabh Agarwal and Gudmund Skovbjerg Frandsen BRICS, Department of Computer Science, University of Aarhus IT-Parken, Abogade˚ 34, DK-8200, Aarhus N, Denmark. {saurabh, gudmund}@daimi.au.dk Abstract. On the lines of the binary gcd algorithm for rational integers, algorithms√ for computing the gcd are presented for the ring of integers in Q( d) where d ∈{−2, −7, −11, −19}. Thus a binary gcd like algorithm is presented for a unique factorization domain which is not Euclidean (case d = −19). Together with the√ earlier known√ binary gcd like algorithms for the ring of integers in Q( −1) and Q( −3), one now has binary gcd like algorithms for all complex quadratic Euclidean domains. The running time of our algorithms is O(n2) in each ring. While there exists an O(n2) algorithm for computing the gcd in quadratic number rings by Erich Kaltofen and Heinrich Rolletschek, it has large constants hidden under the big-oh notation and it is not practical for medium sized inputs. On the other hand our algorithms are quite fast and very simple to implement. 1 Introduction Greatest common divisor is one of the most fundamental concepts of number the- ory. Elementary number theory texts introduce gcd very early and also present an algorithm to compute it, the Euclid’s algorithm. However, it is not possible to extend Euclid’s algorithm to all number rings. The rings in which one can extend Euclid’s algorithm are called Euclidean rings. A large amount of effort has been put in identifying Euclidean number rings. Franz Lemmermeyer’s pa- per on Euclidean number rings [12] contains an almost complete list of all known Euclidean number rings. In 1965 a different algorithm to compute gcd was presented by J. Stein [19]. Apart from being very simple to understand, this algorithm has the virtue of being efficiently implementable on a computer as the only operations used by the algorithm are addition, subtraction and division by 2. Since divisions by 2 can be performed by right shifts (on a computer), this algorithm essentially has no divisions at all. This algorithm is popularly known as the binary gcd algorithm. In this paper we present extensions of this algorithm to four complex quadratic rings. Basic Research in Computer Science (www.brics.dk), funded by the Danish National Research Foundation. D.A. Buell (Ed.): ANTS 2004, LNCS 3076, pp. 57–71, 2004. c Springer-Verlag Berlin Heidelberg 2004 58 S. Agarwal and G.S. Frandsen 1.1 Overview of Results We successfully generalize√ the binary gcd algorithm to compute the gcd in the ring of integers in Q( d) where d ∈{−2, −7, −11, −19}. In each case the time complexity of the algorithm is O(n2) with small constants hidden under the big-oh notation. The only operations used in our algorithms are addition, sub- traction and division by a small fixed number (2 or 3 or 5). One of the main re- sult is an extension of the binary gcd algorithm to a unique factorization domain (ufd) which is not Euclidean (case d = −19). Our extension clearly indicates that the binary gcd like algorithms are not restricted to Euclidean rings. 1.2 Road Map Section 2 contains some preliminaries. In Sect. 3, we review some other algo- rithms for computing the gcd. The main idea of our algorithm is presented in Sect.√ 4. In Sect. 5, the algorithms for computing the gcd in the ring of integers in Q( d) are presented where d ∈{−2, −7, −11, −19}. 2 Preliminaries The definitions/facts in this section are found in most books on algebra and/or algebraic number theory (for example√ see [10,6,7]). Complex quadratic number fields are of the form Q = Q( d) where√ d is a negative square-free rational√ integer. Any α ∈Qis of the form a + b d where a, b ∈ Q.√ For any α = a + b d, the norm of α is defined as N(α)=αα¯ whereα ¯ = a − b d is the conjugate of α.IfZ denotes the ring of algebraic integers in Q, then √ Z + Z d if d ≡ 2, 3 (mod 4) Z = √ Z Z 1 − d d ≡ + 2 ( 1+ ) if 1 (mod 4) There are nine complex√ quadratic rings which are also ufd. These are the ring of integers in Q( d) where d ∈{−1, −2, −3, −7, −11, −19, −43, −67, −163} [18]. From now on we will assume that Z is one of these nine rings. For all α ∈Z, N(α) is a non-negative rational integer and N(α)=0iff α = 0. An element u ∈Z is a unit iff N(u) = 1. Any two elements α, β ∈Z are called associates if α|β and β|α. A non-zero non-unit element ρ ∈Zis a prime if (ρ|αβ) ⇒ (ρ|α or ρ|β). If ρ ∈Z is a prime, then there exists a rational prime p such that N(ρ)=p or p2. In the former case ρ is not associate to any rational prime and in the latter case ρ is an associate to p. The quotient ring Z/ρZ is a finite field with N(ρ) elements. If N(ρ)=p for some odd rational prime p, then − p−1 ,... , ,... , p−1 Z/ρZ 2 0 2 forms a complete set of coset representatives for and if N(ρ) = 2, then {0, 1} forms a complete set of coset representatives for Z/ρZ. Let α, β ∈Zand αβ = 0. Then a non-zero element g ∈Zis said to be greatest common divisor (gcd) of α and β if Binary GCD Like Algorithms for Some Complex Quadratic Rings 59 a. g|α and g|β, and b. for any γ ∈Z\{0},ifγ|α and γ|β, then γ|g. For any α = 0, gcd of α and 0 is defined to be α. In the literature, gcd of α and β is denoted by (α, β) and we also use this notation. In general (α, β) is not unique. However if g1 =(α, β) and g2 =(α, β), then g1 and g2 are associates. It is customary to overload the ’=’ operator for gcd. Thus a statement like (α, β)=(γ,η) means that gcd of α, β and gcd of γ,η are associates. The following facts about gcd are easily shown. Lemma 1. Let α, β ∈Z be arbitrary integers and ρ ∈Z be any prime. a. If ρ|α and ρ|β, then (α, β)=ρ (α/ρ, β/ρ). b. If ρ|α and ρ β, then (α, β)=(α/ρ, β). c. (α, β)=(α + λβ, β) for all λ ∈Z. 3 Related Work The main aim of this section is to present some of the algorithms which can possibly be used or extended to compute the gcd in different number rings. There are many different known ways of computing the gcd and the list of algorithms discussed in this section is not exhaustive. In the rest of this section the term ’ring’ will always mean number ring. 3.1 Euclidean Algorithm The problem of computing the gcd is as old as number theory itself. Euclid gave an algorithm to compute the gcd of rational integers in 300 B.C. [9]. This algo- rithm is called the Euclidean Algorithm (ea). However ea cannot be extended to all rings. The rings in which one can extend ea are the Euclidean rings. A fairly complete list of all known Euclidean rings can be found in [12]. Let R be any Euclidean ring. Then by definition of Euclidean ring, there exists ϕ: R → N ∪{0} such that for any a, b ∈ R there exits q, r ∈ R such that a = bq + r and ϕ(r) <f(b). If r = 0, then (a, b)=(r, b) and if r =0, then (a, b)=b. A basic step in ea takes inputs a and b and finds such q and r. This step is called Euclidean division. ea repeats this step until r = 0 and then outputs the result. As ϕ is a non-negative integer-valued function, ea will always terminate. The analysis of ea in Z is well studied [2,9]. The running time of ea in Z is O(n2). One can establish that the time complexity of ea in imaginary Euclidean quadratic rings is O(µ(n)n) (see for example [14,12]) where µ(n)is the complexity of multiplying two n-bit integers and µ(n)=O(n log n log log n) by [16]. A similar bound follows for some cyclotomic rings from the works of Hendrik Lenstra [13], Renate Scheidler and Hugh Williams [15]. There are two techniques of speeding up ea for large inputs. First technique is by D.H. Lehmer [11]. The basic idea behind this scheme is to perform single- precision arithmetic with leading digits of the input most of the time and fewer 60 S. Agarwal and G.S. Frandsen multiple-precision operations. Andr´e Weilert [21] and George Collins [4] have established that a similar scheme on Gaussian integers has a time complexity of O(n2). Second technique is controlled Euclidean descent by Arnold Sch¨onhage [16]. For the five imaginary quadratic Euclidean rings, Andr´e Weilert has estab- lished that this technique has a time complexity of O(µ(n) log n) [22,20]. 3.2 Non-euclidean Algorithms Erich Kaltofen and Heinrich Rolletschek [8] gave an O(n3) algorithm for com- puting the gcd in all complex quadratic ufds. They transform the problem of computing the gcd to that of computing a short vector in a suitable four dimen- sional integer lattice.