Fast Rational Function Reconstruction
Total Page:16
File Type:pdf, Size:1020Kb
FAST RATIONAL FUNCTION RECONSTRUCTION Sara Khodadad B.Sc., Sharif University of Technology, 2002 X THESIS SUBMITTED IN PARTIAL FIJLFILLMENT OF THE REQCIREMENTS FOR TIIE DEGREE OF MASTER OF SCIENCE in the School of Cornput ing Scierice @ Sara Khodadad 2005 SIMON FRASER UNIVERSITY Fall 2005 All rights rcservcd. This work may not be reproduced in whole or in part. by photocopy or other means, without the pcrmissioil of the author APPROVAL Name: Sara Khodadatl Degree: Master of Science Title of thesis: Fast Rational l+nction Reconstruction Examining Committee: Dr. Daniel Wejskopf Chair Dr. hiicliael Monagan, Senior Supervisor Dr. Arvind Gupta, Supervisor Dr. Petr Lisonek, Exa~niner Date Approved: 'Z":,SIMON FRASER ' $tk-4 uu~lv~~srnlIbra ry DECLARATION OF PARTIAL COPYRIGHT LICENCE The author, whose copyright is declared on the title page of this work, has granted to Simon Fraser University the right to lend this thesis, project or extended essay to users of the Simon Fraser University Library, and to make partial or single copies only for such users or in response to a request from the library of any other university, or other educational institution, on its own behalf or for one of its users. The author has further granted permission to Simon Fraser University to keep or make a digital copy for use in its circulating collection, and, without changing the content, to translate the thesislproject or extended essays, if technically possible, to any medium or format for the purpose of preservation of the digital work. The author has further agreed that permission for multiple copying of this work for scholarly purposes may be granted by either the author or the Dean of Graduate Studies. It is understood that copying or publication of this work for financial gain shall not be allowed without the author's written permission. Permission for public performance, or limited permission for private scholarly use, of any multimedia materials forming part of this work, may have been granted by the author. This information may be found on the separately catalogued multimedia material and in the signed Partial Copyright Licence. The original Partial Copyright Licence attesting to these terms, and signed by this author, may be found in the original bound copy of this work, retained in the Simon Fraser University Archive. Simon Fraser University Library Burnaby, BC, Canada Abstract Let F be a field, f,g E F[z] with rn = deg f > deg g > 0. Our problem is to find a rational f~mctionn/d E F(x) where n/d = g mod f: gcd(f, d) = gcd(n, d) = 1 and deg n + deg d < m. If degree bounds N > deg 12 and D > deg d satisfying N + D < m are known, then bhe problem is solved by the Extended Euclidean Algorithm in F[z]. If degree bounds are not known it is still possible to find n/d with high probability. One way is to use rnaximal q~~otientrational f~mctionreconstruction. We have implemented the algorithm for F[x] = Zp[x], with p a prime. To speed up the algorithm, our implementation uses Karatsuba's algorithm for multiplication in Z,[z] and a Fast Extended Euclidean Algorithm. As an application, we have modified Brown's modular GCD algorithm to use the maximal quotient algorithm. The modification reduces the number of evaluation points needed by the algorithm. Keywords: Fast Extended Euclidean Algorithm, Rational Reconstruction, Rational Function Interpo- lation To my dearest parents, Faridelz and Ahmad, nn.d my beloved h,u,sbnnd, Roozbeh "Sciencc is what wc understand well mough to explain to a computer. Art is everything else we do." -DONALD E. KNUTH Acknowledgments I am really grateful to my supervisor Dr. Michael hlonagan whose help, suggestions and encouragement helped me in all the time of research for and writing of this thesis. I have to thank my co-supervisor, Dr. Arvind Gupta, for reviewing this thesis. Especiall3i, I would like to give my special thanks to my dearest husband Roozbeh for all his help, support, interest and valuable hints that enabled me t,o complete this work. Finally I would like to express my gratihde to my dear friends Amir, Laleh, Maryarn, Sara, Shirin and Soroush who are there for me whenever I need them. Contents Approval Abstract iii Dedication Quotation Acknowledgments Contents vii List of Tables List of Figures List of Algorithms xi 1 Introduction 1 2 F'ast Polynomial Arithmetic 6 2.1 Fast Polynomial Multiplication .......................... 6 2.1.1 Karatsuba's Multiplication Algorithm .................. 7 2.1.2 Memory Requirements of Karatsuba's Algorithm ............ 12 2.2 The Euclidean Algorithm ............................. 14 2.2.1 The Extcnded Euclidean Algorithm ................... 15 2.2.2 The Fast Extended Euclidean Algorithm ................. 19 2.2.3 Fast Poly~lo~nialInterpolation (Application) ............... 30 3 Rational Function Reconstruction 3.1 Rational Function Interpolation (Cauchy Interpolation) ........ 3.2 Rational Function Reconstruction (RFR) ................ 3.2.1 J%Tang'sAlgorithm ......................... 3.2.2 Maxirrial Quotient Rational finctiori Recoristruction ...... 4 Polynomial GCD Computation 4.1 Multivariate GCD Computation (Brown's Algorithm) ......... 4.2 Application of RFR to Brown's Algorithm .................... 50 5 Summary 5 5 Bibliography 5 6 viii List of Tables 2.1 The classical and Karatsuba's multiplication algorithm timings (in ms) .... 11 2.2 The number of multiplications and additions of steps of Algorith~ri2.5 .... 28 2.3 Timings (in ms) of the FEEA compared to the EEA .............. 30 List of Figures 2.1 Steps of Karatsuba's multiplication algorithm .................. 9 2.2 Timings (in ms) of Karatsuba's algorithm for different cutoff degrees ..... 12 2.3 Memory requirements of Karatsuba's algorithm in our implementation .... 13 2.4 Timings (in ms) of the FEEA for different cutoff degree ............ 29 List of Algorithms Karatsuba's Algorithm for input polynomials of size n = 2k .......... 8 Karatsuba's Algorithm for polynomials of different sizes ............ 10 Classical Euclidean Algorithm (EA) ....................... 16 Extended Euclidean Algorithm (EEA) ...................... 16 Fast Extended Euclidean Algorithm (FEEA) .................. 23 Wmg's Rational Function Reconstruction Algorithm .............. 36 Modified FEEA to return the maximal quotient(MQFEEA) .......... 40 Maximal Quotient Rational Function Reconstrnction (MQRFR) ....... 43 Brown's multivariate reduction algorithm (PGCD) ............... 49 Leading Coefficient Retrieval (LCR) ....................... 51 Chapter 1 Introduction Rational recoristruction has become an important tool with many applications in computer algebra. It enables the algorithms to recover rational numbers from their images modulo a large integer (a prime, a prime power or product of several primes) or to recover rational functions from their images modulo a given polynomial. Let F be a field. Given a rational fnnction 7~/dE F(2) and a poly11011ljal m E F[x] where deg nz > 0 and gcd(m, d) = gcd(n, d) = 1, we can easily compute u E F[x] such that u,= n,/d mod 7n. The rational function reconst.ruction algorithm presents a solution for the reverse problem. That is, for given polvnomials m; u E F[x] where 0 < degu < deg nz it output,s a rational function n/d E F(z)where n/d - u,mod ,m and gcd(d, n~)= gcd(r~,d) = 1. The rational function reconstruction problem does not necessarily have a unique solntion. The Extended Euclidean Algorithm finds all solutions satisfying deg n + deg d < deg m. However, it is not had to see that there is only one solution when degee bounds N > deg it and D > deg d satisfying N + D < degm are given. Example 1.1. Let F = Z7 We are given where f E Z7[z]. We w,mt to find a rational f~mction7r/d E Z7(.r) such that Using polynomial inte~polationwe can easily compute u,= z2+x +3 satisfying ,n(a) = f (a), CHAPTER 1. INTRODUCTION 2 and rewrite the above problem in the form of the following rational fnnction reconstruction problem: Given na, -1~E Z7[x]with rn = (x - 1)(x- 2)(x- 3) and u = x2 + n: + 3, find a rational function nld E Z7(x)such that nld = u mod m? gcd(m, cl) = 1. Let N = 1 and D = I be respectively degree bounds for the numerator and the de- norninator of the solution. Using the Extended Euclidean Algorithm we get t,he following solutions Among these 3 solutions only nz/d2satisfies the degree bound requirement, that is, deg n2 5 1 and degd2 5 1. If degree bounds N, D are not available we can use either VCTang's algorithm (Algo- rithm 3.1) or the maximal quotient rational reconstruction algorithm (Algorithm 3.3). Both of these algorithms assume an external mechanism exists which enables us to check whether or not the output of the algorith~nis t,he one we were expecting. In this example we assume that this mechmism gives us u(ai)with ai E Z7 a. new evaluation point. The output of Wang's algorit,hm with inputs .rr~- (2: - 1)(~- 2)(2 - 3),u = x2 + x + 3 would be (62 + 6)/s. Assuming u(4) = 5 we have m = (x- l)(x- 2)(2 - 3)(x- 4) and = 4x3 + 5x2 + 32. This time Wmg's algorithm returns (z2+ 2)/(.c + 1). Adding another point (5,l) or u(5) = 1 and calling Wang's algorithm with inputs 172 = (x- 1)(x - 2)(x- 3)(x- 4)(x- 5) aid u = 4z4 + 6x3 + 5z2 + 63. + 5 we get t.he sanic solution. At this point we require an external mechanism to check whether (x2+ 1)/(x+ 1) is the correct solution. Background In 1981, VITang [20] presented a new algorithm for the partial fraction decomposition of rational fhnctions in Q(:I:). To get, a more efficient algoritllrn he suggested that one first solve the problem modulo a suitably selected prime and then lift the problem p-adically to get the desired solution over Q(z).