Modern Computer Algebra, 3rd Edition PDF
Modern Computer Algebra, 3rd Edition PDF
Computer algebra systems are now ubiquitous in all areas of science and engineer-
ing. This highly successful textbook, widely regarded as the “bible of computer
algebra”, gives a thorough introduction to the algorithmic basis of the mathematical
engine in computer algebra systems. Designed to accompany one- or two-semester
courses for advanced undergraduate or graduate students in computer science or
mathematics, its comprehensiveness and reliability has also made it an essential
reference for professionals in the area.
Special features include: detailed study of algorithms including time analysis;
implementation reports on several topics; complete proofs of the mathematical
underpinnings; and a wide variety of applications (among others, in chemistry,
coding theory, cryptography, computational logic, and the design of calendars and
musical scales). A great deal of historical information and illustration enlivens the
text.
In this third edition, errors have been corrected and much of the Fast Euclidean
Algorithm chapter has been renovated.
Joachim von zur Gathen has a PhD from Universität Zürich and has taught at the
University of Toronto and the University of Paderborn. He is currently a professor
at the Bonn–Aachen International Center for Information Technology (B-IT) and
the Department of Computer Science at Universität Bonn.
Jürgen Gerhard has a PhD from Universität Paderborn. He is now Director of
Research at Maplesoft in Canada, where he leads research collaborations with
partners in Canada, France, Russia, Germany, the USA, and the UK, as well as
a number of consulting projects for global players in the automotive industry.
Modern Computer Algebra
Third Edition
J ÜRGEN G ERHARD
Maplesoft, Waterloo
CAMBRIDGE UNIVERSITY PRESS
Cambridge, New York, Melbourne, Madrid, Cape Town,
Singapore, São Paulo, Delhi, Mexico City
Cambridge University Press
The Edinburgh Building, Cambridge CB2 8RU, UK
Published in the United States of America by Cambridge University Press, New York
www.cambridge.org
Information on this title: www.cambridge.org/9781107039032
A catalogue record for this publication is available from the British Library
To Mercedes Cappuccino
Contents
Introduction 1
I Euclid 23
2 Fundamental algorithms 29
2.1 Representation and addition of numbers . . . . . . . . . . . . . . 29
2.2 Representation and addition of polynomials . . . . . . . . . . . . 32
2.3 Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.4 Division with remainder . . . . . . . . . . . . . . . . . . . . . . 37
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
vii
viii Contents
II Newton 217
IV Fermat 511
V Hilbert 585
24 Applications 677
24.1 Gröbner proof systems . . . . . . . . . . . . . . . . . . . . . . . 677
24.2 Petri nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
24.3 Proving identities and analysis of algorithms . . . . . . . . . . . 681
24.4 Cyclohexane revisited . . . . . . . . . . . . . . . . . . . . . . . 685
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
Appendix 701
Keeping up to date
http://cosec.bit.uni-bonn.de/science/mca/
A Beggar’s Book Out-worths a Noble’s Blood.1
William Shakespeare (1613)
I.AmÌ '@ éJ
Ë@ h. AJm
' AÓ ©J
Ôg. éJ
¯ IªÔ
g. ð H. AJºË@ @ Yë ¯
HPQm
Ém × PAJk@ ð ÉÜØ ¨AJ.@ á« @P Qm× 3
Ghiyāth al-Dı̄n Jamshı̄d bin Mas֒ūd bin Mah.mūd al-Kāshı̄ (1427)
1
2 Introduction
matrices, polynomials, etc. They will become an indispensable tool for the sci-
entist and engineer, from students to the work place. These systems are now be-
coming integrated with other software, like numerical packages, CAD/CAM, and
graphics.
The goal of this text is to give an introduction to the basic methods and tech-
niques of computer algebra. Our focus is threefold:
◦ complete presentation of the mathematical underpinnings,
◦ asymptotic analysis of our algorithms, sometimes “Oh-free”,
◦ development of asymptotically fast methods.
It is customary to give bounds on running times of algorithms (if any are given
at all) in a “big-Oh” form (explained in Section 25.7), say as O(n log n) for the
FFT. We often prove “Oh-free” bounds in the sense that we identify the numeri-
cal coefficient of the leading term, as 23 n log2 n in the example; we may then add
O(smaller terms). But we have not played out the game of minimizing these coef-
ficients; the reader is encouraged to find smaller constants herself.
Many of these fast methods have been known for a quarter of a century, but
their impact on computer algebra systems has been slight, partly due to an “unfor-
tunate myth” (Bailey, Lee & Simon 1990) about their practical (ir)relevance. But
their usefulness has been forcefully demonstrated in the last few years; we can now
solve problems—for example, the factorization of polynomials—of a size that was
unassailable a few years ago. We expect this success to expand into other areas of
computer algebra, and indeed hope that this text may contribute to this develop-
ment. The full treatment of these fast methods motivates the “modern” in its title.
(Our title is a bit risqué, since even a “modern” text in a rapidly evolving discipline
such as ours will obsolesce quickly.)
The basic objects of computer algebra are numbers and polynomials. Through-
out the text, we stress the structural and algorithmic similarities between these two
domains, and also where the similarities break down. We concentrate on polyno-
mials, in particular univariate polynomials over a field, and pay special attention
to finite fields.
We will consider arithmetic algorithms in some basic domains. The tasks that
we will analyze include conversion between representations, addition, subtraction,
multiplication, division, division with remainder, greatest common divisors, and
factorization. The domains of fundamental importance for computer algebra are
the natural numbers, the rational numbers, finite fields, and polynomial rings.
Our three goals, as stated above, are too ambitious to keep up throughout. In
some chapters, we have to content ourselves with sketches of methods and out-
looks on further results. Due to space limitations, we sometimes have recourse to
the lamentable device of “leaving the proof to the reader”. Don’t worry, be happy:
solutions to the corresponding exercises are available on the book’s web site.
Introduction 3
After writing most of the material, we found that we could structure the book
into five parts, each named after a mathematician that made a pioneering con-
tribution on which some (but, of course, not all) of the modern methods in the
respective part rely. In each part, we also present selected applications of some of
the algorithmic methods.
The first part E UCLID examines Euclid’s algorithm for calculating the gcd,
and presents the subresultant theory for polynomials. Applications are numerous:
modular algorithms, continued fractions, Diophantine approximation, the Chinese
Remainder Algorithm, secret sharing, and the decoding of BCH codes.
The second part N EWTON presents the basics of fast arithmetic: FFT-based mul-
tiplication, division with remainder and polynomial equation solving via Newton
iteration, and fast methods for the Euclidean Algorithm and the solution of sys-
tems of linear equations. The FFT originated in signal processing, and we discuss
one of its applications, image compression.
The third part G AUSS deals exclusively with polynomial problems. We start
with univariate factorization over finite fields, and include the modern methods
that make attacks on enormously large problems feasible. Then we discuss polyno-
mials with rational coefficients. The two basic algorithmic ingredients are Hensel
lifting and short vectors in lattices. The latter has found many applications, from
breaking certain cryptosystems to Diophantine approximation.
The fourth part F ERMAT is devoted to two integer problems that lie at the foun-
dation of algorithmic number theory: primality testing and factorization. The most
famous modern application of these classical topics is in public key cryptography.
The fifth part H ILBERT treats three different topics which are somewhat more
advanced than the rest of the text, and where we can only exhibit the foundations
of a rich theory. The first area is Gröbner bases, a successful approach to deal with
multivariate polynomials, in particular questions about common roots of several
polynomials. The next topic is symbolic integration of rational and hyperexponen-
tial functions. The final subject is symbolic summation; we discuss polynomial
and hypergeometric summation.
The text concludes with an appendix that presents some foundational material in
the language we use throughout the book: The basics of groups, rings, and fields,
linear algebra, probability theory, asymptotic O-notation, and complexity theory.
Each of the first three parts contains an implementation report on some of the
algorithms presented in the text. As case studies, we use two special purpose pack-
ages for integer and polynomial arithmetic: N TL by Victor Shoup and B I P OL A R
by the authors.
Most chapters end with some bibliographical and historical notes or supple-
mentary remarks, and a variety of exercises. The latter are marked according
to their difficulty: exercises with a ∗ are somewhat more advanced, and the few
marked with ∗∗ are more difficult or may require material not covered in the text.
4 Introduction
Laborious (but not necessarily difficult) exercises are marked by a long arrow −→ .
The book’s web page http://cosec.bit.uni-bonn.de/science/mca/ pro-
vides some solutions.
This book presents foundations for the mathematical engine underlying any
computer algebra system, and we give substantial coverage—often, but not al-
ways, up to the state of the art—for the material of the first three parts, dealing
with Euclid’s algorithm, fast arithmetic, and the factorization of polynomials. But
we hasten to point out some unavoidable shortcomings. For one, we cannot cover
completely even those areas that we discuss, and our treatment leaves out ma-
jor interesting developments in the areas of computational linear algebra, sparse
multivariate polynomials, combinatorics and computational number theory, quan-
tifier elimination and solving polynomial equations, and differential and difference
equations. Secondly, some important questions are left untouched at all; we only
mention computational group theory,parallel computation, computing with tran-
scendental functions, isolating real and complex roots of polynomials, and the
combination of symbolic and numeric methods. Finally, a successful computer
algebra system involves much more than just the mathematical engine: efficient
data structures, a fast kernel and a large compiled or interpreted library, user inter-
face, graphics capability, interoperability of software packages, clever marketing,
etc. These issues are highly technology-dependent, and there is no single good
solution for them.
The present book can be used as the textbook for a one-semester or a two-
semester course in computer algebra. The basic arithmetic algorithms are dis-
cussed in Chapters 2 and 3, and Sections 4.1–4.4, 5.1–5.5, 8.1–8.2, 9.1–9.4, 14.1–
14.6, and 15.1–15.2. In addition, a one-semester undergraduate course might be
slanted towards computational number theory (9.5, 18.1–18.4, and parts of Chap-
ter 20), geometry (21.1–21.6), or integration (4.5, 5.11, 6.2–6.4, and Chapter 22),
supplemented by fun applications from 4.6–4.8, 5.6–5.9, 6.8, 9.6, Chapter 13, and
Chapters 1 and 24. A two-semester course could teach the “basics” and 6.1–6.7,
10.1–10.2, 15.4–15.6, 16.1–16.5, 18.1–18.3, 19.1–19.2, 19.4, 19.5 or 19.6–19.7,
and one or two of Chapters 21–23, maybe with some applications from Chapters
17, 20, and 24. A graduate course can be more eclectic. We once taught a course
on “factorization”, using parts of Chapters 14–16 and 19. Another possibility is
a graduate course on “fast algorithms” based on Part II. For any of these sugges-
tions, there is enough material so that an instructor will still have plenty of choice
of which areas to skip. The logical dependencies between the chapters are given
in Figure 1.
The prerequisite for such a course is linear algebra and a certain level of mathe-
matical maturity; particularly useful is a basic familiarity with algebra and analysis
of algorithms. However, to allow for the large variations in students’ background,
we have included an appendix that presents the necessary tools. For that mate-
rial, the borderline between the boring and the overly demanding varies too much
Introduction 5
2. Fundamental
algorithms
1. Examples
MODERN
COMPUTER
3. The Euclidean
Algorithm
ALGEBRA
4. Applications of 8. Fast
Euclid’s Algorithm NEWTON multiplication
14. Factoring
FERMAT over finite fields GAUSS
F IGURE 1: Leitfaden.
6 Introduction
to get it right for everyone. If those notions and tools are unfamiliar, an instructor
may have to expand beyond the condensed description in the appendix. Otherwise,
most of the presentation is self-contained, and the exceptions are clearly indicated.
By their nature, some of the applications assume a background in the relevant area.
The beginning of each part presents a biographical sketch of the scientist after
which it is named, and throughout the text we indicate some of the origins of our
material. For lack of space and competence, this is not done in a systematic way,
let alone with the goal of completeness, but we do point to some early sources,
often centuries old, and quote some of the original work. Interest in such historical
issues is, of course, a matter of taste. It is satisfying to see how many algorithms
are based on venerable methods; our essentially “modern” aspect is the concern
with asymptotic complexity and running times, faster and faster algorithms, and
their computer implementation.
The 2003 edition. The great French mathematician Pierre Fermat never pub-
lished a thing in his lifetime. One of the reasons was that in his days, books and
other publications often suffered vitriolic attacks for perceived errors, major or
minor, frequently combined with personal slander.
Our readers are friendlier. They pointed out about 160 errors and possible im-
provements in the 1999 edition to us, but usually sugared their messages with
sweet compliments. Thanks, friends, for helping us feel good and produce a better
book now! We gratefully acknowledge the assistance of Sergeı̆ Abramov, Michael
Barnett, Andreas Beschorner, Murray Bremner, Peter Bürgisser, Michael Clausen,
Rob Corless, Abhijit Das, Ruchira Datta, Wolfram Decker, Emrullah Durucan,
Friedrich Eisenbrand, Ioannis Emiris, Torsten Fahle, Benno Fuchssteiner, Rod
Glover, David Goldberg, Mitch Harris, Dieter Herzog, Andreas Hirn, Mark
van Hoeij, Dirk Jung, Kyriakos Kalorkoti, Erich Kaltofen, Karl-Heinz Kiyek,
Andrew Klapper, Don Knuth, Ilias Kotsireas, Werner Krandick, Daniel Lauer,
Daniel Bruce Lloyd, Martin Lotz, Thomas Lücking, Heinz Lüneburg, Mantsika
Matooane, Helmut Meyn, Eva Mierendorff, Daniel Müller, Olaf Müller, Seyed
Hesameddin Najafi, Michael Nöcker, Michael Nüsken, Andreas Oesterhelt, Daniel
Panario, Thilo Pruschke, Arnold Schönhage, Jeff Shallit, Hans Stetter, David
Theiwes, Thomas Viehmann, Volker Weispfenning, Eugene Zima, and Paul
Zimmermann.
Our thanks also go to Christopher Creutzig, Katja Daubert, Torsten Metzner,
Eva Müller, Peter Serocka, and Marianne Wehry.
Besides correcting the known errors and (unintentionally) introducing new ones,
we smoothed and updated various items, and made major changes in Chapters 3,
15, and 22.
Paderborn, February 2002
The 2013 edition. Many people have implemented algorithms from this text
and were happy with it. A few have tried their hands at the fast Euclidean al-
gorithm from Chapter 11 and became unhappy. No wonder — the description
contained a bug which squeezed through an unseen crack in our proof of correct-
ness. That particular crack has been sealed for the present edition, and in fact
much of Chapter 11 is renovated. In addition, about 80 other errors have been
corrected. Thanks go to John R. Black, Murray Bremner, Winfried Bruns, Evan
Jingchi Chen, Howard Cheng, Stefan Dreker, Olav Geil, Giulio Genovese, Stefan
Gerhold, Charles-Antoine Giuliani, Sebastian Grimsell, Masaaki Kanno, Tom
Koornwinder, Heiko Körner, Volker Krummel, Martina Kuhnert, Jens Kunerle,
8 Introduction
Note. We produced the postscript files for this book with the invaluable help of
the following software packages: Leslie Lamport’s LATEX, based on Don Knuth’s TEX,
Klaus Lagally’s ArabTEX, Oren Patashnik’s B IBTEX, Pehong Chen’s MakeIndex, M APLE,
M U PAD, Victor Shoup’s N TL, Thomas Williams’ and Colin Kelley’s gnuplot, the Persis-
tence of Vision Ray Tracer POV-Ray, and xfig.
Clarke’s Third Law:
Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke (c. 1969)
There are too goddamned many machines that spew out data too fast.
Robert Ludlum (1995)
1 The advancement and perfection of mathematics are intimately connected with the prosperity of the State.
1
Cyclohexane, cryptography, codes, and computer
algebra
Three examples in this chapter illustrate some applications of the ideas and meth-
ods of computer algebra: the spatial configurations (conformations) of the cy-
clohexane molecule, a chemical problem with an intriguing geometric solution;
a cryptographic protocol for the secure transmission of messages; and distributed
codes for sharing secrets or sending packets over a faulty network. Throughout
this book you will find such sample applications in a wide variety of areas, from
the design of calendars and musical scales to image compression and the intersec-
tion of algebraic curves. The last section in this chapter gives a concise overview
of some computer algebra systems.
H H
H C H a2 a3
H C C H
a1 a4
H C C H
a6 a5
H C H
H H
F IGURE 1.1: The structure formula for cyclohexane (C6 H12 ), and the orientation we give
to the bonds a1 , . . . , a6 .
We start with an example from chemistry. It illustrates the three typical steps in
mathematical applications: creating a mathematical model of the problem at hand,
“solving” the model, and interpreting the solution in the original problem. Usually,
11
12 1. Cyclohexane, cryptography, codes, and computer algebra
none of these steps is straightforward, and one often has to go back and modify the
approach.
Cyclohexane C6 H12 (Figure 1.1), a molecule from organic chemistry, is a hydro-
carbon consisting of six carbon atoms (C) connected to each other in a cycle and
twelve hydrogen atoms (H), two attached to each carbon atom. The four bonds of
one carbon atom (two bonds to adjacent carbon atoms and two bonds to hydrogen
atoms) are arranged in the form of a tetrahedron, with the carbon in the center and
its bonds pointing to the four corners. The angle α between any two bonds is about
109 degrees (the precise value of α satisfies cos α = −1/3). Two adjacent carbon
atoms may freely rotate around the bond between them.
Chemists have observed that cyclohexane occurs in two incongruent conforma-
tions (which are not transformable into each other by rotations and reflections),
a “chair” (Figure 1.2) and a “boat” (Figure 1.3), and experiments have shown
that the “chair” occurs far more frequently than the “boat”. The frequency of
occurrence of a conformation depends on its free energy—a general rule is that
molecules try to minimize the free energy—which in turn depends on the spatial
structure.
When modeling the molecule by means of plastic tubes (Figure 1.4) representing
the carbon atoms and the bonds between them (omitting the hydrogen atoms for
simplicity) in such a way that rotations around the bonds are possible, one observes
that there is a certain amount of freedom in moving the atoms by rotations around
the bonds in the “boat” conformation (we will call it the flexible conformation),
but that the “chair” conformation is rigid, and that it appears to be impossible to
get from the “boat” to the “chair” conformation. Can we mathematically model
and, if possible, explicitly describe this behavior?
We let a1 , . . . , a6 ∈ R 3 be the orientations of the six bonds in three-space, so
that all six vectors point in the same direction around the cyclic structure (Fig-
ure 1.1), and normalize the distance between two adjacent carbon atoms to be one.
By u ⋆ v = u1 v1 + u2 v2 + u3 v3 we denote the usual inner product of two vectors
u = (u1 , u2 , u3 ) and v = (v1 , v2 , v3 ) in R 3 . The cosine theorem says that u ⋆ v =
||u||2 · ||v||2 · cos β , where ||u||2 = (u ⋆ u)1/2 is the Euclidean norm and β ∈ [0, π ] is
the angle between u and v, when both vectors are rooted at the origin. The above
conditions then lead to the following system of equations:
a1 ⋆ a1 = a2 ⋆ a2 = · · · = a6 ⋆ a6 = 1,
1
a1 ⋆ a2 = a2 ⋆ a3 = · · · = a6 ⋆ a1 = , (1)
3
a1 + a2 + · · · + a6 = 0.
The first line says that the length of each bond is 1. The second line expresses the
fact that the angle between two bonds adjacent to the same carbon atom is α (the
cosine is 1/3 instead of −1/3 since, seen from the carbon atom, the two bonds
1.1. Cyclohexane conformations 13
F IGURE 1.3: Three “boat” conformations of cyclohexane and a stereo image of the middle
one (see Figure 1.2 for a viewing instruction).
have opposite orientation). Finally, the last line expresses the cyclic nature of the
structure.
Together, (1) comprises 6 + 6 + 1 = 13 equations in the 18 coordinates of the
points a1 , . . . , a6 . The first ones are quadratic, and the last ones are linear. There
is still redundancy coming from the whole structure’s possibility to move and ro-
tate around freely in three-space. One possibility to remedy this is to introduce
three more equations expressing the fact that a1 and a2 are parallel to the x-axis
respectively the x, y-plane. These equations can be solved with a computer alge-
bra system, but the resulting description of the solutions is highly complicated and
non-intuitive.
14 1. Cyclohexane, cryptography, codes, and computer algebra
F IGURE 1.4: A plumbing knee model of cyclohexane, with nearly right angles.
1.1. Cyclohexane conformations 15
–0.2
–0.3
–0.4
–0.5
"boat"
–0.6
–0.7
–0.2 y
x
–0.4 –0.2
–0.4 –0.3
–0.6 –0.6 –0.5
–0.7
We built the simple physical “model” in Figure 1.4 of something similar to cy-
clohexane as follows. We bought six plastic plumbing “knees”, with approxi-
mately a right angle. (German plumbing knees actually have an angle of about 93
degrees, for some deep hydrodynamic reason.) This differs considerably from the
109 degrees of the carbon tetrahedron, but on the other hand, it only cost about
e 7. We stuck the six parts together and pulled an elastic cord through them to
keep them from falling apart. Then one can smoothly turn the structure through
the flexible conformations corresponding to the curve in Figure 1.5, physically
“feeling” the curve. Pulling the whole thing forcibly apart, one can also get into
the “chair” position. Now no wiggling or gentle twisting will move the structure;
it is quite rigid.
In classical symmetric cryptosystems, Alice and Bob use the same key for
both encryption and decryption. The RSA cryptosystem, described in detail in
1.2. The RSA cryptosystem 17
❄ transmitted ❄
plaintext ✲ ciphertext ✲ decrypted text
x y = ε(x) δ(y)
encryption ε decryption δ
Long messages are broken into pieces. Now Bob wants to send a message x ∈
{0, . . . , N − 1} to Alice that only she can read. He looks up her public key (N, e),
computes the encryption y = ε(x) ∈ {0, . . . , N − 1} of x such that y ≡ xe mod N,
and sends y. Computing y can be done very efficiently using repeated squaring
(Algorithm 4.8). To decrypt y, Alice uses her private key (N, d) to compute the
decryption x∗ = δ (y) ∈ {0, . . . , N − 1} of y with x∗ ≡ yd mod N. Now Euler’s
theorem (Section 18.1) says that xϕ(N) ≡ 1 mod N, if x and N are coprime. Thus
and it follows that x∗ = x since x and x∗ are both in {0, . . . , N − 1}. In fact, x∗ = x
also holds when x and N have a nontrivial common divisor.
Without knowledge of d, however, it seems currently infeasible to compute x
from N, e, and y. The only known way to do this is to factor N into its prime
factors, and then to compute d with the Extended Euclidean Algorithm as Alice
did, but factoring integers (Chapter 19) is extremely time-consuming: 300 digit
numbers are beyond the capabilities of currently known factoring algorithms even
on modern supercomputers or workstation networks.
Software packages like PGP (“Pretty Good Privacy”; see Zimmermann (1996)
and http://www.openpgp.org) use the RSA cryptosystem for encrypting and
authenticating e-mail and data files, and for secure communication over local area
networks or the internet.
lose them, in Chapter 7.) An obvious solution would be to send the message l + 1
times, but this increases message length and hence slows down communication
speed by a factor of l + 1 and is unacceptable even for small values of l.
Again we may assume that each packet is encoded as an element of some field F,
and that the whole message is the sequence of packets f0 , . . . , fn−1 . Then we
choose k = n + l distinct evaluation points u0 , . . . , uk−1 ∈ F and send the k packets
f (u0 ), . . . , f (uk−1 ) over the net. Assuming that the sequence number i is contained
in the packet header and that the recipient knows u0 , . . . , uk−1 , she can reconstruct
the original message—the (coefficients of the) polynomial f —from any n of the
surviving packages by interpolation (and may discard any others).
The above scheme can also be used to distribute n data blocks (for example,
records of a database) among k = n + l computers in such a way that after failure
of up to l of them the complete information can still be recovered. The difference
between secret sharing and this scheme is that in the former the relevant piece of
information is only one coefficient of f , while in the latter it is the whole polyno-
mial.
The above methods can be viewed as problems in distributed data structures.
Parallel and distributed computing is an active area of research in computer sci-
ence. Developing algorithms and data structures for parallel computing is a non-
trivial task, often more challenging than for sequential computing. The amount
of parallelism that a particular problem admits is sometimes difficult to detect. In
computer algebra, modular algorithms (Chapters 4 and 5) provide a “natural”
parallelism for a certain class of algebraic problems. These are divided into smal-
ler problems by reduction modulo several “primes”, the subproblems can be solved
independently in parallel, and the solution is put together using the Chinese Re-
mainder Algorithm 5.4. An important particular case is when the “primes” are
linear polynomials x − ui . Then modular reduction corresponds to evaluation at ui ,
and the Chinese Remainder Algorithm is just interpolation at all points ui , as in the
examples above.
If the interpolation points are roots of unity (Section 8.2), then there is a par-
ticularly efficient method for evaluating and interpolating at those points, the Fast
Fourier Transform (Chapters 8 and 13). It is the starting point for efficient algo-
rithms for polynomial (and integer) arithmetic in Part II.
24
work will live long after all the text-books of the present day are superseded and
forgotten. It is one of the noblest monuments of antiquity; no mathematician
worthy of the name can afford not to know Euclid. Since the invention of
non-Euclidean geometry and the new ideas of Klein and Hilbert in the 19th
century, we don’t take the Elements quite that seriously any longer.
In the Dark Ages, Europe’s intellectuals were more interested in the maximal
number of angels able to dance on a needle tip, and the Elements mainly survived
in the Arabic civilization. The first translation from the Greek was done by
Al-H.ajjāj bin Yūsuf bin Mat.ar (c. 786–835) for Caliph Hārūn al-Rashı̄d
(766–809). These were later translated into Latin, and Erhard Ratdolt produced in
Venice the first printed edition of the Elements in 1482; in fact, this was the first
mathematics book to be printed. On page 23 we reproduce its first page from a
copy in the library of the University of Basel; the underlining is possibly by the
lawyer Bonifatius Amerbach, its 16th century owner, who was a friend of
Erasmus.
Most of the Elements deals
with geometry, but Books
7, 8, and 9 treat arithmetic.
Proposition 2 of Book 7 asks:
“Given two numbers not prime
to one another, to find their
greatest common measure”,
and the core of the algorithm
goes as follows: “Let AB,CD
be the two given numbers
not prime to one another [. . . ]
if CD does not measure AB,
then, the lesser of the numbers
AB,CD being continually
subtracted from the greater,
some number will be left
which will measure the one
before it” (translation from
Heath 1925).
Numbers here are
represented by line segments,
and the proof that the last number left (dividing the one before it) is a common
divisor and the greatest one is carried out for the case of two division steps (ℓ = 2
in Algorithm 3.6). This is Euclid’s algorithm, “the oldest nontrivial algorithm that
has survived to the present day” (Knuth 1998, §4.5.2), and to whose
25
understanding the first part of this text is devoted. In contrast to the modern
version, Euclid does repeated subtraction instead of division with remainder.
Since some quotient might be large, this does not give a polynomial-time
algorithm, but the simple idea of removing powers of 2 whenever possible
already achieves this (Exercise 3.25).
In the geometric Book 10, Euclid repeats this argument in Proposition 3 for
“commensurable magnitudes”, which are real numbers whose quotient is rational,
and Proposition 2 states that if this process does not terminate, then the two
magnitudes are incommensurable.
The other arithmetical highlight is Proposition 20 of Book 9: “Prime numbers
are more than any assigned multitude of prime numbers.” Hardy (1940) calls its
proof “as fresh and significant as when it was discovered—two thousand years
have not written a wrinkle on [it]”. (For lack of notation, Euclid only illustrates
his proof idea by showing how to find from three given primes a fourth one.)
It is amusing to see how after such a profound discovery comes the platitude of
Proposition 21: “If as many even numbers as we please be added together, the
whole is even.” The Elements is full of such surprises, unnecessary case
distinctions, and virtual repetitions. This is, to a certain extent, due to a lack of
good notation. Indices came into use only in the early 19th century; a system
designed by Leibniz in the 17th century did not become popular.
Euclid authored some other books, but they never hit the bestseller list, and
some are forever lost.
26
Die ganzen Zahlen hat der liebe Gott gemacht,
alles andere ist Menschenwerk.1
Leopold Kronecker (1886)
“I only took the regular course.” “What was that?” enquired Alice.
“Reeling and Writhing, of course, to begin with,” the Mock Turtle
replied: “and then the different branches of Arithmetic—Ambition,
Distraction, Uglification, and Derision.”
Lewis Carroll (1865)
where s ∈ {0, 1}, 0 ≤ n + 1 < 263 , and ai ∈ {0, . . . , 264 − 1} for all i are the digits
29
30 2. Fundamental algorithms
s · 263 + n + 1, a0 , . . . , an
of 64-bit words. This representation can be made unique by requiring that the
leading digit an be nonzero if a 6= 0 (and using the single-entry array 0 to repre-
sent a = 0). We will call this the standard representation for a. For example, the
standard representation of −1 is 263 + 1, 1. It is, however, convenient also to allow
nonstandard representations with leading zero digits since this sometimes facili-
tates memory management, but we do not want to go into details here. The range
of integers that can be represented in standard representation on a 64-bit processor
63 63
is between −264·2 + 1 and 264·2 − 1; each of the two boundaries requires 263 + 1
words of storage. This size limitation is quite sufficient for practical purposes: one
of the larger representable numbers would fill about 70 million 1-TB-discs.
For a nonzero integer a ∈ Z, we define the length λ(a) of a as
log2 |a|
λ(a) = ⌊log264 |a|⌋ + 1 = + 1,
64
where ⌊·⌋ denotes rounding down to the nearest integer (so that ⌊2.7⌋ = 2 and
⌊−2.7⌋ = −3). Thus λ(a) + 1 = n + 2 is the number of words in the standard
representation (1) of a (see Exercise 2.1). This is quite a cluttered expression, and
1
it is usually sufficient to know that about 64 log2 |a| words are needed, or even more
succinctly O(log2 |a|), where the big-Oh notation “O” hides an arbitrary constant
(Section 25.7).
We assume that our hypothetical processor has at its disposal a command for
the addition of two single precision integers a and b. The output of the addition
command is a 64-bit word c plus the content of the carry flag γ ∈ {0, 1}, a special
bit in the processor status word which indicates whether the result exceeds 264 or
not. In order to be able to perform addition of multiprecision integers more easily,
the carry flag is also input to the addition command. More precisely, we have
a + b + γ = γ ∗ · 264 + c,
where γ is the value of the carry flag before the addition and γ ∗ is its value after-
wards. Usually there are processor instructions to clear and set the carry flag.
If a = ∑0≤i≤n ai 264i and b = ∑0≤i≤m bi 264i are two multiprecision integers, then
their sum is
c = ∑ (ai + bi )264i ,
0≤i≤k
where k = max{n, m}, and if, say, m ≤ n, then bm+1 , . . . , bn are set to zero. (In other
words, we may assume that m = n.) In general, ai + bi may be larger than 264 , and
if so, then the carry has to be added to the next digit in order to get a 264 -ary
2.1. Representation and addition of numbers 31
representation again. This process propagates from the lower order to the higher
order digits, and in the worst case, a carry from the addition of a0 and b0 may
influence the addition of an and bn , as the example a = 264(n+1) − 1 and b = 1
shows. Here is an algorithm for the addition of two multiprecision integers of the
same sign; see Exercise 2.3 for a subtraction algorithm.
1. γ0 ←− 0
2. for i = 0, . . . , n do
ci ←− ai + bi + γi , γi+1 ←− 0
if ci ≥ 264 then ci ←− ci − 264 , γi+1 ←− 1
3. cn+1 ←− γn+1
return (−1)s ∑ ci 264i
0≤i≤n+1
integers can be done in time O(n), or at cost O(n), or with O(n) word operations;
the constants hidden in the big-Oh will depend on the details of the machine. We
gain two advantages from this concept: a shorter and more intuitive notation, and
independence of particular machines. The abstraction is justified by the fact that
the actual performance of an algorithm often depends on compiler optimization,
clever cache usage, pipelining effects, and many other things that are quite techni-
cal and nearly impossible to describe in a comparatively high-level programming
language. However, experiments show that “big-Oh” statements are reflected sur-
prisingly well by implementations on any kind of sequentially working processor:
adding two multiprecision integers is a linear operation in the sense that doubling
the input size also approximately doubles the running time.
One can make these statements more precise and formally satisfying. The cost
measure that is widely used for algorithms dealing with integers is the number of
bit operations which can be rigorously defined as the number of steps of a Tur-
ing or register machine (random access machine, RAM) or the number of gates
of a Boolean circuit implementing the algorithm. Since the details of those com-
putational models are rather technical, however, we will content ourselves with
informal arguments and cost measures, as above.
Related data types occurring in currently available processors and mathematical
software are single and multiprecision floating point numbers. These represent
approximations of real numbers, and arithmetic operations, such as addition and
multiplication, are subject to rounding errors, in contrast to the arithmetic opera-
tions on multiprecision integers, which are exact. Algorithms based on computa-
tions with floating point numbers are the main topic in numerical analysis , which
is a theme of its own; neither it nor the recent attempts at systematically combining
exact and numerical computations will be discussed in this text.
a = an rn + an−1 rn−1 + · · · + a1 r + a0 = ∑ ai ri ,
0≤i≤n
a= ∑ ai xi and b = ∑ bi xi (3)
0≤i≤n 0≤i≤m
i 3 2 1 0
ai 9 4 3 8
bi 0 9 4 5
ci 9 13 7 13
1. for i = 0, . . . , n do ci ←− ai + bi
2. return c = ∑ ci xi
0≤i≤n
It is somewhat simpler than integer addition, with its carries. This simplicity
propagates down the line for more complicated algorithms such as multiplication,
division with remainder, etc. Although integers are more intuitive (we learn about
them at a much earlier stage in life), their algorithms are a bit more involved,
and we adopt in this book as a general program the strategy to present mainly
the simpler polynomial case which allows us to concentrate on the essentials, and
often leave details in the integer case to the exercises.
As a first example, we have seen that addition of two polynomials of degree up
to n takes at most n + 1 or O(n) arithmetic operations in R; there is no concern
with machine details here. This is a much coarser cost measure than the number of
word operations for integers. If, for example, R = Z and the coefficients are less
than B in absolute value, then the cost in word operations is O(n log B), which is
the same order of magnitude as the input size. Moreover, additive operations +, −
in R are counted at the same cost as multiplicative operations ·, /, while in most
applications the latter are significantly more expensive than the former.
As a general rule, we will analyze the number of arithmetic operations in the
ring R (additions and multiplications, and also divisions if R is a field) used by an
algorithm. In our analyses, the word addition stands for addition or subtraction ;
we do not count the latter separately. The number of other operations, such as in-
dex calculations or memory accesses, tends to be of the same order of magnitude.
These are usually performed with machine instructions on single words, and their
cost is negligible when the arithmetic quantities are large, say multiprecision inte-
gers. The input size is the number of ring elements that the input occupies. If the
coefficients are integers or polynomials themselves, we may then consider sepa-
rately the size of the coefficients involved and the cost for coefficient arithmetic.
We try to provide explicit (but not necessarily minimal) constants for the domi-
nant term in our analyses of algorithms on polynomials when the cost measure is
the number of arithmetic operations in the coefficient ring, but confine ourselves to
O-estimates when counting the number of word operations for algorithms working
on integers or polynomials with integral coefficients.
2.3. Multiplication
Following our program, we first consider the product c = a · b = ∑0≤k≤n+m ck xk of
two polynomials a and b in R[x], as in (3). Its coefficients are
ck = ∑ ai b j (4)
0≤i≤n
0≤ j≤m
i+ j=k
2.3. Multiplication 35
for 0 ≤ k ≤ n + m. We can just take this formula and turn it into a subroutine, after
figuring out suitable loop variables and boundaries:
for k = 0, . . . , n + m do
ck ←− 0
for i = max{0, k − m}, . . . , min{n, k} do
ck ←− ck + ai · bk−i
There are other ways to organize the loops. We learned in school the following
algorithm.
1. for i = 0, . . . , n do di ←− ai xi · b
2. return c = ∑ di
0≤i≤n
How much time does this take, that is, how many operations in the ground
ring R? Each of the n + 1 coefficients of a has to be multiplied with each of the
m + 1 coefficients of b, for a total of (n + 1)(m + 1) multiplications. Then these
are summed up in n + m + 1 sums; summing s items costs s − 1 additions. So the
total number of additions is
(n + 1)(m + 1) − (n + m + 1) = nm,
and the total cost for multiplication is 2nm + n + m + 1 ≤ 2(n + 1)(m + 1) op-
erations in R. (If a is monic, then the bound drops to 2nm + n ≤ 2n(m + 1).)
Thus we can say that two polynomials of degree at most n can be multiplied
using 2n2 + 2n + 1 operations, or 2n2 + O(n) operations, or O(n2 ) operations,
36 2. Fundamental algorithms
a3 a2 a1 a0 b4 b3 b2 b1 b0
c7 c6 c5 c4 c3 c2 c1 c0
F IGURE 2.1: An arithmetic circuit for polynomial multiplication. The flow of control is
directed downwards. An “electrical” view is to think of the edges as lines, where ring
elements “flow”, with “contact” crossings marked with a •, and no contact at the other
crossings. The size of this circuit equals 32, the number of arithmetic gates in it.
or in quadratic time. The three expressions for the running time get progres-
sively simpler but also less precise. In this book, each of the three versions has its
place (and there are even more versions).
For a computer implementation, Algorithm 2.3 has the drawback of requiring
us to store n + 1 polynomials with m + 1 coefficients each. A way around this is
to interleave the final addition with the computation of the ai xi b. This takes the
same time but uses only O(n + m) storage and is shown in Figure 2.1 for n = 3
and m = 4. Each horizontal level corresponds to one pass through the loop body
in step 1.
We will call classical those algorithms that take a definition of a function and
implement it fairly literally, as the multiplication algorithms above implements the
2.4. Division with remainder 37
formula (4). One might think that this is the only way of doing it. Fortunately,
there are much faster ways of multiplying, in almost linear rather than quadratic
time. We will study these fast algorithms in Part II. By contrast, for the addition
problem no improvement is possible, nor is it necessary: the algorithm uses only
linear time.
According to our general program, we now examine the integer case. The prod-
uct of two single precision integers a, b between 0 and 264 − 1 has “double preci-
sion”: it lies in the interval {0, . . . , 2128 − 265 + 1}. We assume that our processor
has a single precision multiplication instruction which returns the product in two
64-bit words c, d such that a · b = d · 264 + c. Here is the integer analog of Algo-
rithm 2.3.
Besides the multiplication by 264i , which is just a shift in the 264 -ary represen-
tation, multiplication of a multiprecision integer b by a single precision integer ai
must be implemented. The time for this is O(m) (Exercise 2.5), and the total time
is quadratic: O(nm). In line with our general program, we omit the details for
implementing this efficiently.
We conclude this section with the example multiplication of a = 521 = 5 · 102 +
2 · 10 + 1 and b = 2135 = 2 · 103 + 102 + 3 · 10 + 5 in decimal representation, ac-
cording to Algorithm 2.4.
521 · 2135
2135
+42700
+1067500
1112335
The basic tool for modular arithmetic is division with remainder: given inte-
gers a, b, with b nonzero, we want to find a quotient q and a remainder r—both
integers—so that
a = qb + r, |r| < |b|.
In line with our general program, we first discuss the computational aspect of this
problem for polynomials. So we are given a, b ∈ R[x], with b nonzero, and want to
find q, r ∈ R[x] so that
a = qb + r, deg r < deg b. (5)
A first problem is that such q and r do not always exist: it is impossible to divide
x2 by 2x + 1 with remainder in Z[x]! (See Exercise 2.8.) There is a way around
this, the pseudodivision explained in Section 6.12. However, for the moment we
simplify the problem by assuming that the leading coefficient lc(b) of b is a unit
in R, so that it has an inverse v ∈ R with lc(b)v = 1. For R = Z, that still only allows
1 or −1 as leading coefficient, but when R is a field, division with remainder by an
arbitrary nonzero polynomial is possible.
We remind the reader of the “synthetic division” learned in high school with a
small example in Z[x]:
Thus the coefficients of the quotient q = 3x2 − 4x − 1 are determined one by one,
starting at the top, by setting them equal to the corresponding coefficient of the
current “remainder” (in general, one additionally has to divide by lc(b)), which
initially is a = 3x4 + 2x3 + x + 5. Then the remainder is adjusted by subtracting
the appropriate multiple of b = x2 + 2x + 3. The final remainder is r = 15x + 8.
The degree of q is deg a − deg b if q 6= 0. The following algorithm formalizes
this familiar classical method for division with remainder by a polynomial whose
leading coefficient is a unit.
1. r ←− a, u ←− b−1
m
2.4. Division with remainder 39
2. for i = n − m, n − m − 1, . . . , 0 do
3. if deg r = m + i then qi ←− lc(r)u, r ←− r − qi xi b
else qi ←− 0
4. return q = ∑ qi xi and r
0≤i≤n−m
a7 a6 a5 a4 a3 a2 a1 a0 b3 b2 b1 b0
q3 q2 q1 q0 r3 r2 r1 r0
F IGURE 2.2: An arithmetic circuit for polynomial division. A subtraction node computes
the difference of its left input minus its right input.
40 2. Fundamental algorithms
additions and multiplications in R plus one division for inverting bm , and only at
most 2 deg b(deg q + 1) additions and multiplications if b is monic. In many appli-
cations, we have n < 2m, and then the cost is at most 2m2 + O(m) ring operations
(plus an inversion), which is essentially the same as for multiplying two polyno-
mials of degree at most m.
It is easy to see that the quotient and remainder are uniquely determined (when
lc(b) is a unit). Namely, another equation a = q∗ b + r∗ , with q∗ , r∗ ∈ R[x] and
deg r∗ < deg b, yields by subtraction
(q∗ − q)b = r − r∗ .
The right hand side has degree less than deg b, and the left hand side has degree at
least deg b, unless q∗ − q = 0. Therefore the latter is true, q = q∗ , and r = r∗ . We
write “a quo b” for the quotient q and “a rem b” for the remainder r.
What about the integer case? The analog of Algorithm 2.5 is well known from
high school, at least in the decimal representation:
Notes. Good texts on algorithms and their analysis are Brassard & Bratley (1996) and
Cormen, Leiserson, Rivest & Stein (2009).
Addition and multiplication algorithms in decimal notation are explicitly described in
Stevin (1585). Several algorithms for computer arithmetic, such as fast (carry look-ahead
and carry-save) addition, are given in Cormen, Leiserson, Rivest & Stein (2009). For
information about the highly active area of symbolic-numeric computations see the Special
Issue of the Journal of Symbolic Computation (Watt & Stetter 1998) and Corless, Kaltofen
& Watt (2003).
2.4. The first algorithm for division with remainder of polynomials appears in Nuñez
(1567). He is, of course, limited by the concepts of his times to specific degrees, 3 and 1
in his case, and positive coefficients. On fo 31ro , Nuñez writes: Si el partidor fuere com-
puesto, partiremos las mayores dignidades de lo que se ha de partir por la mayor dignidad
del partidor, dexandole en que pueda caber la otra dignidad del partidor, y lo q̃ viniere
multiplicaremos por el partidor, y lo produzido por essa multiplicacion sacaremos de toda
la sũma que se parte, y lo mismo obraremos en lo q̃ restare, por el modo q̃ tenemos quando
partimos numero por numero. Y llegando a numero o dignidad en esta obra que sea de
menor denominacion, que el partidor, quedara essa quantidad en quebrado, [. . . ]1 He then
explains the division of 12x3 + 18x2 + 27x + 17 by 4x + 3 with quotient 3x2 + 2 43 x + 5 163
13
and remainder 1 16 , and checks his result by multiplying out.
An anonymous author (1835) presents a decimal division algorithm for hand calculation
based on a “10’s complement” notation.
Exercises.
2.1 For an integer r ∈ N>1 , we consider the variable-length radix r representation (a0 , . . ., al−1 ) of
a positive integer a, with a = ∑0≤i<l ai ri , a0 , . . ., al−1 ∈ {0, . . ., r − 1}, and al−1 6= 0. Prove that its
length l is ⌊logr a⌋ + 1.
2.2 Design a representation for integers of unlimited size on a 64-bit machine.
2.3 (i) Specify a processor instruction analogous to the addition instruction mentioned in the text
which performs subtraction of two single precision integers. Use the carry flag to indicate whether
the result is negative or not.
(ii) Design an algorithm similar to Algorithm 2.1 for the subtraction of two multiprecision integers
a and b of equal sign and with |a| > |b|.
(iii) Discuss how to decide whether |a| > |b| holds.
2.4 Here is a piece of code implementing Algorithm 2.1 for nonnegative multiprecision integers
(that is, when s = 0) on a hypothetical processor. Text enclosed in /* and */ is a comment. The
1 If the divisor is composed [of more than one summand], we divide the leading term of the dividend by the
leading term of the divisor, ignoring the other terms of the divisor, and we multiply the result by the divisor and
subtract the result of this multiplication from the whole of the dividend, and we apply the same procedure to what
is left, in the way we use it when we divide one number by another. And if we arrive in this procedure at numbers
or terms whose degree is less than that of the divisor, then this quantity will remain as a fraction [...]
42 2. Fundamental algorithms
processor has 26 freely usable registers named A to Z. Initially, registers A and B point to the first
word (the one containing the length) of the representations of a and b, respectively, and C points to a
piece of memory where the representation of c shall be placed.
1: LOAD N, [A] /* load the word that A points to into register N */
2: ADD K, N, 1 /* add 1 to register N and store the result in K
(without affecting the carry flag) */
3: STORE [C], K /* store K in the word that C points to */
4: ADD A, A, 1 /* increase register A by 1 */
5: ADD B, B, 1
6: ADD C, C, 1
7: LOAD I, 1 /* load the constant 1 into register I */
8: CLEARC /* clear carry flag */
9: COMP I, N /* compare the contents of registers I and N ... */
10: BGT 20 /* ... and jump to line 20 if I is greater */
11: LOAD S, [A]
12: LOAD T, [B]
13: ADDC S, S, T /* add the contents of register T to register S
using the carry flag */
14: STORE [C], S
15: ADD A, A, 1
16: ADD B, B, 1
17: ADD C, C, 1
18: ADD I, I, 1
19: JMP 9 /* unconditionally jump to line 9 */
20: ADDC S, 0, 0 /* store carry flag in S */
21: STORE [C], S
22: RETURN
Suppose that our processor runs at 2 GHz and that the execution of one instruction takes one machine
cycle = 0.5 nanoseconds = 5 · 10−10 seconds. Calculate the precise time, in terms of n, to run the
above piece of code, and convince yourself that this is indeed O(n).
2.5 Give an algorithm for multiplying a multiprecision integer b by a single precision integer a,
making use of the single precision multiply instruction described in Section 2.3. Show that your al-
gorithm uses λ(b) single precision multiplications and the same number of single precision additions.
Convert your algorithm into a machine program as in Exercise 2.4.
2.6 Prove that max{λ(a), λ(b)} ≤ λ(a + b) ≤ max{λ(a), λ(b)} + 1 and λ(a) + λ(b) − 1 ≤ λ(ab) ≤
λ(a) + λ(b) hold for all a, b ∈ N>0 .
2.7 Let a > b ∈ N>0 , m = λ(a), n = λ(b) and q = ⌊a/b⌋. Give tight upper and lower bounds for
λ(q) in terms of m and n.
2.8 Prove that in Z[x] one cannot divide x2 by 2x + 1 with remainder as in (5).
2.9∗ Let R be an integral domain with field of fractions K and a, b ∈ R[x] of degree n ≥ m ≥ 0. Then
we can apply the polynomial division algorithm 2.5 to compute q, r ∈ K[x] such that a = qb + r and
deg r < deg b.
(i) Prove that there exist q, r ∈ R[x] with a = qb + r and deg r < deg b if and only if lc(b) | lc(r)
in R every time the algorithm passes through step 3, and that they are unique in that case.
(ii) Modify Algorithm 2.5 so that on input a, b, it decides whether q, r ∈ R[x] as in (i) exist, and
if so, computes them. Show that this takes the same number of operations in R as given in the text,
where one operation is either an addition or a multiplication in R, or a test which decides whether an
element c ∈ R divides another element d ∈ R, and if so, computes the quotient d/c ∈ R.
Exercises 43
2.10 Let R be a ring (commutative, with 1) and a = ∑0≤i≤n ai xi ∈ R[x] of degree n, with all ai ∈ R.
The weight w(a) of a is the number of nonzero coefficients of a besides the leading coefficient:
Thus w(a) ≤ deg a, with equality if and only if all coefficients of a are nonzero. The sparse repre-
sentation of a, which is particularly useful if a has small weight, is a list of pairs (i, ai )i∈I , with each
ai ∈ R and a = ∑i∈I ai xi . Then we can choose #I = w(a) + 1.
(i) Show that two polynomials a, b ∈ R[x] of weight n = w(a) and m = w(b) can be multiplied in
the sparse representation using at most 2nm + n + m + 1 arithmetic operations in R.
(ii) Draw an arithmetic circuit for division of a polynomial a ∈ R[x] of degree less than 9 by b =
x6 − 3x4 + 2 with remainder. Try to get its size as small as possible.
(iii) Let n ≥ m. Show that quotient and remainder on division of a polynomial a ∈ R[x] of degree
less than n by b ∈ R[x] of degree m, with lc(b) a unit, can be computed using n − m divisions in R,
and w(b) · (n − m) multiplications and subtractions in R each.
2.11 Let R be a ring and k, m, n ∈ N. Show that the “classical” multiplication of two matrices
A ∈ Rk×m and B ∈ Rm×n takes (2m − 1)kn arithmetic operations in R.
‘Immortality’ may be a silly word, but probably a mathematician
has the best chance of whatever it may mean.
Godfrey Harold Hardy (1940)
The ignoraunte multitude doeth, but as it was euer wonte, enuie that
knoweledge, whiche thei can not attaine, and wishe all men ignoraunt,
like unto themself. [. . . ] Yea, the pointe in Geometrie,
and the unitie in Arithmetike, though bothe be undiuisible,
doe make greater woorkes, & increase greater multitudes,
then the brutishe bande of ignoraunce is hable to withstande.
Robert Recorde (1557)
I have often wished, that I had employed about the speculative part of
geometry, and the cultivation of the specious Algebra [multivariate
polynomials] I had been taught very young, a good part of that time
and industry, that I had spent about surveying and fortification (of
which I remember I once wrote an entire treatise) and other practick
parts of mathematicks. And indeed the operations of symbolical
arithmetick (or the modern Algebra) seem to me to afford men one of
the clearest exercises of reason that I ever yet met with.
Robert Boyle (1671)
Integers and polynomials with coefficients in a field behave similarly in many re-
spects. Often—but not always—the algorithms for both types of objects are quite
similar, and sometimes one can find a common abstraction of both domains, and it
is then sufficient to design one algorithm for this generalization to solve both prob-
lems in one fell swoop. In this chapter, the Euclidean domain covers the structural
similarities between gcd computations for integers and polynomials. Typically, in
such a situation the polynomial version is slightly simpler, and in Chapter 6, we
will meet polynomial subresultants which have no integer analog at all.
126 = 3 · 35 + 21,
35 = 1 · 21 + 14,
(1)
21 = 1 · 14 + 7,
14 = 2 · 7,
and 7 is the greatest common divisor of 126 and 35. One of the most important
applications is for exact arithmetic on rational numbers, where one has to simplify
35/126 to 5/18 in order to keep the numbers small.
This algorithm can also be adapted to work for polynomials. It is convenient
to use the following general scenario, which captures both situations under one
umbrella. The reader may always think of R as being either the integers or poly-
nomials. The algebraic terminology is explained in Chapter 25.
45
46 3. The Euclidean Algorithm
We say that q = a quo b is the quotient and r = a rem b the remainder, although
q and r need not be unique. Such a d is called a Euclidean function on R.
E XAMPLE 3.2. (i) R = Z and d(a) = |a| ∈ N. Here the quotient and the remain-
der can be made unique by the additional requirement that r ≥ 0.
(ii) R = F[x], where F is a field, and d(a) = deg a. We define the degree of the
zero polynomial to be −∞. It is easy to show uniqueness of the quotient and the
remainder in this case (Section 2.4).
√
(iii) R = Z[i] = {a + ib: a, b ∈ Z}, the ring of Gaussian integers, with i = −1,
and d(a + ib) = a2 + b2 (Exercise 3.19).
(iv) R a field, and d(a) = 1 if a 6= 0 and d(0) = 0. ✸
(i) c | a and c | b,
(i) a | c and b | c,
L EMMA 3.4. The gcd in Z has the following properties, for all a, b, c ∈ Z.
For a proof, see Exercise 3.3. Because of the associativity, we may write
1. r0 ←− f , r1 ←− g
2. i ←− 1
while ri 6= 0 do ri+1 ←− ri−1 rem ri , i ←− i + 1
3. return ri−1 .
For f = 126 and g = 35, the algorithm works precisely as illustrated at the
beginning of this section.
which is obtained by reading the lines of (1) from the bottom up. This important
method is called the Extended Euclidean Algorithm and works in any Euclidean
domain. In various incarnations, it plays a central role throughout this book.
We note that the algorithm terminates because the d(ri ) are strictly decreasing
nonnegative integers for 1 ≤ i ≤ ℓ, where d is the Euclidean function on R. The
elements ri for 0 ≤ i ≤ ℓ + 1 are the remainders and the qi for 1 ≤ i ≤ ℓ are
the quotients in the traditional (Extended) Euclidean Algorithm. The elements
ri , si , and ti form the ith row in the traditional Extended Euclidean Algorithm, for
0 ≤ i ≤ ℓ + 1. The central property is that si f + ti g = ri for all i; in particular,
sℓ f + tℓ g = rℓ is a gcd of f and g (see Lemma 3.8 below). We will see later that all
other intermediate results computed by the algorithm are useful for various tasks
in computer algebra.
(ii) R = Q[x], f = 18x3 − 42x2 + 30x − 6, g = −12x2 + 10x − 2. Then the com-
putation of the traditional Extended Euclidean Algorithm goes as follows. Row
i + 1 is obtained from the two preceding ones by first computing the quotient
qi = ri−1 quo ri and then for each of the three remaining columns by subtracting
the quotient times the entry in row i of that column from the entry in row i − 1.
i qi ri si ti
3 2
0 18x − 42x + 30x − 6 1 0
1 − 32 x + 94 −12x2 + 10x − 2 0 1
2 − 83 x + 43 9
2x− 2
3
1 3 9
2x− 4
8 4
3 0 3x− 3 4x2 − 8x + 4
9 3 3 9
x − = 1 · (18x3 − 42x2 + 30x − 6) + x − (−12x2 + 10x − 2). ✸
2 2 2 4
P ROOF. For (i) and (ii) we proceed by induction on i. The case i = 0 is clear from
step 1 of the algorithm, and we may assume i ≥ 1. Then
ri−1 0 1 ri−1 ri ri
Qi = = = ,
ri 1 −qi ri ri−1 − qi ri ri+1
and (i) follows from Ri = Qi Ri−1 and the induction hypothesis. Similarly, (ii)
follows from
si−1 ti−1 si ti
Qi =
si ti si+1 ti+1
and the induction hypothesis.
For (iii), let i ∈ {0, . . . , ℓ}. We conclude from (i) that
r
ℓ f ri
= Qℓ · · · Qi+1 Ri = Qℓ · · · Qi+1 .
0 g ri+1
Comparing the first entry on both sides, we see that rℓ is a linear combination of
ri and ri+1 , and hence any common divisor of ri and ri+1 divides rℓ . On the other
hand, det Qi = −1 and the matrix Qi is invertible over R, with inverse
−1 qi 1
Qi = ,
1 0
and hence r
ri ℓ
= Q−1 −1
i+1 · · · Qℓ .
ri+1 0
Thus both ri and ri+1 are divisible by rℓ , and rℓ ∼ gcd(ri , ri+1 ). In particular, this is
true for i = 0, so that gcd( f , g) ∼ gcd(r0 , r1 ) ∼ rℓ .
The claim (iv) follows immediately from (i) and (ii), and (v) follows from (ii)
by taking determinants:
si ti
siti+1 − ti si+1 = det = det Ri
si+1 ti+1
s0 t0
= det Qi · · · det Q1 · det = (−1)i .
s1 t1
In particular, this implies that gcd(si ,ti ) ∼ 1 and that Ri is invertible. Now let p ∈ R
be a divisor of ti . If p | f , then clearly p | si f + ti g = ri . On the other hand, if p | ri ,
then p also divides si f = ri −ti g, and hence p divides f since si and ti are coprime.
This proves (vi). For (vii), we multiply both sides of (i) by R−1 i and obtain
r0 −1 ri i ti+1 −ti ri
= Ri = (−1) ,
r1 ri+1 −si+1 si ri+1
using (ii) and (v), and the claim follows by writing this out as a system of linear
equations. ✷
3.3. Cost analysis for Z and F[x] 51
C OROLLARY 3.9.
Any two elements f , g of a Euclidean domain R have a gcd h ∈ R, and it is express-
ible as a linear combination h = s f + tg with s,t ∈ R.
L EMMA 3.10.
P ROOF. We only prove the first equality; the second can be verified in the same
way (Exercise 3.21 (i)). We show (5) and
and
deg si+1 = deg qi + deg si = ∑ deg q j + deg qi = ∑ deg q j ,
2≤ j<i 2≤ j<i+1
T HEOREM 3.11.
The traditional Extended Euclidean Algorithm 3.6 for polynomials f , g ∈ F[x] with
deg f = n ≥ deg g = m can be performed with
◦ at most m + 1 inversions and 2nm + O(n) additions and multiplications in F if
only the quotients qi and the remainders ri are needed,
◦ at most m + 1 inversions and 6nm + O(n) additions and multiplications in F
for computing all results.
P ROOF. The first claim has already been shown, and it remains to analyze the
additional cost for computing the si and ti . At each step, the computation of ti+1 =
ti−1 − qiti requires at most 2 deg qi degti + deg qi + degti + 1 field operations for
the product (Section 2.3), plus at most degti+1 + 1 operations for the subtraction.
Using Lemma 3.10, we obtain
∑ 2(ni−1 − n i )(n0 − ni−1 ) + 2(n0 − ni + 1)
2≤i≤ℓ
3.3. Cost analysis for Z and F[x] 53
= n−m+1+4 ∑ (n − m + i − 1)
2≤i≤m+1
A similar argument as above shows that the normal case is the worst case, so
that the bound is valid in general. Finally, Exercise 3.22 (i) shows that the cost for
the si ’s is at most 2(m2 + m), and the claim follows. ✷
In Chapter 11, we will find a much faster algorithm for the gcd.
Now we sketch the cost analysis when R = Z and d(a) = |a|. We may assume
that f = r0 ≥ g = r1 > r2 · · · > rℓ ≥ 0, so that qi ≥ 1 for all i, and represent all
numbers in 264 -ary standard representation (Section 2.1). Then the length λ(a) of
a positive integer a is λ(a) = ⌊(log a)/64⌋ + 1, where log is the binary logarithm.
But now the bound corresponding to what we used for polynomials, namely ℓ ≤
d(g) + 1 = g + 1 = (264 )(log g)/64 + 1 ≤ 264λ(g), on the number of division steps in
the Euclidean Algorithm for the pair ( f , g) ∈ N 2 is exponential in the input size
λ( f ) + λ(g) (if λ( f ) is not much bigger than λ(g)) and hence rather useless. We
can in fact prove a polynomial upper bound on ℓ, as follows. For 1 ≤ i ≤ ℓ, we
have
ri−1 = qi ri + ri+1 ≥ ri + ri+1 > 2ri+1 .
Thus
∏ ri−1 > 2ℓ−2 ∏ ri+1
2≤i<ℓ 2≤i<ℓ
r1 r2 r2
2ℓ−2 < < 1,
rℓ−1 rℓ 2
log g log g
ℓ ≤ ⌊2 log r1 ⌋ + 1 = 128 + 1 ≤ 128 + 1 = 128λ(g).
64 64
This bound can still be improved. For N ∈ N and f , g ∈ Z with N ≥ f > g > 0,
the largest possible number of division steps ℓ for ( f , g) is the one where all the
quotients are equal to 1, so that f and g are the two largest successive Fibonacci
numbers up to N. As an example, the Euclidean Algorithm for ( f , g) = (13, 8)
computes
54 3. The Euclidean Algorithm
13 = 1 · 8 + 5,
8 = 1 · 5 + 3,
5 = 1 · 3 + 2,
3 = 1 · 2 + 1,
2 = 2 · 1.
The nth Fibonacci number √ Fn (with F0 = 0, F1 =√1, and Fn = Fn−1 + Fn−2 for
n ≥ 2) is approximately φn / 5, where φ = (1 + 5)/2 ≈ 1.618 is the golden
ratio (Exercise 3.28). Thus the following holds for the number ℓ of division steps
for ( f , g) = (Fn+1 , Fn ) if n ≥ 1:
√
ℓ = n − 1 ≈ logφ 5g − 1 ∈ 1.441 log g + O(1). (8)
The average number of division steps for ( f , g) when g is fixed and f varies is
12(ln 2)2
ℓ≈ log g ≈ 0.584 log g.
π2
Now that we have a good upper bound for the number of steps in the Euclidean
Algorithm, we look at the cost for each step. First we consider the cost for one
division step. Let a > b > 0 be integers and a = qb + r with q, r ∈ N and 0 ≤
r < b. According to Section 2.4, computing q and r takes O((λ(a) − λ(b)) · λ(b))
word operations, where λ(a) and λ(b) are the lengths of a and b in the standard
representation, respectively.
Then setting n = λ( f ) and m = λ(g), we obtain—by analogy with (4)—that the
total cost for performing the traditional Euclidean Algorithm (without computing
the si and ti ) is O(nm) word operations.
The following integer analog of Lemma 3.10 is proven in Exercise 3.23.
g f
L EMMA 3.12. |si | ≤ and |ti | ≤ for 1 ≤ i ≤ ℓ + 1.
ri−1 ri−1
Lemma 3.12 yields analogous bounds for the length of si and ti as in the poly-
nomial case, and we have the following theorem, whose proof is left as Exercise
3.24.
T HEOREM 3.13.
The traditional Extended Euclidean Algorithm 3.6 for positive integers f , g with
λ( f ) = n ≥ λ(g) = m can be performed with O(nm) word operations.
3.4. (Non-)Uniqueness of the gcd 55
N cN /N 2
10 0.63
100 0.6087
1000 0.608383
10 000 0.60794971
100 000 0.6079301507
TABLE 3.1: The probabilities that two random positive integers below N are coprime.
We conclude this section with the following question: what is the probability
that two random integers are coprime? More precisely, when N gets large and
cN = #{1 ≤ x, y ≤ N: gcd(x, y) = 1}, we are interested in the numerical value of
cN /N 2 . Table 3.1 gives cN /N 2 for some values of N; it seems to approach a limit
which is a little larger than 3/5. In fact, the value is
cN 6 log N log N
∈ +O ≈ 0.6079271016 + O .
N 2 π2 N N
Interestingly, a similar approximation holds for the probability that a random inte-
ger is squarefree, so that it has no square divisor p2 :
#{1 ≤ x ≤ N: x is squarefree} 6 1
∈ 2 +O √ .
N π N
Exercises 4.18 and 14.32 answer the corresponding questions for polynomials over
a finite field.
In Figure 3.2, we see a two-dimensional coordinate system where the point
(x, y) ∈ N 2 for x, y ≤ 200 is colored white if gcd(x, y) = 1 and gray otherwise.
The intensity of a pixel is proportional to the number of prime factors in the gcd.
The probability that two random integers below 200 are coprime is precisely the
percentage of the area of the 200 × 200 pixels that is colored white. Thus about
3/5 of all pixels are white, and about 2/5 are gray.
If you hold the page horizontally in front of your eyes, you can see (almost)
white horizontal and vertical lines corresponding to prime values of x and y, and
dark lines through the origin corresponding to lines ax = by with small integers
a, b, the most clearly visible being the line x = y.
element gcd( f , g) ∈ Q[x], which one should we choose? In other words, how do
we choose one representative from among all the multiples of a? A reasonable
choice is the monic polynomial, that is, the one with leading coefficient 1. Thus
if lc(a) ∈ Q \ {0} is the leading coefficient of a ∈ Q[x], then we take normal(a) =
a/ lc(a) as the normal form of a. (This has nothing to do with the “normal EEA”
on page 51.)
To make this work in an arbitrary Euclidean domain R, we assume that we have
selected some normal form normal(a) ∈ R for every a ∈ R so that a ∼ normal(a).
We call the unit u ∈ R with a = u· normal(a) the leading unit lu(a) of a. Moreover,
we set lu(0) = 1 and normal(0) = 0. The following two properties are required:
◦ two elements of R have the same normal form if and only if they are associate,
◦ the normal form of a product is equal to the product of the normal forms.
3.4. (Non-)Uniqueness of the gcd 57
These properties in particular imply that the normal form of any unit is 1. We say
that an element a in normal form, so that lu(a) = 1, is normalized.
In our two main applications, integers and univariate polynomials over a field,
we have natural normal forms. If R = Z, lu(a) = sign(a) if a 6= 0 and normal(a) =
|a| defines a normal form, so that an integer is normalized if and only if it is
nonnegative. When R = F[x] for a field F, then letting lu(a) = lc(a) (with the
convention that lu(0) = 1) and normal(a) = a/ lc(a) defines a normal form, and a
nonzero polynomial is normalized if and only if it is monic.
Given such a normal form, we define gcd(a, b) to be the unique normalized
associate of all greatest common divisors of a and b, and similarly lcm(a, b) as the
normalized associate of all least common multiples of a and b. Thus gcd(a, b) > 0
for R = Z and gcd(a, b) is monic for R = F[x] if at least one of a, b is nonzero, and
gcd(0, 0) = 0 in both cases. Lemma 3.4 then remains valid if we replace | · | by
normal(·).
In the polynomial case, it turns out that it is not only useful to have a normal
form for the gcd, but to modify the traditional Euclidean Algorithm so that all
the remainders ri are normalized. In Chapter 6, we will see that for R = Q[x] the
computations of the traditional Euclidean Algorithm produce remainders whose
coefficients have huge numerators and denominators even for inputs of moderate
size, and that the coefficients of the monic associates of the remainders are much
smaller (see pages 143 and 185). In this book, we will often use the following
variant of the traditional Extended Euclidean Algorithm 3.6 which works with
these monic associates.
2. i ←− 1
while ri 6= 0 do
qi ←− ri−1 quo ri
ρi+1 ←− lu(ri−1 − qi ri )
ri+1 ←− (ri−1 − qi ri )/ρi+1
si+1 ←− (si−1 − qi si )/ρi+1
ti+1 ←− (ti−1 − qiti )/ρi+1
i ←− i + 1
3. ℓ ←− i − 1
return ℓ, ρi , ri , si ,ti for 0 ≤ i ≤ ℓ + 1, and qi for 1 ≤ i ≤ ℓ
58 3. The Euclidean Algorithm
E XAMPLE 3.7 (continued). (ii) With monic remainders, the following quanti-
ties are computed.
i qi ρi ri si ti
3 7 2 5 1 1
0 18 x − 3x + 3x − 3 18 0
1 x − 23 −12 x2 − 56 x + 1
6 0 1
− 12
2 x − 21 1
4 x− 1
3
2
9
1
3x− 2
1
3 1 0 − 29 x + 1
9 − 13 x2 + 2
3x− 3
1
L EMMA 3.15. (a) With the following modifications, all statements of Lemma 3.8
hold for the results of Algorithm 3.14.
(iii) gcd( f , g) = gcd(ri , ri+1 ) = rℓ ,
(v) siti+1 − ti si+1 = (−1)i (ρ0 · · · ρi+1 )−1 ,
(vi) gcd(ri ,ti ) = gcd( f ,ti ),
(vii) f = (−1)i ρ0 · · · ρi+1 (ti+1 ri − ti ri+1 ), g = (−1)i+1 ρ0 · · · ρi+1 (si+1 ri − si ri+1 ).
(b) If R = F[x] for a field F , deg f ≥ deg g, and ni = deg ri for all i, then the degree
formulas of Lemma 3.10 hold for the results of Algorithm 3.14 as well.
P ROOF. With the following changes, the proof of Lemma 3.8 goes through:
ri−1 0 1 ri−1 ri ri
Qi = = = ,
ri ρ−1 −1
i+1 −qi ρi+1 ri (ri−1 − qi ri )ρ−1
i+1 ri+1
qi ρi+1
Q−1
i = ,
1 0
3.4. (Non-)Uniqueness of the gcd 59
s0 t0
det Qi · · · det Q1 · det = (−1)i (ρ0 · · · ρi+1 )−1 ,
s1 t1
r0 ri i ti+1 −ti ri
= R−1
i = (−1) (ρ0 · · · ρi+1 ) .
r1 ri+1 −si+1 si ri+1
Statements (iii) and (vi) follow from the fact that all elements involved are normal-
ized. The proof of (b) is left as Exercise 3.21 (ii). ✷
We conclude this section with a cost analysis of the EEA for polynomials. It
turns out to be not more expensive than the traditional EEA.
T HEOREM 3.16.
For the monic normal form normal(h) = h/ lc(h) on F[x], the Extended Euclidean
Algorithm 3.14 for polynomials f , g ∈ F[x] with deg f = n ≥ deg g = m can be
performed with
◦ at most m + 2 inversions and 2nm + O(n) additions and multiplications in F if
only the quotients qi , the remainders ri , and the coefficients ρi are needed,
◦ at most m + 2 inversions and 6nm + O(n) additions and multiplications in F
for computing all results.
As in Section 3.3, the normal case is the worst case, normalizing f and g takes two
inversions and n + m multiplications, and (i) follows.
60 3. The Euclidean Algorithm
= m+1+ ∑ 4(n − m + i − 1)
1≤i≤m+1
Exercise 3.22 (ii) shows that the cost for computing all si is at most 2m2 + 3m + 1
in the normal case. Again, the normal case is the worst case, and (ii) follows. ✷
Theorem 6.53 (i) in Section 6.11 shows that in the polynomial case, the results
of the traditional EEA and the results of Algorithm 3.14 are constant multiples of
each other.
Taking the positive or monic gcd in Z or F[x], respectively, is a reasonable
solution to the nonuniqueness problem. However, when you implement computer
algebra software, many other rings will be relevant, and often normalization is
not compatible across domains. For example, gcd(−10x, 5x2 ) is not really defined
unless we specify the domain R in Definition 3.3. Using R as a subscript, we
have—under normalization—gcdQ[x] (−10x, 5x2 ) = x, and ±5x are candidates for
gcdZ[x] (−10x, 5x2 ). A computer algebra system has to make an assumption here,
unless it allows the user to specify the domain; for our example, usually Z[x] is
assumed.
If R is a domain with a normal form normalR , then we get one for the polynomial
ring R[x] by setting
normalR (lc( f ))
normalR[x] ( f ) = · f,
lc( f )
where lc( f ) is the leading coefficient of f (Exercise 3.8 (iii)). Inductively, this
defines a normal form, and hence a unique gcd, for multivariate polynomials over
Z or over any field.
Notes 61
Notes. 3.1. The algorithm described in Euclid’s Elements does not use division with
remainder, but rather subtracts the smaller number g from the larger one until it becomes
smaller than g, and then swaps the two.
Allowing −∞ as a value of a Euclidean function d is a bit annoying and makes our two
main examples, integers and univariate polynomials over a field, look different. The proper
analogy between Z and F[x] goes as follows. We can take d(a) = |a| on Z and d(a) = 2deg a
on F[x], including d(0) = 0 in both cases; then d(ab) = d(a)d(b). Or, equivalently, we can
take d(a) = ⌊log2 |a|⌋ on Z (Exercise 3.5) and d(a) = deg a on F[x], with d(0) = −∞ in
both cases; then d(ab) is d(a) + d(b) (or d(a) + d(b) + 1 in Z).
3.2. The astronomical book Āryabhat.ı̄ya, written by Āryabhat.a in Sanskrit near the end
of the fifth century AD, contains an algorithm for computing from two coprime integers
f , g ∈ N two integers s,t such that s f + tg = 1. This problem is also solved in Bachet
(1612).
Exercise 3.25 discusses the binary Euclidean Algorithm of Stein (1967). Knuth (1998),
already in the second edition, states a binary EEA due to Michael Penk (Algorithm Y in
the Answers to Exercises of §4.5.2). Weilert (2000) adapts the binary Euclidean Algorithm
to the Gaussian integers.
Although the polynomial version of the (Extended) Euclidean Algorithm is conceptually
somewhat simpler, it is much younger (Stevin 1585; Newton 1707, page 38) than the
2000-year old integer algorithm. One reason for this is that we have a more intuitive
understanding of integers than we do of polynomials.
3.3. The fact that the number of division steps is maximal for Fibonacci numbers is Lamé’s
(1844) theorem. The scholarly work of Bach & Shallit (1996) contains more complete his-
torical information about this and many other topics in this book. The interesting paper
by Shallit (1994) points to three earlier analyses of the number of divisions in Euclid’s
algorithm: Reynaud (1824), Finck (1841), and Binet (1841); the latter allows negative
remainders, as in Exercise 3.13. Finck’s wording un problème qui [. . . ] a pour objet
de déterminer le nombre des opérations de la recherche du p.g.c.d. de deux nombres en-
tiers1 is a remarkably modern-sounding demand for the analysis of Euclid’s algorithm.
He gives the inequality√ri−1 > 2ri+1 that we used. Dupré (1846) gives √ the bounds of
about (log f )/ log((1 + 5)/2) for the ordinary and (log f )/ log(1 + 2) for Binet’s Eu-
clidean Algorithm (Exercise 3.30). Much earlier, Schwenter (1636), 86. Auffgab, calls
the Euclidean Algorithm for 770 020 512 197 390 and 124 591 930 070 091, with 32 divi-
sions, the arithmetical labyrinth, due to Simon Jacob von Coburg, and points to the Fi-
bonacci numbers as requiring many divisions in the Euclidean Algorithm. (The two large
integers are not Fibonacci numbers, and Schwenter says that their Euclidean Algorithm
requires 54 divisions; there is a calculation or copying mistake somewhere.) We have
gcd(Fn , Fm ) = Fgcd(n,m) ; see Exercise 3.31.
The average number of division steps in the Euclidean Algorithm for integers was inves-
tigated by Heilbronn (1968) and Dixon (1970), and in the binary algorithm (Exercise 3.25)
by Brent (1976); see Knuth (1998), §4.5.2, and Shallit (1994) for surveys. Those results
were all based on reasonable but unproven assumptions. The question was finally settled by
2
Vallée (2003); she gives average case analyses of several variations, with about π6 n many
divisions on average for the Euclidean Algorithm on n-bit numbers. For polynomials over
1 a problem that [. . . ] has as its goal to determine the number of operations in computing the gcd of two integers
62 3. The Euclidean Algorithm
finite fields, Ma & von zur Gathen (1990)) give worst case and average case analyses of
several variants of the Euclidean Algorithm.
The fact that two random integers are coprime with probability 6/π 2 is a theorem of
Dirichlet (1849). Dirichlet also proves the fact, surprising at first sight, that for fixed a
in a division the remainder r = a rem b, with 0 ≤ r < b, is more likely to be smaller
than b/2 than larger: If pa denotes the probability for the former, where 1 ≤ b ≤ a is
chosen uniformly at random, then pa is asymptotically 2 − ln 4 ≈ 61.37%. For Dirichlet’s
theorem, and also the corresponding statement about the probability of being squarefree
(due to Gegenbauer 1884), see Hardy & Wright (1985), §§18.5 and 18.6. A heuristic
argument goes as follows. A prime p divides a random integer x with probability 1/p, and
neither x nor y with probability 1 − 1/p2 . Hence gcd(x, y) = 1 happens with probability
ζ(2)−1 = ∏ p prime (1 − 1/p2 ) = 6/π 2 ; see Notes 18.4 for a discussion of Riemann’s zeta
function. The value of ζ(2) was determined by Euler (1734/35b, 1743); see Apostol (1983)
for a simple way of calculating this quantity.
3.4. The Euclidean Algorithm 3.14 with monic remainders (for univariate polynomials)
appears in the 1969 edition of Knuth (1998), and in Brown (1971).
The calculation of the Bézout coefficients via the EEA in general is in Euler (1748a),
§70. See also Notes 6.3. Gauß (1863b), articles 334 and 335, does this for polynomials in
F p [x], where p is prime.
Exercises.
3.1 Prove that two odd integers whose difference is 32 are coprime.
3.2 Let R be an integral domain. Show that
Our two familiar examples, the degree on F[x] for a field F and the absolute value on Z, both fulfill
this property. This exercise shows that every Euclidean domain has such a Euclidean function.
(i) Show that δ: Z −→ N with δ(3) = 2 and δ(a) = |a| if a 6= 3 is a Euclidean function on Z
violating (9).
(ii) Suppose that R is a Euclidean domain and D = {δ: δ is a Euclidean function on R}. Then D is
nonempty, and we may define a function d: R −→ N ∪ {−∞} by d(a) = min{δ(a): δ ∈ D}. Show that
d is a Euclidean function on R (called the minimal Euclidean function).
(iii) Let δ be a Euclidean function on R such that δ(ab) < δ(b) for some a, b ∈ R \ {0}. Find
another Euclidean function δ ∗ that is smaller than δ. Conclude that the minimal Euclidean function
d satisfies (9).
(iv) Show that for all a, b ∈ R \ {0} and a Euclidean function d satisfying (9), we have d(0) < d(a),
and d(ab) = d(b) if and only if a is a unit.
Exercises 63
(v) Let d be the minimal Euclidean function as in (ii). Conclude that d(0) = −∞ and the group of
units of R is R× = {a ∈ R \ {0}: d(a) = 0}.
(vi) Prove that d(a) = deg a is the minimal Euclidean function on F[x] for a field F, and that
d(a) = ⌊log2 |a|⌋ is the minimal Euclidean function on Z, with d(0) = −∞ in both cases.
3.6∗ (i) Show that each two nonzero elements a, b of a UFD R have a gcd as well as a lcm. You
may assume that a normal form on R is given (this is not a restriction, by Exercise 3.9). Hint: First
look at the special case R = Z, and use the factorizations of normal(a) and normal(b) into normalized
primes.
(ii) Prove that gcd(a, b) · lcm(a, b) = normal(a · b).
(iii) Conclude that lcm(a1 , . . ., an ) = normal(a1 · · ·an ) for any n nonzero elements a1 , . . ., an ∈ R
that are pairwise coprime (you might need Exercise 3.4).
(iv) Is gcd(a1 , . . ., an ) · lcm(a1 , . . ., an ) = normal(a1 · · ·an ) valid for arbitrary n ∈ N?
3.7∗ Let R be a Euclidean domain, with a Euclidean function d: R −→ N ∪ {−∞} that has the addi-
tional properties
◦ d(ab) = d(a) + d(b),
◦ d(a + b) ≤ max{d(a), d(b)}, with equality if d(a) 6= d(b),
◦ d is surjective,
for all a, b ∈ R. Prove that R is a polynomial ring with d as degree function. Proceed as follows:
(i) Prove that d(a) = −∞ if and only if a = 0.
(ii) Show that F = {a ∈ R: d(a) ≤ 0} is a subfield of R.
(iii) Let x ∈ R be such that d(x) = 1, and prove that every nonzero a ∈ R has a unique representation
a = an xn + an−1 xn−1 + · · · + a1 x + a0 ,
3.11 For each of the following pairs of integers, find their greatest common divisor using the Eu-
clidean Algorithm:
(i) 34, 21; (ii) 136, 51; (iii) 481, 325; (iv) 8771, 3206.
3.12 Show that {s f +tg: s,t ∈ Z} = {k · gcd( f , g): k ∈ Z} holds for all f , g ∈ Z. (In other words, the
two ideals h f , gi and hgcd( f , g)i are identical.)
3.13 The Euclidean Algorithm for integers can be slightly speeded up if it is permitted to carry out
divisions with negative remainders, so that ri−1 = ri qi + ri+1 with −|ri /2| < ri+1 ≤ |ri /2|. Do the
four examples in Exercise 3.11 using this method.
3.14 Use the Extended Euclidean Algorithm to find gcd( f , g), for f , g ∈ Z p [x] in each of the fol-
lowing examples (arithmetic in Z p = {0, . . ., p − 1} is done modulo p). In each case compute the
corresponding polynomials s and t such that gcd( f , g) = s f + tg.
(i) f = x3 + x + 1, g = x2 + x + 1 for p = 2 and p = 3.
(ii) f = x4 + x3 + x + 1, g = x3 + x2 + x + 1 for p = 2 and p = 3.
(iii) f = x5 + x4 + x3 + x + 1, g = x4 + x3 + x2 + x + 1 for p = 5.
(iv) f = x5 + x4 + x3 − x2 − x + 1, g = x3 + x2 + x + 1 for p = 3 and p = 5.
3.15 Show that the si and ti in the traditional Extended Euclidean Algorithm for inputs f , g ∈ Z
with f > g > 0 alternate in sign, so that s2i and t2i−1 are positive and s2i+1 and t2i are negative
for all admissible values of i ≥ 1. Conclude that 0 = s1 < 1 = s2 ≤ |s3 | < |s4 | < · · · < |sℓ+1 | and
0 = t0 < 1 = t1 ≤ |t2 | < |t3 | < · · · < |tℓ+1 |.
3.16 Let R be a Euclidean domain, a, b, c ∈ R, and gcd(a, b) = 1. Prove the following:
(i) a | bc =⇒ a | c,
(ii) a | c and b | c =⇒ ab | c.
Hint: You may want to use the fact that the Extended Euclidean Algorithm computes s,t ∈ R such
that sa + tb = 1.
3.17 Prove that Z[x] is not a Euclidean domain. Hint: If it were, then we could compute s,t ∈ Z[x]
such that s · 2 + t · x = gcd(2, x), using the Extended Euclidean Algorithm.
3.18∗ Let R = F[x] for a field F and
[
S= (F \ {0})ℓ+1 × (R \ {0})2 × {q ∈ R: deg q > 0, q monic}ℓ−1 .
ℓ≥1
The Euclidean representation of a pair ( f , g) ∈ (R \ {0})2 with deg f ≥ deg g is defined as the list
(ρ0 , . . ., ρℓ , rℓ , q1 , . . ., qℓ ) ∈ S formed from the results of the Euclidean Algorithm. Show that the map
for 1 ≤ i ≤ ℓ.
(vi) Write a M APLE program that implements the traditional Extended Euclidean Algorithm and
additionally computes all continuants ci (qℓ−i+2 , . . ., qℓ ) for r0 = x20 and r1 = x19 + 2x18 + x in Q[x],
where q1 , . . ., qℓ are the quotients in the traditional Extended Euclidean Algorithm.
3.21 (i) Prove Lemma 3.10 (6) for the traditional EEA 3.6. Hint: Since q1 may be constant, it is
wise to start the induction with i = 3 and show the cases i = 1 and i = 2 separately.
(ii) Prove Lemma 3.10 for the Extended Euclidean Algorithm 3.14.
3.22 (i) Show that for polynomials f , g ∈ F[x] of degrees n ≥ m, where F is a field, computing
all entries si in the traditional Extended Euclidean Algorithm from the quotients qi takes at most
2m2 + 2m additions and multiplications in F. Hint: Exhibit the bound for the normal case and prove
that this is the worst case.
(ii) Prove that the corresponding estimate for the Extended Euclidean Algorithm is 2m2 + 3m + 1.
3.23 Prove Lemma 3.12. Hint: Use Lemma 3.8 and Exercise 3.15.
3.24∗ Prove Theorem 3.13.
3.25∗ We consider the following recursive algorithm for computing the gcd of two integers.
A LGORITHM 3.17 Binary Euclidean Algorithm.
Input: a, b ∈ N>0 .
Output: gcd(a, b) ∈ N.
1. if a = b then return a
2. if both a and b are even then return 2 · gcd(a/2, b/2)
3. if exactly one of the two numbers, say a, is even then return gcd(a/2, b)
4. if both a and b are odd and, say, a > b, then return gcd((a − b)/2, b)
(i) Run the algorithm on the examples of Exercise 3.11.
(ii) Prove that the algorithm works correctly.
(iii) Find a “good” upper bound on the recursion depth of the algorithm, and show that it takes
O(n2 ) word operations on inputs of length at most n.
(iv) Modify the algorithm so that it additionally computes s,t ∈ N such that sa + tb = gcd(a, b).
66 3. The Euclidean Algorithm
3.26∗ Adapt the algorithm from Exercise 3.25 to polynomials over a field. Hint: Start with F2 [x].
3.27 Let Fn and Fn+1 be consecutive terms in the Fibonacci sequence. Show that gcd(Fn+1 , Fn ) = 1.
3.28 (i) Prove the formula
1
Fn = √ (φn+ − φn− ) for n ∈ N (10)
5
√
for the
√ Fibonacci numbers, where φ+ = (1 + 5)/2 ≈ 1.618 is the golden √ ratio and φ− = −1/φ+ =
(1 − 5)/2 ≈ −0.618. Conclude that Fn is the nearest integer to φn+ / 5 for all n.
(ii) For n ∈ N>0 , let kn = [1, . . ., 1] be the continued fraction of length n with all entries equal to 1
(Section 4.6). Prove that kn = Fn+1 /Fn , and conclude that limn−→∞ kn = φ+ .
3.29∗ This continues Exercise 3.28.
(i) Let h = ∑n≥0 Fn xn ∈ Q[[x]] be the formal power series whose coefficients are the Fibonacci
numbers. Derive a linear equation for h from the recursion formula for the Fibonacci numbers and
solve it for h. (It will turn out that h is a rational function in x.)
(ii) Compute the partial fraction expansion (Section 5.11) of h and use it to prove (10) again by
employing the formula ∑n≥0 xn = 1/(1 − x) for the geometric series and comparing coefficients.
3.30∗ In the least absolute remainder variant of the Euclidean Algorithm for integers (Exercise
3.13), all quotients qi (with the possible exception of q1 ) are at least two in absolute value. Thus
the nonnegative integers with the largest possible number of division steps in this variant, that is, the
analog of the Fibonacci numbers in Lamé’s theorem, are recursively defined by
G0 = 0, G1 = 1, Gn+1 = 2Gn + Gn−1 for n ≥ 1.
(i) Find a closed form expression similar to (10) for Gn . Hint: Proceed as in Exercise 3.29.
(ii) Derive a tight upper bound on the length ℓ of the least absolute remainder Euclidean Algorithm
for two integers f , g ∈ N with f > g in terms of log g, and compare it to (8).
3.31∗ For n ∈ N, let Fn be the nth Fibonacci number, with F0 = 0 and F1 = 1. Prove or disprove that
the following properties hold for all n, k ∈ N.
(i) Fn+k+1 = Fn Fk + Fn+1 Fk+1 ,
(ii) Fk divides Fnk ,
(iii) gcd(Fnk+1 , Fk ) = 1 if k ≥ 1 (hint: Exercise 3.27),
(iv) Fn rem Fk = Fn rem k if k ≥ 1,
(v) gcd(Fn , Fk ) = gcd(Fk , Fn rem k ) if k ≥ 1 (hint: Exercise 3.16),
(vi) gcd(Fn , Fk ) = Fgcd(n,k) .
(vii) Conclude from (i) that Fn can be calculated with O(log n) arithmetic operations in Z.
(viii) Generalize your answers to Lucas sequences (Ln )n≥0 of the form L0 = 0, L1 = 1, and Ln+2 =
aLn+1 + Ln for n ∈ N, where a ∈ Z is a fixed constant.
3.32∗ We define the sequence f0 , f1 , f2 , . . . ∈ Q[x] of monic polynomials by
◦ gcd( fn , fn−1 ) = 1 for n ≥ 1,
◦ for every n ≥ 1 the number of division steps in the Euclidean Algorithm for ( fn , fn−1 ) is n, and
all quotients are equal to x.
(i) What are the remainders in the Euclidean Algorithm for fn and fn−1 ? What are the ρi ? Find a
recursion for the fn . What is the degree of fn ?
(ii) What is the connection between the fn and the Fibonacci numbers?
(iii) State and prove a theorem saying that the number of division steps in the Euclidean Algorithm
for the pair ( fn , fn−1 ) is maximal. Make explicit what you mean by maximal.
3.33 Let R be a ring, and f , g, q, r ∈ R[x] with g 6= 0, f = qg + r, and deg r < deg g. Prove that q and
r are unique if and only if lc(g) is not a zero divisor.
Die Musik hat viel Aehnlichkeit mit der Algeber.1
Novalis (1799)
The science of algebra, independently of any of its uses, has all the
advantages which belong to mathematics in general as an object of
study, and which it is not necessary to enumerate. Viewed either as a
science of quantity, or as a language of symbols, it may be made of the
greatest service to those who are sufficiently acquainted with
arithmetic, and who have sufficient power of comprehension
to enter fairly upon its difficulties.
Augustus De Morgan (1837)
J
®m ' B I.K
Q® K ñëð
é<Ë@ B@ AëPðX ÕΪK
Bð ½Ë X é®J
®k úΫ Yg@ ®K Bð
éJ®J
®k
úΫ ¯ñJ ¯ Õæ® JÒK
Ë ¡m Ì '@ àB
.
ÕæB@ P Yg. ú¯ ÉJ
¯ AÒ» I.K
Q®K ½Ë X ÉJ
¯ AÒK@ð
é<Ë@ B@ éÒʪK B
èP Yg àB
. J
®m' B I.K
Q®K éK@ 3
Abū Ja֒far Muh.ammad bin Mūsā al-Khwārizmı̄ (c. 830)
69
70 4. Applications of the Euclidean Algorithm
By standard tricks, such as rerunning the test or choosing a larger data base, this
probability can be made arbitrarily small.
The technique can also be used to test equalities like f · g = h for polynomials
f , g, h, by substituting a random value, or A · B = C for matrices A, B,C, by evalu-
ating at a random vector.
This fingerprinting method can even be applied to problems outside the alge-
braic realm, by “arithmetizing” combinatorial problems. Suppose that one main-
tains a large data base in North America and a mirror image in Europe, by per-
forming all updates on both. Each night, one wants to check whether they indeed
are identical. Sending the whole data base would take too long. So one considers
the data base as a string of words, many gigabytes long, and the (large) number
a whose 264 -ary representation this is. Then one chooses a prime p, computes
a rem p and sends this to the mirror site. The corresponding calculation is per-
formed on the other data base, and the two results are compared. If they disagree,
then the two data bases differ. If they agree, then probably the two data bases
are identical, provided p was chosen appropriately. This can be set up so that the
size of the transmitted message is only logarithmic in the size of the data bases.
Exercise 4.3 asks you to apply this method to the more general problem of string
matching.
Division with remainder of a large number by a small number is easy (Exer-
cise 4.1), and you are familiar with one particularly simple example: the remainder
of a number modulo 9 (or 3) equals the remainder of the sum of its decimal digits.
In particular, the number is divisible by 9 (or 3) if and only if this sum is. Why
does this work? Let a = ∑0≤i<l ai · 10i be the decimal representation of a ∈ N.
Since 10 ≡ 1 mod 9 (and mod 3), we have a ≡ ∑0≤i<l ai · 1i = ∑0≤i<l ai mod 9
(and mod 3) (see Exercise 4.4 for remainders modulo 11).
Computing with remainders of arithmetic expressions modulo some nonzero in-
teger is called modular arithmetic. Given an expression e involving integers and
arithmetic operations +, −, ·, we can compute e modulo some number m very effi-
ciently by first reducing all integers modulo m and then, step by step, performing
an arithmetic operation in Z and immediately reducing the result modulo m again,
as we have done in the examples above. Here is another one:
e = 20 · (−89) + 32 ≡ 6 · 2 + 4 ≡ 12 + 4 ≡ 5 + 4 ≡ 9 ≡ 2 mod 7.
In this way, the intermediate results never exceed m2 . The basic rules for comput-
ing with congruences are
where α = (x mod (x3 + 4x)) ∈ Z5 [x]/hx3 + 4xi. We have done the calculations in
detail in this example to illustrate the principle; later we will suppress the details.
T HEOREM 4.1.
Let R be a Euclidean domain, a, m ∈ R, and S = R/mR. Then a mod m ∈ S is a
unit if and only if gcd(a, m) = 1. In this case, the modular inverse of a mod m can
be computed by means of the Extended Euclidean Algorithm.
P ROOF. We have
If, on the other hand, gcd(a, m) = 1, then the Extended Euclidean Algorithm pro-
vides such s,t ∈ R. ✷
E XAMPLE 4.2. We let R = Z, m = 29, and a = 12. Then gcd(a, m) = 1, and the
Extended Euclidean Algorithm computes 5·29+(−12)·12 = 1. Thus (−12)·12 ≡
17 · 12 ≡ 1 mod 29, and hence 17 is the inverse of 12 modulo 29. ✸
this construction works for any prime power q, namely, there exist irreducible
polynomials in Fq [x] of any degree, and any two irreducible polynomials of the
same degree lead to isomorphic fields.
C OROLLARY 4.6.
Let F be a field, and f ∈ F[x] of degree n ∈ N. One arithmetic operation in
F[x]/h f i, that is, addition, multiplication, or division by an invertible element,
can be done using O(n2 ) arithmetic operations in F . More precisely, we have at
most 4n2 + O(n) operations for a multiplication modulo f and at most 6n2 + O(n)
operations for an inversion modulo f .
C OROLLARY 4.7.
One arithmetic operation in Zm , where m ∈ N>0 and n = λ(m) = ⌊(log2 m)/64⌋+1
is the length of m in the standard representation, can be done using O(n2 ) word
operations.
ϕ(m) = #Z×
m = #{0 ≤ a < m: gcd(a, m) = 1}.
In Section 5.4, we will derive a formula for ϕ(m) when m is arbitrary from the
Chinese Remainder Theorem. Exercise 4.19 discusses the analog of Euler’s totient
function for polynomials over a finite field.
1. { binary representation of n }
write n = 2k + nk−1 · 2k−1 + · · · + n1 · 2 + n0 , with all ni ∈ {0, 1}
bk ←− a
2. for i = k − 1, k − 2, . . . , 0 do
if ni = 1 then bi ←− b2i+1 a else bi ←− b2i+1
3. return b0
i
Correctness follows easily from the invariant bi = a⌊n/2 ⌋ . This procedure uses
⌊log n⌋ squarings plus w(n) − 1 ≤ ⌊log n⌋ multiplications in R, where log is the
binary logarithm and w(n) is the Hamming weight of the binary representation
of n (Chapter 7), that is, the number of ones in it. Thus the total cost is at most
2 log n multiplications. For example, the binary representation of 13 is 1 · 23 +
1 · 22 + 0 · 2 + 1 and has Hamming weight 3. Thus a13 would be computed as
76 4. Applications of the Euclidean Algorithm
((a2 · a)2 )2 · a, using three squarings and two multiplications. If R = Z17 = Z/h17i
and a = 8 mod 17, then we compute 813 mod 17 as
which is much faster than first evaluating 813 = 549 755 813 888 and then divid-
ing by 17 with remainder. This method was already used by Euler (1761). He
calculated 7160 mod 641 by computing 72 , 74 , 78 , 716 , 732 , 764 , 7128 , 7160 = 7128 · 732 ,
reducing modulo 641 after each step. (He also listed, unnecessarily, 73 .) As an-
3
other example, starting from 22 = 28 = 256, we only need two squarings modulo
5
5 · 27 + 1 = 641 to calculate ((28 )2 )2 = 22 ≡ −1 mod 641. This shows that 641
5
divides the fifth Fermat number F5 = 22 + 1, as discovered by Euler (1732/33);
5
see Sections 18.2 and 19.1. Even if we were given the 10-digit number 22 + 1 =
4 294 967 297, it would seem more laborious to divide it by 641 with remainder
rather than to use modular repeated squaring.
There are clever ways of reducing the cost to (1 + o(1)) log n multiplications
(Exercise 4.21), where o(1) goes to zero as n gets large. On the other hand, start-
ing with an indeterminate x and using d multiplications or additions, one can only
compute polynomials of degree at most 2d , and thus ⌈log n⌉ multiplications are
indeed necessary to obtain xn . However, when x is not an indeterminate but from a
well-structured domain, one can sometimes exploit that structure for faster expo-
nentiation algorithms. We will see an example in the iterated Frobenius algorithm
of Section 14.7. Particularly important for cryptographic applications are methods
based on normal bases and Gauß periods in finite fields.
Using this property, we obtain a pretty, elementary proof of the following famous
number-theoretic theorem, which—in a more general form—will have many ap-
plications in factoring polynomials and primality testing (Chapters 14 and 18).
a p = ((a − 1) + 1) p ≡ (a − 1) p + 1 p ≡ (a − 1) + 1 = a mod p,
s f + tg = a. (4)
The set of all real solutions of (4) is a line in the plane R 2 , a one-dimensional
object, that can be written as a sum v + U of a particular solution v ∈ R 2 and the
set U of all solutions of the homogeneous equation
s f + tg = 0. (5)
The following lemma says that this is also true for the set of integral solutions.
Moreover, we can decide whether (4) is solvable over Z, and if so, compute all
solutions with the Extended Euclidean Algorithm. Since the proof is the same, we
state the result for arbitrary Euclidean domains.
78 4. Applications of the Euclidean Algorithm
T HEOREM 4.10.
Let R be a Euclidean domain, a, f , g ∈ R, and h = gcd( f , g).
(ii) If h 6= 0 and (s∗ ,t ∗ ) ∈ R2 is a solution of (4), then the set of all solutions is
(s∗ ,t ∗ ) +U , where
g f
U = R· ,− ⊆ R2
h h
is the set of all solutions to the homogeneous equation (5).
(iii) If R = F[x] for a field F , h 6= 0, (4) is solvable, and deg f + deg g − deg h >
deg a, then there is a unique solution (s,t) ∈ R2 of (4) such that deg s <
deg g − deg h and degt < deg f − deg h.
P ROOF. (i) If s,t ∈ R satisfy (4), then gcd( f , g) divides s f + tg and hence a.
Conversely, we assume that h = gcd( f , g) divides a. The claim is trivial if h = 0;
otherwise we can compute s∗ ,t ∗ ∈ R such that s∗ f + t ∗ g = h, using the Extended
Euclidean Algorithm, and (s,t) = (s∗ a/h,t ∗ a/h) solves (4).
(ii) For (s,t) ∈ R2 , we have, since h 6= 0 and f /h and g/h are coprime, that
f g g −f
(5) ⇐⇒ s = − t ⇐⇒ ∃k ∈ R s=k and t = k ⇐⇒ (s,t) ∈ U.
h h h h
Then also
(4) ⇐⇒ f · (s − s∗ ) + g · (t − t ∗ ) = 0 ⇐⇒ (s − s∗ ,t − t ∗ ) ∈ U.
The situation can be generalized to higher dimensions. The proof of the follow-
ing theorem is left as Exercise 4.24.
T HEOREM 4.11.
Let R be a Euclidean domain, a, f1 , . . . , fn ∈ R, with all fi nonzero, and U the set
of all solutions of the homogeneous equation f1 s1 + · · · + fn sn = 0.
4.6. Continued fractions and Diophantine approximation 79
f1 s1 + · · · + fn sn = a (6)
E XAMPLE 4.12. We can rewrite the Euclidean Algorithm from page 45 for r0 =
126 and r1 = 35 as follows.
r0 126 r2 r0 21
q1 = = = 3, = − q1 = ,
r1 35 r1 r1 35
80 4. Applications of the Euclidean Algorithm
r1 35 r3 r1 14
q2 = = = 1, = − q2 = ,
r2 21 r2 r2 21
r2 21 r4 r2 7
q3 = = = 1, = − q3 = ,
r3 14 r3 r3 14
r3 14 r5 r3
q4 = = = 2, = − q4 = 0.
r4 7 r4 r4
Thus the continued fraction expansion of 126/35 ∈ Q is
126 18 1
= = [3, 1, 1, 2] = 3 + .✸
35 5 1+ 1 1
1+
2
This holds for every continued fraction approximation with c = 1. Of three con-
√
secutive continued
√ fraction approximations, at least one satisfies (7) with c = 5,
and for any c > 5 there are real numbers α that have only finitely many rational
approximations with (7); see Notes 4.6. For comparison, this is about twice as
good as decimal fractions, where we restrict q to be a power of 10 and can achieve
an approximation error of 1/2q.
Polynomial analogs of (7) are discussed in Exercises 4.29 and 4.30. The latter
shows that every power series f has approximations
with polynomials r,t such that deg r, degt ≤ n, for infinitely many n. These are just
certain Padé approximants (Section 5.9).
Table 4.2 shows the rational approximations of π that result from truncating
the continued fraction expansion after the ith component for i = 1, . . . , 5 and the
82 4. Applications of the Euclidean Algorithm
number of correct digits (after the decimal point). Throughout history, people
have grappled with practical problems, in architecture, land surveying, astronomy
etc., that required “squaring the circle”. The Egyptian Rhind Papyrus from about
1650 BC gives the value (16/9)2 ≈ 3.1604. Archimedes (278–212 BC) gave a
method to approximate π , in principle arbitrarily well, using polygons inscribed
10
and circumscribed to a circle; he proved 3 71 < 25 344/8069 < π < 29 376/9347 <
1
3 7 . The Chinese astronomer Tsu Ch’ung-chih (430–501) determined six decimal
digits of π and deduced the approximation 355/113, which was also found by
Adrian Antoniszoon (1527–1607). Lambert (1761) proved that π is irrational,
and Lindemann (1882) proved that it is transcendental. An interesting unsolved
question asks whether the decimal digits of π are uniformly distributed or even
random, in some sense. We do not even know to prove that the digit 1, say, occurs
infinitely often!
Table 4.3 shows some steps in our knowledge about the decimal expansion of π .
Of the records in the 20th century, we only list some where the number of decimal
digits of the number of decimal digits (in the rightmost column) increased. The
current world record is an awesome 10 trillion digits, but is unlikely to stand for
long.
Archimedes c. 250 BC 2
Tsu Ch’ung-chih 5th c. 7
Al-Kāshı̄ 1424 14
van Ceulen 1615 35
Machin 1706 100
William Shanks 1853 527
Reitwiesner 1949 2 035
Genuys 1958 10 000
Daniel Shanks & Wrench 1962 100 265
Guilloud & Bouyer 1973 1 001 250
Kanada, Yoshino & Tamura 1982 16 777 206
Kanada, Tamura et al. 1987 133 554 400
Kanada & Tamura 1989 1 073 740 000
Kanada & Takahashi 1997 51 539 600 000
Kanada & Takahashi 1999 206 158 430 000
Kanada Laboratory 2002 1 241 100 000 000
Yee & Kondo 2011 10 000 000 000 050
William Shanks published a book on his computation of 607 digits, but made
an error at the 528th digit. With a modern computer algebra system the first
100000 digits require just a few keystrokes (evalf[100000](Pi), for example,
in M APLE), and bang! there it is on your screen.
The computation of π to many digits is based on deep mathematics and is only
possible with the help of fast algorithms for high precision integer and floating
point arithmetic, based on the Fast Fourier Transform (Chapter 8) and fast division
4.7. Calendars 83
(Chapter 9). It is a good test for computer hardware, which is routinely performed
on some supercomputers before shipping. Borwein, Borwein & Bailey (1989)
speak from experience:
4.7. Calendars
The tropical year, to which our calendar adheres, is the period of time between
two successive occasions of vernal equinox, the precise point of time in spring
when the sun crosses the celestial equator. The length of the tropical year is about
365d 5h 48′ 45.2′′ , or 365.242190 days. (Actually, the exact value is currently
diminishing by about 0.53 seconds each century, but this shall not bother us here.)
Since the dawn of civilization, people have used calendars to express the regu-
larities of the moon’s rotation around the earth and of the seasons. Lunar calen-
dars divide time into months, where originally each month began with new moon.
Since the length of a lunar month is between 29 and 30 days, lunar calendars are
asynchronous to the year of the seasons. Solar calendars, however, ignore the
moon phases and try to approximate the year of the seasons as closely as possible.
The early Roman calendar was of a mixed lunisolar type. It consisted of origi-
nally 10 and later 12 months, and occasionally one extra month was added in order
to keep in step with the seasons. The Julian calendar, named after Julius Caesar
(and which had been invented by the Egyptian Sosigenes), started on 1 January
45 BC. Since the Romans before Caesar had badly neglected the management of
the calendar, the year 46 BC, the annus confusionis, had 445 days! Caesar used
84 4. Applications of the Euclidean Algorithm
the approximation of 365.25 days for the year and introduced one additional 366th
leap day every four years. Although this approximation is quite close to the exact
length of the tropical year, the Julian calendar was fast by about three days every
400 years.
Towards the end of the 16th century, vernal equinox was on 10 March rather than
on its “correct” date of 21 March. To rectify this, Pope Gregory XIII introduced
the following calendar reform. First, the erroneous calendar gain was fixed by
eliminating the 10 days between 4 October and 15 October 1582. Second, the
leap year rule was modified by turning those years which are divisible by 100 but
not by 400 into normal years; this removed three leap days in 400 years. So, for
example, the years 1700, 1800, and 1900 AD were all normal years, but counting
the year 2000 AD as normal would be the bug of the millennium. This Gregorian
calendar, which is essentially still used today, corresponds to an approximation of
the tropical year as
1 3 97
365 + − = 365 = 365.2425
4 400 400
days. It is too long by about 26.8 seconds a year.
ratio of the two tones involved. Table 4.5 lists some common intervals and their
frequency ratios.
frequency ratio name example
r1 = 2 : 1 octave c–C
r2 = 3 : 2 fifth G–C
r3 = 4 : 3 fourth F–C
r4 = 5 : 4 major third E–C
r5 = 6 : 5 minor third E♭ –C
r6 = 9 : 8 whole tone D–C
tone C D E F G A B c
Pythagorean tuning 1:1 9:8 81:64 4:3 3:2 27:16 243:128 2:1
diatonic tuning 1:1 9:8 5:4 4:3 3:2 5:3 15:8 2:1
TABLE 4.6: Frequency ratios with respect to the base tone C in the diatonic scale.
C♯ D♯ F♯ G♯ A♯
= = = = =
D♭ E♭ G♭ A♭ B♭
C D E F G A B c
Suppose that we want to divide the octave into n equal parts, so that one half-
tone has frequency ratio 21/n , in such a way that each of the pleasant intervals
can be reached with an integral number of half-tone steps. This means that for
i = 1, . . . , 6, the frequency ratio ri from Table 4.5 should be close to 2di /n for some
integer di ; equality would be best, but, for example, there are no integers d, n
such that r2 = 3/2 = 2d/n (Exercise 4.31). Taking logarithms, we have the task of
finding di ∈ N with
di
log ri − (8)
n
1 The Well-Tempered Clavier
4.8. Musical scales 87
1 = log r1 ✻• • • • • • • • • • • • • • •• •• ••
• • • • • • • • • • • • • •
• •••••
• • • • • • • • • • • • • •
•• • • • • • •• • • • • • • • • • • • • •
••••• • •
• ••• • • • • • •
•••••• •
• • • • • • •
•
•
•
•
•
•
•
•
• •
• • • •••••
• • • • • • • • •
•• • • • •••••
•••••• • • •
• • • • • • • • •
•• •• •
• • • •
• • • • ••
• • • • •
• • • • •
•
•
• • •
•
•
•
•
•
• • • • • ••••• • • • • • • • • • •
• • • • • •••••
• • • • • • • • • • •
• • • • • •• •
• • • • • • •
• •• • • • •••••
• •
• • • • • • • • • • •
• •
log r2 • • •• • • •••••• • • • • • • • • • •
• • •••••
• • • • • • • • • •
• • •••••• • • • • • • •
• • • • • • • • • •• • ••
• • • • • • • • • • • • • •
• • ••••• • • • •
log r3 • •••• • •
• •
•
•••••
•••••• •
• • •
• • • •
• • •
• • •
• •
•
•
•
• • • • •
•••••• • • • • • • • • • •
• • • • • • •••••
• • • • • • • • • • • •
log r4 •• • • • •
• • • •• •
• • • • • • • • • • •
log r5 • • • •••••
• • • • • • • • • • •
•• • • • • • • • • ••
• • • • • • • • • •
•• • • •
•••••• • • • • • • • • • •
log r6 •• • • • •••••
• • • • • • • • • • •
• • • •••••• • • • • • • • • • •
••• • • •••••
• • • • • • • • • •
•• • • ••••• • • • • • • • • • • •
• • • •••••
• • • • • • • • • • •
••••• ✲ • • • • • •
0
6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 n
0.02 ✻•
0.01
•
• •
• ••
•
• •••••••••••••••••••••• ✲
0
6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 n
Error in the nth approximation
Section 17.3. Here we solve it graphically: in Figure 4.8 on page 87, we have
a horizontal line at log ri , for the six “pleasant intervals” shown, and the dots
on the vertical line passing through n = 6, 7, . . . , 36 have distance 0, 1/n, 2/n, . . . ,
(n − 1)/n, 1 from the horizontal axis. Inspection reveals a reasonable fit for n = 12;
the lower diagram depicts the quality of the approximations, defined as the sum
over all i of the squares of the distance between log ri and its closest neighbor. For
n = 12, a whole tone is two half-tones, a minor third three, and so on.
Another good fit is at n = 19. Then a whole tone is three “third-tones”, a minor
third is five third-tones, and so on. For example, the tones E♭ and D♯ , which are
distinguished in music sheets, correspond to the same key on the piano (but are
different when played on a violin, say). In a well-tempered 19-tone scale, however,
the minor third E♭ –C is five third-tones, while the augmented second D♯ –C is only
four third-tones.
Notes. 4.1. The fingerprinting technique was invented by Freivalds (1977); an early use
was by the Persian philosopher and scientist Avicenna (980–1037), who apparently verified
his calculations by checking them modulo 9, as did al-Khwārizmı̄ and al-Kāshı̄. DeMillo
& Lipton (1978) apply it to checking equivalence of two arithmetic circuits. Many other
applications in computer science, from universal hashing to probabilistically checkable
proofs, are described in Motwani & Raghavan (1995). The general topic of probabilistic
algorithms is discussed in Section 6.5, and Section 18.4 presents techniques for finding
prime numbers.
4.2. Moore (1896) proved that any finite field is an Fq , as described, for a prime power q,
and coined the term “Galois-field”; the notation GF(q) is quite common.
4.3 and 4.4. The term repeated squaring seems to have been standard in the early 20th
century, since Pocklington (1917) uses it without further explanation (except to say that for
his modular problem one divides with remainder by the modulus after each multiplication).
Bürgisser, Clausen & Shokrollahi (1997) note that repeated squaring for the computation
of an is just Horner’s rule for the binary representation of the exponent n. Knuth (1998),
§4.6.3, discusses at length the topic of addition chains where one tries to minimize the
number of multiplications for an exponentiation. We refer to Mullin, Onyszchuk, Vanstone
& Wilson (1989), von zur Gathen & Nöcker (1997, 1999), Gao, von zur Gathen & Panario
(1998), and Gao, von zur Gathen, Panario & Shoup (2000) for exponentiation in finite
fields.
Euler (1732/33) proved that any prime p dividing Fn satisfies p ≡ 1 mod 2n+2 (Exercise
18.26). He found the factor 641 of F5 as only the second possibility allowed by his con-
dition. In the same five-page paper, he also states Fermat’s little theorem, but saying that
he has no proof and eo autem difficiliorem puto eius demonstrationem esse, quia non est
verum, nisi n + 1 sit numerus primus.2 Our proof is from his later paper Euler (1736b).
Fermat never communicated a proof of his “little theorem”. An unpublished manuscript
of Leibniz from 12 September 1680 (and also Leibniz 1697) contains the first proof of
Fermat’s little theorem; see Mahnke (1912/13), page 38, Vacca (1894), Tropfke (1902),
page 62, and Dickson (1919), Chapter III, pages 59–60. Mahnke considers it likely that
2 I also assume its proof to be rather difficult because it is not true unless n + 1 is prime.
Notes 89
Leibniz found the statement of the theorem himself, but it cannot be completely ruled out
that he had already read Fermat’s Varia Opera, published in 1679.
4.5. Generalizing our single linear Diophantine equation, we may consider a system of
linear Diophantine equations, that is, a matrix F ∈ Rm×n and a vector a ∈ Rm , where R is
a Euclidean domain, and ask for s ∈ Rn satisfying Fs = a. There are variants of Gauss-
ian elimination that allow only elementary unimodular row and column transformations,
that is, permutations, multiplications by units of R, and additions of multiples of one row or
column to another. They transform the original system into an equivalent one, for example,
in Smith or in Hermite normal form, in which solvability of the system and the set of
solutions are easy to determine. For example, the Hermite normal form of a nonsingular
square matrix F ∈ Zn×n is the unique lower triangular matrix H = UF, where U ∈ Zn×n
is unimodular, so that degU = ±1, all diagonal elements of H are positive, and each en-
try below the diagonal is nonnegative and smaller than the diagonal element in the same
column (Exercise 16.7).
Such unimodular transformations correspond to the division steps in the Euclidean Al-
gorithm. For the case of one equation, for example, the Hermite normal form of a one-row
matrix F = ( f1 , . . . , fn ) ∈ R1×n is (h, 0, . . . , 0), where h = gcd( f1 , . . . , fn ), so that computing
the Hermite normal form in this case is the same as computing a gcd. We will encounter
a different type of unimodular “Gaussian elimination” for R = Z in the basis reduction of
Chapter 16.
Finally, we may drop the requirement that the equations be linear and ask whether a
system of polynomial equations in several variables with coefficients in R has a solution,
and if so, look for an explicit description of the set of all solutions. Hilbert’s tenth problem
(see page 587) asks to determine the solvability of a Diophantine equation for R = Z.
Against Hilbert’s intuition, the question turns out to be undecidable, in the sense of Turing.
(See for example Sipser (1997) for the background.) This was proved by Matiyasevich
(1970), who showed that any recursively enumerable set D ⊆ N can be represented as
for some n ∈ N and some polynomial f ∈ Z[x1 , . . . , xn ]. Thus D 6= Ø if and only if there is
some s ∈ N n such that f (s) = 0. By Lagrange’s famous theorem, every nonnegative integer
can be written as a sum of four squares, and hence D 6= Ø if and only if g(t) = 0 has an
integral solution t ∈ Z 4n , where
g = f (y21 + y22 + y23 + y24 , . . . , y44n−3 + y24n−2 + y24n−1 + y24n ) ∈ Z[y1 , . . . , y4n ].
that the continued fraction expansion is periodic for a root of an irreducible quadratic poly-
nomial with integer coefficients; Lagrange (1770a) proved the converse. By relating con-
tinued fractions to certain differential equations, Euler (1737) derived the expansion for e.
In one of his papers on continued fractions, Euler (1762/63) introduces explicit expressions
for our numbers
√ si and ti and proves Lemma 3.8 (iv) and (v). Hurwitz√(1891) showed the
quality 1/ 5q2 of rational approximations, and the optimality of c = 5 in (7). Lagrange
(1798) had proven that any “best” rational approximation comes from a continued frac-
tion. Perron’s (1929) classic explains the rich and interesting theory of continued fractions
in detail; for further reading and references see also Knuth (1998), §4.5.3, and Bombieri &
van der Poorten (1995) give an amusing introduction.
Al-Khwārizmı̄ gives in his Algebra, written around 825, three values for π: 3 17 ≈ 3.1428,
√
10 ≈ 3.16, and 62 832/20 000 = 3.1416. Already the Indian mathematician Āryabhat.a
(c. 530) had obtained the latter. The quote at the beginning of this chapter shows that
al-Khwārizmı̄ was well aware of the inexact quality of these approximations. The word
algorithm is derived from al-Khwārizmı̄’s name, indicating his family’s origin from the
town of Khwarezm, present-day Khiva in Uzbekistan (the old-fashioned “algorism” was
a better transliteration than the anagram of logarithm ). Algebra comes from the word
al-jabr in the title of his algebra book éÊK. A®ÒË@ ð QJ.m.Ì '@ H
. Ak ú¯ QåJjÒË@ H. AJºË@ (al-kitāb
al-mukhtas.ar fı̄ h.isāb al-jabr wa-l-muqābala = The concise book on computing by moving
and reducing terms). Q.g. (jabara) means “to break” and refers to the technique of moving
terms of an equation to the other side so that all resulting terms are positive; he did not allow
negative terms. (The Spanish word algebrista designates both someone who does algebra
or who sets broken bones, as in Cervantes (1615), chapter XV, where one of Don Quixote’s
companions is healed by an algebrista.) éÊK. A®Ó (muqābala) is probably the “reduction” of
equations by subtracting equal quantities on both sides, and these are his two techniques for
solving linear and quadratic equations, the topic of the first part of his book. The influence
of al-Khwārizmı̄’s work on Arab, and later medieval European, mathematics was profound.
Al-Kāshı̄ was chief astronomer at Ulugh Beg’s court in Samarkand. His Instructions
on the circle’s circumference, written around 1424 (see Luckey 1953), is a remarkable
achievement. He presents his calculation of π with great concern about error control,
Newton iteration for square roots with just the required precision, and a conversion of his
hexagesimal result to decimal notation.
Euler (1736a) introduced the symbols π (§638) and e (§171); they became popular
with his Introductio in analysin infinitorum (Euler 1748a), but Gauß (1866) still used a
different notation. π had been used by Jones (1706) and by Christian Goldbach in 1742.
Ludolph van Ceulen (1540–1610) published 20 digits of π in 1596, and his tombstone in
the Pieterskerk in Leiden, Holland, recorded 35 digits. It was lost in the 19th century,
and on 5 July 2000 a reconstruction was ceremoniously installed. Still, tombstones have
not caught on as publication medium. Shanks had calculated 527 digits of π by February
1853, all correct. In March and April 1853, he extended this to 607 digits, incorrectly.
The 2011 record by Yee & Kondo took about one year on a home-brew desktop computer
with about 60 TB of disk space. This impressive achievement is largely due to ingenious
algorithms devised by the Chudnovsky brothers, the Borwein brothers, Richard Brent, and
their collaborators. Hilbert’s (1893) elegant paper proves the transcendence of e and π
on four pages. Berggren, Borwein & Borwein (1997) present a magnificent collection of
writings about π. It is a must for π gourmets, and we used their material liberally.
Exercises 91
There are analogs of continued fractions in the polynomial case. If F is a field, then an
element α of F((x−1 )) or F((x)), the field of formal Laurent series in x−1 or x, respectively,
may be represented by an infinite continued fraction whose initial segments converge to α
with regard to the degree valuation and the x-adic valuation (Section 9.6), respectively.
This is discussed in Exercises 4.29 and 4.30.
4.7. Euler (1737) uses a year of 365d 5h 49′ 8′′ , which is 22.8 seconds longer than our
8
value, to calculate several calendars, including the Julian and Gregorian ones, and 365 33 .
Lagrange (1798), §20, finds several rational approximations to the length of the year, our
four among them, via continued fractions based on a year of 365d 5h 48′ 49′′ , 3.8 seconds
longer than our assumption. He ends his calculations by admonishing the astronomers to
do their homework: comme les Astronomes sont encore partagés sur la véritable longueur
de l’année, nous nous abstiendrons de prononcer sur ce sujet.3 We follow Lagrange’s
modesty.
4.8. Drobisch (1855) first used continued fractions to approximate log(3/2) by rational
numbers in order to divide the octave into equal parts. Ternary continued fractions, studied
by Jacobi (1868), can be used to approximate two irrational quantities simultaneously,
and Barbour (1948) applied them to the tuning problem by approximating log(3/2) and
log(5/4).
Actually, perfectly well-tempered instruments are quite rare. In a piano, the thick chords
for low notes produce anharmonic overtones (“harmonics”). Octaves usually have a ratio
slightly higher than 2 : 1, and on violins a fourth in one octave may have a ratio different
from the same fourth’s ratio in another octave.
Exercises.
4.1 Suppose that on a 64-bit processor you are given a single precision number p with 263 < p < 264 ,
and the words making up a positive multiprecision integer a, say of n words. Give an algorithm that
computes a rem p in O(n) word operations. You may assume that the processor has a double-by-
single-precision division instruction, which takes as input three single precision integers a0 , a1 , p
such that a1 < p and returns single precision integers q, r with a1 · 264 + a0 = qp + r and r < p. Hint:
You have to take care of the leading bit of a.
4.2 Suppose that the two data bases to be compared, as in Section 4.1, are up to 10 GB long and
actually different, and that we use single-precision primes p with 263 < p < 264 . There are at least
1017 such primes (Exercise18.18).
(i) Modulo how many primes can they agree at most?
(ii) If we choose our prime p at random, what is the probability that our test gives an incorrect
“ok”?
4.3∗ You are to apply the fingerprinting technique to string matching . Given are two strings x =
x0 x1 · · ·xm−2 xm−1 and y = y0 y1 · · ·yn−2 yn−1 , say consisting of symbols xi , yi ∈ {0, 1} for all i, of
lengths m < n, respectively. We want to determine whether x occurs as a substring of y. Let zi =
yi yi+1 · · ·yi+m−1 be the substring of length m of y starting at position i, for 0 ≤ i < n − m. Thus the
task is to determine whether x = zi for some i.
(i) Describe a simple algorithm that uses O(mn) symbol comparisons.
(ii) Let a = ∑0≤ j<m xi 2i and bi = ∑0≤ j<m yi+ j 2i be the integers whose binary representation (with
most significant bit right) is x and zi , respectively, and 263 < p < 264 a single precision prime. Give
an algorithm that computes all bi rem p and compares them to a rem p in O(n) word operations.
3 since the astronomers have not yet agreed on the true length of the year, we will refrain from making a recom-
mendation on this subject.
92 4. Applications of the Euclidean Algorithm
(iii) Any match is certainly found by your algorithm. If m ≤ 63k, i < n − m, and p was chosen at
random among the at least 1017 single precision primes (Exercise 18.18), what is the probability that
x 6= yi and yet a ≡ bi mod p (in terms of k)? What is the probability that some such false match is
reported, in terms of k and n? For which k and n is the latter probability below 0.1%?
4.4 Prove that an integer a = ∑0≤i≤l ai · 10i ∈ N is divisible by 11 if and only if the alternating sum
a0 − a1 + a2 − a3 ± · · · + (−1)l al of its decimal digits is.
4.5 Show that for any integer m, congruence mod m is an equivalence relation on Z, and prove (1).
4.6 Let m ∈ N≥1 and f ∈ Zm [x] be monic of degree n. Show that the residue class ring Zm [x]/h f i
has mn elements.
4.7 Is there a b ∈ Z such that 6b ≡ 1 mod 81?
4.8 (i) Let a ∈ N be such that 0 ≤ a < 1000 and the three least significant digits in the decimal
representation of 17a are 001. What is a?
(ii) Same question when the least significant digits are 209.
4.9 Let f = x4 +x3 +2x2 +x +1, g1 = x, and g2 = x3 +x in Q[x]. Compute polynomials t1 ,t2 ∈ Q[x]
such that ti gi ≡ 1 mod f for i = 1, 2, if they exist. Is Q[x]/h f i a field?
4.10 Show that the polynomial f = x3 + x + 1 ∈ F2 [x] is irreducible, and compute the inverses of all
nonzero elements in F8 = F2 [x]/h f i using the Extended Euclidean Algorithm.
4.11 Let g = x5 + x + 1 ∈ F2 [x]. For each of the two polynomials
(i) f = x3 + x + 1, (ii) f = x3 + 1
in F2 [x], do the following. If f mod g is a unit in F2 [x]/hgi, compute its inverse h mod g. If f mod g
is a zero divisor, find a polynomial h ∈ F2 [x] of degree less than 5 such that f h ≡ 0 mod g.
4.12 Prove carefully that R[x]/hx2 + 1i and C are isomorphic fields.
4.13 (i) Find a polynomial f ∈ F7 [x] of degree less than 4 solving the congruence (x2 − 1) · f ≡
x3 + 2x + 5 mod x4 + 2x2 + 1 in F7 [x].
(ii) Show that the residue class ring F343 = F7 [x]/hx3 + x + 1i is a field, and compute the inverse
of x2 mod x3 + x + 1 in F343 .
4.14 (i) Let R be a Euclidean domain and m, f ∈ R. Show that f mod m is a zero divisor (see
page 227) in R/hmi if and only if gcd( f , m) 6= 1 if and only if f mod m is not invertible in R/hmi.
(ii) Give an example of a ring containing nonzero elements that are neither units nor zero divisors.
4.15 Let R be a Euclidean domain and a, b, c ∈ R.
(i) Show that the congruence ax ≡ b mod c has a solution x ∈ R if and only if g = gcd(a, c) di-
vides b. Prove that in the latter case, the congruence is equivalent to (a/g)x ≡ (b/g)x mod (c/g).
(ii) For R = Z and a = 5, 6, 7, determine whether the congruence ax ≡ 9 mod 15 is solvable, and
if so, give all solutions x ∈ {0, . . ., 14}.
4.16∗ The degree sequence of a pair ( f , g) ∈ (F[x] \ {0})2 of nonzero polynomials over a field F is
(deg r0 , deg r1 , . . ., deg rℓ ) ∈ N ℓ+1 , where r0 , r1 , . . ., rℓ are the remainders in the Euclidean Algorithm
for f and g. How many pairs of polynomials ( f , g) ∈ (Fq [x] \ {0})2 over the finite field Fq with
q elements have degree sequence (4, 3, 1, 0)? Generalize your answer for arbitrary given degree
sequences (n0 , n1 , . . ., nℓ ) ∈ N ℓ+1 with n0 ≥ n1 > · · · > nℓ ≥ 0 for ℓ ≥ 1. Hint: Use Exercise 3.18.
For all possible degree sequences with n0 = 3 and n1 = 2, list the corresponding pairs of polynomials
in (F2 [x] \ {0})2 .
4.17∗ This continues Exercise 4.16. Let Fq be a finite field with q elements and n, m ∈ Z with
n ≥ m ≥ 0.
Exercises 93
(i) For two disjoint subsets S, T ⊆ {0, . . ., m − 1}, let pS,T denote the probability that no degree in
S and all degrees in T occur in the remainder sequence of the Euclidean Algorithm for two random
polynomials in Fq [x] of degrees n and m, respectively. Prove that pS,T = q−#S (1 − q−1 )#T .
(ii) For 0 ≤ i < m, let Xi denote the random variable that has Xi = 1 if i occurs in the degree
sequence of the Euclidean Algorithm for two random polynomials in Fq [x] of degrees n and m,
respectively, and Xi = 0 otherwise. Show that X0 , . . ., Xm−1 are independent and prob(Xi = 0) = 1/q
for all i.
4.18∗ Let q be a prime power and n, m ∈ N with n ≥ m > 0. Use Exercise 4.17 to prove the following
statements.
(i) The probability that two random polynomials of degree n and m, respectively, in Fq [x] are
coprime is 1 − 1/q.
(ii) The probability that n2 = n1 − 1 is 1 − 1/q.
(iii) The probability that the degree sequence is normal, that is, ℓ = m + 1 and ni+1 = ni − 1 for
1 ≤ i < ℓ, is (1 − 1/q)m ≥ 1 − m/q.
4.19 Let Fq be a finite field with q elements, f ∈ Fq [x] of degree n > 0, and R = Fq [x]/h f i the
residue class ring modulo f . Then R× , the set of elements of R that have a multiplicative inverse, is
a multiplicative group, and Theorem 4.1 implies that R× = {g mod f : gcd( f , g) = 1}. We denote its
cardinality by Φ( f ) = #R× = #{g ∈ Fq [x]: degg < n and gcd( f , g) = 1}.
(i) Prove that Φ( f ) = qn − 1 if f is irreducible.
(ii) Show that Φ( f ) = (qd − 1)qn−d if f is a power of an irreducible polynomial of degree d.
4.20 Devise a recursive variant of the repeated squaring algorithm 4.8, and also an iterative variant
which proceeds from the low order to the high order bits of the binary representation of n. Trace all
three algorithms on the computation of a45 .
4.21∗ Give a “repeated fourth powering” algorithm that uses 2⌊log4 n⌋ squarings and w4 (n) + 1
ordinary multiplications, where w4 (n) is the number of nonzero digits in the 4-ary representation
of n. Trace your algorithm on the computation of a45 . Generalize your algorithm to a “repeated 2k th
powering” algorithm for k ∈ N>0 .
4.22 Compute 15−1 mod 19 via Euclid and via Fermat.
4.23 Derive (a + b) p ≡ a p + b p mod p for all a, b ∈ Z and prime p from Fermat’s little theorem.
4.24∗ (i) Let R be a Euclidean domain, f1 , . . ., fn ∈ R, and h = gcd( f1 , . . ., fn ). Prove that there
exist s1 , . . ., sn ∈ R such that s1 f1 + · · · + sn fn = h.
(ii) Prove Theorem 4.11.
(iii) Let l = lcm( f1 , . . ., fn ). Show that if R = F[x] for a field F, h 6= 0, and deg a < deg l, then
there exist s1 , . . ., sn ∈ R solving (6) such that deg si < deg l − deg fi .
4.25 Compute integral solutions of the linear Diophantine equations 24s + 33t = 9 and 6s1 + 10s2 +
15s3 = 7.
4.26 (i) Expand the rational fractions 14/3 and 3/14 into finite continued fractions.
(ii) Convert [2, 1, 4] and [0, 1, 1, 100] into rational numbers.
√ √ √ √ √
4.27 Expand each of the following as infinite continued fractions: 2, 2 − 1, 2/2, 5, 7.
4.28 Let R be a Euclidean domain and q1 , . . ., qℓ ∈ R \ 0. Show that
ci+1 (q1 , . . ., qi )
[q1 , . . ., qi ] =
ci+1 (0, q2 , . . ., qi )
for 1 ≤ i ≤ ℓ, where ci is the ith continuant polynomial (Exercise 3.20).
94 4. Applications of the Euclidean Algorithm
4.29∗∗ This exercise assumes familiarity with valuations and formal Laurent series. Let F be a field.
The field F((x−1 )) of formal Laurent series in x−1 consists of expressions of the form
g= ∑ g jx j, gm , gm−1 , . . . ∈ F
−∞< j≤m
for some m ∈ Z. We set deg g = max{ j ≤ m: g j 6= 0}, with the convention that deg 0 = −∞. This
degree function has the usual properties, as the degree of polynomials. In fact, the field F(x) of
rational functions is a subfield of F((x−1 )), and we have deg(a/b) = deg a − deg b for a, b ∈ F[x].
For a Laurent series g, we obtain the continued fraction [q1 , q2 , . . .] of g as follows. Set α1 = g,
and recursively define qi = ⌊αi ⌋ ∈ F[x] and αi+1 = 1/(αi − qi ) for i ∈ N>0 . Here, ⌊·⌋ extracts the
polynomial part, so that deg(αi − qi ) < 0.
(i) Show that deg qi = deg αi for all i ∈ N>0 and deg αi > 0 if i ≥ 2.
(ii) Prove that the continued fraction of a rational function r0 /r1 ∈ F((x−1 )), with nonzero r0 , r1 ∈
F[x], is finite, and that the qi are the quotients in the traditional Euclidean Algorithm for r0 , r1 .
(iii) Let s0 = t1 = 1, s1 = t0 = 0, and si+1 = si−1 − qi si , ti+1 = ti−1 − qiti for i ≥ 1, as in the
traditional Extended Euclidean Algorithm. Prove that the ith convergent ci = [q1 , . . ., qi−1 ] of g is
ci = −ti /si , for all i ≥ 2.
(iv) Show that g = −(ti−1 − αi ti )/(si−1 − αi si ), and conclude that deg(g − ci ) < −2 deg si for all
i ≥ 2. Thus if |h| = 2deg h is the degree valuation of a Laurent series h, then we obtain the analog
|g + ti /si | < |si |−2 of (7).
(v) Now let i ∈ N≥2 , k ≥ n = deg si , r0 = ⌊xn+k g⌋, r1 = xn+k , and ri = si r0 + ti r1 . Conclude
from (iv) that deg ri < k, and show that ri /si ≡ r0 mod xn+k if x ∤ si . (In fact, Lemma 11.3 implies
that q1 , . . ., qi−1 are the first i − 1 quotients and ri is the ith remainder in the traditional Euclidean
Algorithm for r0 , r1 .)
4.30∗∗ This exercise is an analog of Exercise 4.29, now for Laurent series in x rather than in x−1 .
Let F be a field. The field F((x)) of formal Laurent series in x consists of expressions of the form
g= ∑ g jx j, gm , gm+1 , . . . ∈ F
m≤ j<∞
for some m ∈ Z. We let v(g) = min{ j ≥ m: g j 6= 0}, with the convention that v(0) = ∞.
For a Laurent series g, we obtain the continued fraction [q1 , q2 , . . .] of g as follows. Set α1 = g,
and recursively define qi = ⌊αi ⌋ ∈ F[1/x] and αi+1 = 1/(αi − qi ) for i ∈ N>0 . Here, ⌊·⌋ extracts the
part which is polynomial in 1/x, so that v(αi − qi ) > 0, or equivalently, x | (αi − qi ).
(i) Prove that v( f g) = v( f ) + v(g), v(1/g) = −v(g) if g 6= 0, and v( f + g) ≥ min{v( f ), v(g)}, with
equality if v( f ) 6= v(g), hold for all f , g ∈ F((x)).
(ii) Let s0 = t1 = 1, s1 = t0 = 0, and si+1 = si−1 − qi si , ti+1 = ti−1 − qiti for i ≥ 1, as in the
traditional Extended Euclidean Algorithm. Then the si ,ti are polynomials in 1/x. Prove that the ith
convergent ci = [q1 , . . ., qi−1 ] of g is ci = −ti /si , for all i ≥ 2.
(iii) Show that g = −(ti−1 − αi ti )/(si−1 − αi si ), and conclude that v(g − ci ) > −2v(si ) for all
i ≥ 2. Thus if |h| = 2−v(h) is the x-adic valuation of a Laurent series h, then we obtain the analog
|g + ti /si | < |si |−2 of (7).
(iv) Now assume that g ∈ F[[x]] is a power series, let i ∈ N≥2 , and n = −v(si ) ∈ N. Prove that xn si
and xn ti are polynomials of degree at most n, and conclude that there exist polynomials s,t ∈ F[x] of
degree not more than n such that x ∤ s and t/s ≡ g mod x2n+1 .
4.31 Prove that there do not exist integers d, n such that 3/2 = 2d/n .
4.32∗∗ (Sturm 1835) Let f ∈ R[x] have no multiple roots, so that gcd( f , f ′ ) = 1, and determine
f0 = f , f1 = f ′ , f2 , . . ., fℓ , q1 , . . ., qℓ ∈ R[x] similarly as in the traditional Euclidean Algorithm, but
according to the modified rule
qi = fi−1 quo fi , fi+1 = −( fi−1 rem fi )
Exercises 95
for 1 ≤ i ≤ ℓ, with the convention that fℓ+1 = 0. The difference to the traditional Euclidean Algorithm
is the sign of fi+1 ; this corresponds to taking ρ0 = ρ1 = 1 and ρi = −1 for 2 ≤ i ≤ ℓ in the Extended
Euclidean Algorithm 3.14. The polynomials f0 , f1 , . . ., fℓ form the Sturm chain of f . For each
b ∈ R, let w(b) be the number of sign alternations in the sequence f0 (b), . . ., fℓ (b). Here, a sign
alternation occurs when either fi (b) < 0, fi+1 (b) ≥ 0 or fi (b) > 0, fi+1 (b) ≤ 0. Prove Sturm’s
theorem, which says that for all b, c ∈ R such that f (b) 6= 0 6= f (c) and b < c, the number of real
roots of f in the interval (b, c) is w(b) − w(c). Hint: It is sufficient to prove the theorem for intervals
containing at most one zero of all the fi ’s. Show that w does not change at a zero of some fi with
i > 0, but that w drops by one at a zero of f0 = f .
4.33 Let F be a field.
(i) Show that a polynomial f ∈ F[x] of degree 2 or 3 is irreducible if and only if it has no roots
in F.
(ii) For each of the two fields F = Q and F = F2 , find a polynomial of degree 4 that is reducible
and has no roots in F.
All is fair in war, love, and mathematics.
Eric Temple Bell (1937)
These [results] must not be taken on trust by the student, but must be
worked by his own pen, which must never be out of his hand while
engaged in any algebraical process.
Augustus De Morgan (1831)
1 When controversies arise, there will not be a greater dispute between two philosophers than between two com-
puters. It will be sufficient for them to take pen in hand, sit down with their calculators, and (having summoned
a friend, if they like) say to each other: Let us calculate.
5
Modular algorithms and interpolation
97
98 5. Modular algorithms and interpolation
modular
problem reduction problem
✲
in R in R/hmi
direct modular
computation computation
❄ ❄
solution ✛ solution
in R reconstruction in R/hmi
modular
reduction ✿ R/hpr i
modular
reduction
... .
R ✲ R/hmi
..
❥
R/hp1 i
❄ ..
✙ .
R ✛ R/hmi ② .. .
reconstruction
❄
reconstruction R/hpr i
modular modular
reduction reduction
R ✲ R/hpl i ✲ R/hpi
direct modular
computation computation
❄ ❄
R ✛ R/hpl i ✛ R/hpi
reconstruction lifting
Z[x] of degree at most n has coefficients not much larger than the input polyno-
mials, but the intermediate coefficients in Euclid’s algorithm may be longer by
a factor of about n than the inputs, and by a factor of about n2 for the traditional
Euclidean Algorithm. When computing in a modular fashion, we may choose
the moduli mi such that their product is only slightly larger than the final result,
and by reducing modulo the mi where possible, also the intermediate results in
the modular computation remain as “small” as the final result.
◦ The designer of a modular algorithm is free in her choice of the moduli, as long
as their product is large enough to recover the result. Thus she may choose
the moduli to be Fourier primes which support particularly fast polynomial
arithmetic; these will be discussed in Chapter 8.
◦ In nearly all tasks in computer algebra, the cost for solving a problem with
input size n is at least linear in n. For example, if we use the algorithms for
integer and polynomial arithmetic as described in Chapters 2 and 3, then one
arithmetic operation on integers of length n or on polynomials of degree n takes
O(n2 ) operations. In such cases, it is cheaper to solve r “small” problems with
inputs of size about n/r rather than one “big” problem. In the extreme case
n = r, the cost of the modular computation becomes just O(n), but this has to
be balanced against the cost for the change of representation.
◦ If the moduli mi in the small primes approach fit into one machine word of
the target processor, then the cost for an arithmetic operation modulo one mi
amounts to only a few machine cycles.
◦ The r subtasks modulo the distinct small primes are independent of each other
and can be performed in a distributed fashion using r processors or machines
in parallel.
100 5. Modular algorithms and interpolation
As an aside, we note that as long as the direct computation uses only additions
and multiplications, but no divisions, an arbitrary modulus—or arbitrary pairwise
coprime moduli in the “small primes” variant—may be chosen in a modular algo-
rithm.
Besides the big prime method, we discuss in this chapter the theoretical under-
pinnings of the small primes modular algorithm, namely the Chinese Remainder
Algorithm, and two applications: secret sharing and computing the determinant.
We have to wait until Chapter 9 for the tools used in the third variant: Newton
iteration and Hensel lifting. The prime power approach will play a major role in
the polynomial factorization algorithm in Chapter 15. Table 15.5 on page 460 lists
eleven problems for which we will have learnt modular algorithms by then.
We also discuss applications of the Extended Euclidean Algorithm and the Chi-
nese Remainder Algorithm to various kinds of interpolation problems and to par-
tial fraction decomposition.
where m = (x−u0 )(x−u1 ) · · · (x−un−1 ), as basis for all polynomials of degree less
than n in the first case; see the Lagrange interpolation formula (3) below. Some
problems, such as multiplication, are quite easy in appropriate bases of this kind,
while others, like division with remainder, seem to require a representation of the
first type.
For each computational problem, one should examine whether this general-
purpose tool is of use. This involves two questions:
5.2. Evaluation and interpolation 101
We discuss some fundamental tools for these questions in this book: the Chinese
Remainder Algorithm, the Extended Euclidean Algorithm, and Newton iteration
(including Hensel lifting).
It is important to realize the similarity between evaluating a polynomial at a
point u and taking the remainder of an integer modulo a prime p. The former is the
same as taking the remainder modulo x − u, and so the latter can be thought of as
“evaluating the integer at p”. The inverse operation of recovering the coefficients
of a polynomial from its values at several points is interpolation. For integers, this
is afforded by the Chinese Remainder Algorithm, and it is useful to understand this
as “interpolating an integer from its values at several primes”.
Similar representations exist for rational functions and rational numbers. We
will later discuss conversion algorithms: Cauchy interpolation and Padé approxi-
mation for rational functions (Sections 5.8 and 5.9), and rational number recon-
struction (Section 5.10).
The proper choice of representation is vital when dealing with multivariate poly-
nomials. Four important possibilities—dense, sparse, by an arithmetic circuit, or
by a “black box”—are briefly discussed in Section 16.6.
An important application of the general idea of change of representation are the
fast multiplication algorithms in Chapter 8 (based on the FFT). In the three major
problems in Part V, namely Gröbner bases, integration, and summation, the basic
task can be interpreted as transforming a general input into a representation where
the problem at hand is fairly easy to solve.
Thus we can evaluate F at all points ui using 2n2 − 2n operations in F. What about
interpolation?
The Lagrange interpolant
x − uj
li = ∏ ∈ F[x] (2)
0≤ j<n ui − u j
j6=i
102 5. Modular algorithms and interpolation
1.5
l0
l1
1 l2
l3
l4
0.5 l5
-0.5
-1
0 1 2 3 4 5
has the property that li (u j ) is 0 if i 6= j and 1 when i = j; see Figure 5.4. For
arbitrary v0 , . . . , vn−1 ∈ F,
x − uj
f= ∑ vi li = ∑ vi ∏ . (3)
0≤i<n 0≤i<n 0≤ j<n ui − u j
j6=i
is a polynomial of degree less than n such that f (ui ) = vi for all i. The interpolating
polynomial with this degree constraint is unique, since the difference of two such
polynomials has degree less than n and n roots, hence is the zero polynomial.
T HEOREM 5.1.
Evaluating a polynomial f ∈ F[x] of degree less than n at n distinct points u0 , . . . ,
un−1 ∈ F or computing an interpolating polynomial at these points can be per-
formed with O(n2 ) operations in F . More precisely, evaluation takes 2n2 − 2n
operations, and Lagrange interpolation uses 7n2 − 7ny operations.
P ROOF. It remains to prove the claim for interpolation. Let mi = x−ui for all i. We
first compute m0 m1 , m0 m1 m2 , . . . , m = m0 · · · mn−1 . This amounts to multiplying a
monic linear polynomial by a monic polynomial of degree i for 1 ≤ i < n, taking
∑ 2i = n2 − n
1≤i<n
5.3. Application: Secret sharing 103
χ( f ) = ( f mod 11, f mod 13) = (2 mod 11, 7 mod 13) ∈ Z11 × Z13 .
T HEOREM 5.2.
χ is surjective with kernel hmi.
= ∑ (0, . . . , 0, vi mod mi , 0, . . . , 0) = v.
0≤i<r
P ROOF. Theorem 5.2 and the homomorphism theorem for rings (Section 25.2)
imply (6). For f ∈ R, we have
f is invertible modulo m ⇐⇒ gcd( f , m) = 1 ⇐⇒ gcd( f , mi ) = 1 for 0 ≤ i < r
⇐⇒ f is invertible modulo mi for 0 ≤ i < r,
and the second claim follows. ✷
106 5. Modular algorithms and interpolation
The proof of Theorem 5.2 is constructive and yields the following algorithm.
1. m ←− m0 · · · mr−1
2. for i = 0, . . . , r − 1 do
compute m/mi
call the Extended Euclidean Algorithm 3.14 to compute si ,ti ∈ R with
m
si + ti mi = 1
mi
ci ←− vi si rem mi
m
3. return ∑ ci
0≤i<r mi
E XAMPLE 5.5. (i) We let R = Z, mi = pei i for 0 ≤ i < r, where the pi ∈ N are
distinct primes and ei ∈ N>0 for 0 ≤ i < r. Then
m= ∏ pei i
0≤i<r
and for arbitrary v0 , . . . , vr−1 ∈ Z the CRA computes a solution f ∈ Z of the system
of congruences
f ≡ vi mod pei i for 0 ≤ i < r.
For example, we take r = 2, m0 = 11, m1 = 13, and m = 11 · 13 = 143, and find
for v0 = 2 and v1 = 7 an f ∈ Z with 0 ≤ f < m and
s0 = 6 and s1 = −7. The Lagrange interpolants l0 and l1 from Theorem 5.2, which
do not occur explicitly in the algorithm, are l0 = 6 · 13 = 78 and l1 = (−7) · 11 =
−77, and we check that in fact l0 ≡ 1 mod 11, l0 ≡ 0 mod 13, l1 ≡ 0 mod 11, and
l1 ≡ 1 mod 13. Now
c0 = v0 s0 rem m0 = 2 · 6 rem 11 = 1,
c1 = v1 s1 rem m1 = 7 · (−7) rem 13 = 3.
Finally, in step 3 we compute
m m
f = c0 + c1 = 1 · 13 + 3 · 11 = 46,
m0 m1
and indeed 46 = 4 · 11 + 2 = 3 · 13 + 7.
(ii) We let R = F[x] for a field F and mi = x − ui for 0 ≤ i < r, where u0 , . . . , ur−1
in F are pairwise distinct. Then f ≡ f (ui ) mod (x − ui ) for 0 ≤ i < r and arbitrary
f ∈ F[x], by Section 4.1, and hence the ring homomorphism
χ: F[x] −→ F[x]/hx − u0 i × · · · × F[x]/hx − ur−1 i ∼
= Fr
f 7−→ ( f (u0 ), . . . , f (ur−1 ))
from Theorem 5.2 is just the evaluation homomorphism (4) at u0 , . . . , ur−1 . (The
ring F r consists of the r-tuples with entries from F, and the ring operations are
done coordinatewise.) Moreover, the li from the proof of Theorem 5.2 satisfying
li ≡ li (ui ) = 1 mod (x − ui ),
li ≡ li (u j ) = 0 mod (x − u j ) for j 6= i
and deg li < r are the Lagrange interpolants
x − uj
li = ∏ .
0≤ j<r ui − u j
j6=i
With R = Z and the mi as in (i) of the above example, we obtain the following
formula for Euler’s totient function from (2) of Section 4.2 and the Chinese Re-
mainder Theorem. Exercise 5.28 gives the corresponding formula for polynomials
over a finite field.
C OROLLARY 5.6.
If m = pe00 · · · per−1
r−1
, with distinct primes p0 , . . . , pr−1 ∈ N and e0 , . . . , er−1 ∈ N>0 ,
then
e0 −1 er−1 −1 1
ϕ(m) = (p0 − 1)p0 · · · (pr−1 − 1)pr−1 = m · ∏ 1− .
p|m, p prime
p
T HEOREM 5.7.
Let R = F[x] for a field F , m0 , . . . , mr−1 , m ∈ R as in (5), di = deg mi ≥ 1 for 0 ≤
i < r, n = deg m = ∑0≤i<r di , and vi ∈ R with deg vi < di . Then the unique solution
f ∈ F[x] with deg f < n of the Chinese Remainder Problem
operations.
We fix i ∈ {0, . . . , r − 1} in step 2. The Extended Euclidean Algorithm with
input m/mi and mi takes O(di (n − di )) operations (Theorem 3.16). By the degree
formula for si (Lemma 3.15 (b)), we have deg si < deg mi = di , and hence the
multiplication of vi and si , together with the subsequent division with remainder
5.5. Modular determinant computation 109
by mi , takes O(di2 ) operations. So we have O(di n) operations for each i, and O(n2 )
for step 2.
Finally, in step 3 we need O(di (n − di )) operations for the multiplication of ci
and m/mi for 0 ≤ i < r, and O(rn) for the addition of all the products (their degree
is strictly less than n). This gives a cost of O(n2 ) for step 3, and also a total cost of
O(n2 ) for the whole algorithm. ✷
The following is the integer analog of Theorem 5.7; see Exercise 5.29.
T HEOREM 5.8.
Let R = Z, m0 , . . . , mr−1 , m ∈ N as in (5), n = ⌊log2 m/64⌋ + 1 the word length
of m, and vi ∈ Z such that 0 ≤ vi < mi for 0 ≤ i < r. Then the unique solution
f ∈ Z with 0 ≤ f < m of the Chinese Remainder Problem
∗
..
. ∗
∗
(k) (k)
akk · · · ak j · · ·
.. ..
0 . .
.. ..
. .
(k) (k)
aik · · · ai j · · ·
.. ..
. .
The table represents the matrix after k − 1 pivoting stages, a “∗” denotes an arbi-
trary rational number, and the upper diagonal entries are nonzero. The diagonal
110 5. Modular algorithms and interpolation
(k)
element akk 6= 0 is the new pivot element, and the entries of the kth column below
the pivot element must be made zero in the kth stage by subtracting an appropriate
multiple of the kth row. The entries of the matrix for k < i ≤ n and k ≤ j ≤ n
change according to the formula
(k)
(k+1) (k) aik (k)
ai j = ai j − a .
(k) k j
(8)
akk
(1)
The entries ai j = ai j are the entries of the original matrix A. If bk is an upper
(k)
bound for the absolute value of the numerators and denominators of all ai j for
1 ≤ i, j ≤ n, so that in particular |ai j | ≤ b1 for 1 ≤ i, j ≤ n, then the formula (8)
gives
2 k−2 k−1 k−1
−1)/3 4k−1
bk ≤ 2b4k−1 ≤ 21+4 b4k−2 ≤ · · · ≤ 21+4+···+4 b14 = 2(4 b1 ,
which is an exponentially large upper bound in the input size n2 λ(b1 ) ≈ n2 log264 b1
(see Sections 2.1 and 6.1 concerning the length λ). At this point, we may won-
der whether Gaussian elimination indeed uses polynomial time, if we count word
operations. In fact, the length of the intermediate results and the number of word
operations for Gaussian elimination over Q are polynomial in the input size, but
the proof is nontrivial. We use an alternative approach to reach the same goal,
a polynomial time algorithm for computing det A. This illustrates modular compu-
tation in a simple case, and introduces some tools of more general interest.
The simplest way of obtaining a polynomial-time computation for the determi-
nant d = det A of a matrix A ∈ Z n×n is to choose a prime p which is guaranteed to
be bigger than 2|d|, perform Gaussian elimination on A mod p ∈ Z pn×n to calculate
d mod p, and represent this value in the “symmetric” system
p−1 p−1
− ,..., (9)
2 2
of representatives (if p is odd; see Section 4.1). If r ∈ Z is this representative, then
p p
r ≡ d mod p, − <r< .
2 2
The congruence holds since any polynomial expression like the determinant com-
mutes with the canonical homomorphism Z −→ Z p (Section 25.3); so that the
determinant, taken modulo p, of A equals the determinant in Z p of the matrix
(A mod p) ∈ Z pn×n whose entries are those of A, taken modulo p. It follows that p
divides d − r,
p p
|d − r| ≤ |d| + |r| < + = p,
2 2
and hence d = r.
5.5. Modular determinant computation 111
1
The word length λ(C) of the bound C = nn/2 Bn on | det A| is about 64 log2 C =
1 1 2
64 n( 2 log2 n + log2 B), and thus polynomial in the input size n λ(B), and we will
see in Section 18.4 that a prime p between, say, 2C and 4C can be found easily
with a probabilistic polynomial-time algorithm. Then arithmetic modulo p can
be performed in polynomial time, in fact, with O(log2 C) word operations. All
entries of A are less than p in absolute value, and nothing happens computationally
in reducing them modulo p. Thus the cost of the algorithm is O(n3 ) operations
modulo p, which shows that the determinant of an integer matrix can be computed
with
O(n3 · n2 (log n + log B)2 ) or O∼ (n5 log2 B) (11)
word operations, where the O∼ notation ignores logarithmic factors (Section 25.7).
This is polynomial time, but not cubic (in n)! Using the fast integer arithmetic of
112 5. Modular algorithms and interpolation
Part II, the running time can be reduced to O∼ (n4 log B); this is softly quadratic
in the input size. Well, should we call the running time of Gaussian elimination
quadratic, cubic, quartic, or quintic?
The algorithm indicated above is not much progress over Gaussian elimination
in Q, except that we could easily prove that it works in polynomial time. The
really big idea, however, is not to compute with a single modulus, but with several
moduli at a time: small primes modular computation. These primes can then be
chosen very small, of only logarithmic length, and the main cost of the resulting
algorithm are many small Gaussian eliminations, which can be performed in a
parallel or even distributed fashion. This method is much more efficient.
3. for i = 0, . . . , r − 1 do
compute di ∈ {0, . . . , mi −1} such that di ≡ det A mod mi using Gauss-
ian elimination over Zmi
4. call the Chinese Remainder Algorithm 5.4 to determine d ∈ Z of least abso-
lute value with d ≡ di mod mi for 0 ≤ i < r
5. return d
E XAMPLE 5.11. We take the first four prime numbers as moduli and get
For the cost analysis, Theorem 18.10 says that we can calculate the first r
primes using O(r log2 r loglog r) word operations, and that log mi ∈ O(log r) for
all i. (Actually, somewhat fewer than r primes are sufficient, see Exercise 18.21.)
Thus log m = ∑0≤i<r log mi ∈ O(r log r). A single arithmetic operation modulo mi
can be done with O(log2 mi ) or O(log2 r) word operations, and hence the total cost
of all Gaussian eliminations in step 3 is O(n3 r log2 r) word operations. The reduc-
tion of an entry of A modulo one modulus mi takes O(λ(B)λ(mi )) or O(log B·log r)
word operations, by Section 2.4. Therefore the reduction of all entries of A mod-
ulo m0 , . . . , mr−1 in step 2 takes O(n2 log B · r log r) word operations. The cost for
step 4 is O(r2 log2 r) word operations, by Theorem 5.8, and dominates the cost of
step 1. The fact that r ∈ O(n log(nB)) leads to the following theorem, which says
that the small primes approach is faster by about two orders of magnitude than the
big prime algorithm.
T HEOREM 5.12.
The determinant of a matrix A ∈ Z n×n with all entries less than B in absolute value
can be computed deterministically with
word operations.
In practice, one would precompute and store not the first r primes but r single
precision primes close to the word size of the processor (say between 263 and
264 −1 if the word size is 64). Exercise 18.18 shows that there are sufficiently many
such single precision primes for all practical purposes. Then one operation modulo
an mi takes constant time, and the total cost is O(n3 r), plus O(n2 log B · r + r2 ) or
O(nr2 ) for the initial modular reduction and the CRA, where r is about λ(2C) or
O(n log(nB)). In contrast, the cost of the big prime variant is about O(n3 r2 ) word
operations.
Similarly to the integer case, a modular algorithm for computing determinants
of matrices with entries in F[x], where F is a field, can be designed. If the field is
large enough, then this is even easier than the integer case (Exercise 5.32).
E XAMPLE 5.13. We look for a polynomial f ∈ Q[x] of degree less than 4 such
that
f (0) = 0, f ′ (0) = 1, f (1) = 1, f ′ (1) = 0, (15)
Thus the initial segments of the Taylor expansions of f at x = 0 and x = 1 are
v0 = f (0) + f ′ (0)x = x and v1 = f (1) + f ′ (1)(x − 1) = 1, respectively, and the
conditions (15) are equivalent to the congruences
f ≡ x mod x2 , f ≡ 1 mod (x − 1)2 .
Here our moduli are m0 = x2 and m1 = (x − 1)2 , and the Extended Euclidean
Algorithm finds that (−2x + 3)x2 + (2x + 1)(x − 1)2 = 1. Thus s0 = 2x + 1 and
s1 = −2x + 3 in step 2 of the Chinese Remainder Algorithm 5.4,
c0 = v0 s0 rem m0 = x · (2x + 1) rem x2 = x,
c1 = v1 s1 rem m1 = 1 · (−2x + 3) rem (x − 1)2 = −2x + 3,
5.7. Rational function reconstruction 115
and finally
m m
f = c0 + c1 = x(x − 1)2 + (−2x + 3)x2 = −x3 + x2 + x.
m0 m1
C OROLLARY 5.14.
The Hermite interpolation problem (14) can be solved using O(n2 ) arithmetic op-
erations in F .
Now this is a strictly weaker condition, and we will see that it can always be
satisfied, but that there are (exceptional) cases where (16) has no solution.
The following lemma is in a sense the converse of Lemma 3.15 (b), which state
that the si ,ti in the Extended Euclidean Algorithm have small degrees. It says that
any linear combination r = s f + tg of f and g, where f , g, r, s,t ∈ F[x] and the
degrees of r, s,t are “small”, is a multiple of some row r j = s j f + t j g in the EEA.
116 5. Modular algorithms and interpolation
L EMMA 5.15 (Uniqueness of the EEA entries). Let F be a field, f , g, r, s,t ∈ F[x]
with deg f = n, r = s f + tg and t 6= 0, and suppose that
r = αr j , s = αs j , t = αt j .
P ROOF. First, we claim that s j t = st j . Suppose that the claim is false, and consider
the equation
sj tj f rj
= .
s t g r
The coefficient matrix is nonsingular, and we can solve for f in F(x) using Cra-
mer’s rule (Theorem 25.6), obtaining
rj tj
det
r t
f= . (19)
sj tj
det
s t
The degree of the left hand side of (19) is n, while
by Lemma 3.15 (b) and (18), and the degree of the right hand side of (19) is strictly
less than n. Thus we have a contradiction, proving the claim.
Now, Lemma 3.15 (v) implies that s j and t j are relatively prime, and from the
claim we have t j | s j t, so that t j | t. We write t = αt j , where α ∈ F[x], and α 6= 0
since t 6= 0. Then we have st j = s j t = αs j t j , and cancelling t j , we obtain s = αs j .
Finally,
r = s f + tg = α(s j f + t j g) = αr j . ✷
We now show that (17) can be solved by means of the Extended Euclidean Al-
gorithm. We say that a rational function r/t ∈ F(x), with r,t ∈ F[x], is in canonical
form if t is monic and gcd(r,t) = 1. Every rational function has a unique canonical
form.
5.7. Rational function reconstruction 117
T HEOREM 5.16.
Let m ∈ F[x] of degree n > 0 and g ∈ F[x] of degree less than n. Furthermore, let
r j , s j ,t j ∈ F[x] be the jth row in the Extended Euclidean Algorithm for m, g, where
j is minimal such that deg r j < k.
(i) There exist polynomials r,t ∈ F[x] satisfying (17), namely r = r j and t = t j .
If in addition gcd(r j ,t j ) = 1, then r and t also solve (16).
(ii) If r/t ∈ F(x) is a canonical form solution to (16), then r = τ −1 r j and t =
τ −1t j , where τ = lc(t j ) ∈ F \ {0}. In particular, (16) is solvable if and only
if gcd(r j ,t j ) = 1.
C OROLLARY 5.17.
There is an algorithm which decides whether (16) is solvable, and if so, computes
its unique solution using O(n2 ) operations in F .
In the next two sections, several examples will illustrate Theorem 5.16. We will
combine the Chinese Remainder Algorithm for polynomials with rational function
reconstruction to solve various interpolation problems, depicted in Table 5.5. The
problems will be precisely specified below. When the input consists of n items,
we also have a degree constraint on the output which leaves n choices. Then the
polynomial problems always have a solution, and the rational ones typically do,
but not always. The polynomial output in the second and the fourth row is trivially
just the input. The next-to-last column in Table 5.5 can be considered as a special
case of the last column. The third row is the “least common generalization” of the
first two rows and a special case of the last row. The solution of these problems
proceeds in two steps.
◦ First a polynomial solution is computed, by the Chinese Remainder Algorithm.
This was done in the preceding sections.
118 5. Modular algorithms and interpolation
rational function
input moduli polynomial output
output
mi = x − ui , polynomial Cauchy
several values ui distinct interpolation, §5.2 interpolation, §5.8
Taylor expansion Padé approximation,
m = xn §5.9
around 0
rational Hermite
Taylor expansions mi = (x − ui )ei , Hermite
interpolation,
around several ui ui distinct interpolation, §5.6
Exercises 5.42, 5.43
rational function
remainder mod m m arbitrary
reconstruction, §5.7
remainders modulo mi arbitrary, rational CRA,
CRA, §5.4
several mi pairwise coprime Exercise 5.42
◦ Then the required rational solution is calculated, via the Extended Euclidean
Algorithm for the polynomial solution and a problem-specific modulus.
Like polynomial interpolation, Cauchy and Hermite interpolation and Padé ap-
proximation are well-studied problems in numerical analysis. The various desig-
nations illustrate the power of our general approach: people had found each of
these problems interesting and studied them, and only in hindsight can we classify
them as special instances of the single general task “rational CRA”.
Now for any i, r(ui ) = t(ui )vi = t(ui )g(ui ) if and only if r ≡ tg mod (x −ui ), and by
the Chinese Remainder Theorem, Corollary 5.3, (21) is in turn equivalent to (17)
with m = (x − u0 ) · · · (x − un−1 ). The following consequence of Theorem 5.16 on
rational function reconstruction gives a complete answer on existence and unique-
ness of a solution to (20).
C OROLLARY 5.18.
Let F be a field, u0 , . . . , un−1 ∈ F be distinct, v0 , . . . , vn−1 ∈ F , g ∈ F[x] of degree
less than n with g(ui ) = vi for all i, and k ∈ {0, . . . , n}. Furthermore, let r j , s j ,t j ∈
F[x] be the jth row in the Extended Euclidean Algorithm for the polynomials m =
(x − u0 ) · · · (x − un−1 ) and g, where j is minimal such that deg r j < k.
(i) There exist polynomials r,t ∈ F[x] satisfying (21), namely r = r j and t = t j .
If in addition gcd(r j ,t j ) = 1, then r and t also solve (20).
E XAMPLE 5.19. (i) Let F = F5 , and suppose that we want to compute a rational
function ρ = r/t ∈ F5 (x), with r,t ∈ F5 [x] of degree at most one, such that ρ(i) = 2i
for i = 0, 1, 2. Exercise 5.4 computes the interpolating polynomial g = 3x2 + 3x + 1
of degree less than 3. The Extended Euclidean Algorithm for m = x(x−1)(x−2) =
x3 + 2x2 + 2x and g computes
120 5. Modular algorithms and interpolation
j qj ρj rj sj tj
3 2
0 1 x + 2x + 2x 1 0
2
1 x+1 3 x +x+2 0 2
2 x+4 4 x+2 4 2x + 2
3 x+2 4 1 4x + 1 2x2 + 1
4 1 0 x2 + x + 2 3x3 + x2 + x
and from row 2 we get the desired rational function
r2 x+2 3x + 1
ρ= = = ∈ F5 (x).
t2 2x + 2 x+1
Row 3 gives another rational interpolating function, namely
r3 1 3
ρ= = 2 = 2 .
t3 2x + 1 x + 3
Row 4 would yield ρ = r4 /t4 = 0, but this is obviously not an interpolating func-
tion. We have gcd(r4 ,t4 ) = gcd(m,t4 ) = m.
(ii) Let F = Q, n = 3, u0 = 0, u1 = 1, u2 = −1, v0 = 1, v1 = 2, v2 = 2, and suppose
that we are looking for a rational function ρ = r/t ∈ Q(x) satisfying (20) for k = 2.
Making the ansatz r = a1 x + a0 and t = b1 x + b0 and plugging in u0 , u1 , u2 , we
arrive at the linear system
a0 = b0 , a1 + a0 = 2(b1 + b0 ), −a1 + a0 = 2(−b1 + b0 ),
which is equivalent to (21). It simplifies to
a0 = b0 , 2a0 = 4b0 , 2a1 = 4b1 ,
and hence r = 2x, t = x form—up to multiplication by a constant—the unique
solution of (21). However, the rational function
r 2x
ρ=
= =2
t x
does not solve (20) since obviously ρ(u0 ) = ρ(0) 6= 1 = v0 , and hence (20) has no
solution.
The Extended Euclidean Algorithm for m = x(x − 1)(x + 1) = x3 − x and the
interpolating polynomial x2 + 1 yields
j qj ρj rj sj tj
3
0 1 x −x 1 0
1 x 1 x2 + 1 0 1
1 1
2 x −2 x −2 2x
1 1 2
3 x 1 1 2x −2x + 1
4 1 0 − 21 x2 − 12 12 x3 − 21 x
5.9. Padé approximation 121
We see from row 2 that r = x and t = x/2 solves (21), but we are not allowed to
cancel the common factor x since ρ = 2 does not solve (20). ✸
The alternative way of solving (21) via a system of linear equations, as we did
above, works in general but is less efficient than the EEA.
C OROLLARY 5.20.
There is an algorithm that either computes the canonical form solution to (20) or
else certifies that (20) is unsolvable, using O(n2 ) arithmetic operations in F .
C OROLLARY 5.21.
Let g ∈ F[x] have degree less than n ∈ N, k ∈ {0, . . . , n}, and r j , s j ,t j ∈ F[x] be the
jth row in the Extended Euclidean Algorithm for m = xn and g, where j is minimal
such that deg r j < k.
122 5. Modular algorithms and interpolation
j qj ρj rj sj tj
4
0 1 x 1 0
1 x + 3 4 x3 + 2x2 + 3x + 4 0 4
2
2 x 1 x + 2x + 3 1 x+3
2 2
3 x + 2x + 3 4 1 x x + 3x + 1
4 1 0 4x3 + 3x2 + 2x + 1 4x4
is the required solution. In fact, this is a (k, n − k)-Padé approximant to g for all
values of k ≥ 1 and n such that n − k ≥ 2, since g is the formal derivative of the
geometric series 1/(1 − x) = ∑i≥0 xi , and hence g = 1/(x − 1)2 is the formal power
series inverse of (x − 1)2 .
The above table contains other Padé approximants to g: row 1 gives the trivial
(4, 0) approximant r1 /t1 = 4x3 + 3x2 + 2x + 1 and row 2 yields the (3, 1) approx-
imant r2 /t2 = (x2 + 2x + 3)/(x + 3), but row 4 does not give a Padé approximant
since x divides t4 , and in fact r4 /t4 = 0 does not approximate g.
(ii) Let g = x2 + 1 ∈ Q[[x]] and n = 3. Then there is no (2, 1)-Padé approximant
to g. To see why, we assume that there are polynomials r,t ∈ Q[x] of degree at
most 1 such that x ∤ t and r ≡ tg mod x3 . Let t = ax + b, with a, b ∈ F and b 6= 0.
Then
r ≡ (ax + b)(x2 + 1) ≡ bx2 + ax + b mod x3 ,
approximations are so good that in a plot it is hard to tell them apart from the
tangent function. Instead, Figure 5.7 on page 124 shows the difference between
the tangent function and each of the four Padé approximants from Table 5.6 on
the interval (−π /2, π /2). It can be seen that the Padé approximant for k = 5 or 4
is the best one. For example, its approximation error to tan(1.5) ≈ 14.1 is about
0.059, while the Taylor polynomial has an approximation error of about 9.54 at
that point. ✸
Corollary 5.21 yields a decision procedure for Padé approximants: Compute the
appropriate results r j and t j of the Extended Euclidean Algorithm. If their gcd is
one, then r j /t j is the unique (k, n − k)-Padé approximant as in (22), otherwise no
such approximant exists.
124 5. Modular algorithms and interpolation
0.5
Taylor
0.4
Padé k = 7 or 6
0.3 Padé k = 5 or 4
Padé k = 3 or 2
0.2
0.1
0
-0.1
-0.2
-0.3
-0.4
-0.5
-1.5 -1 -0.5 0 0.5 1 1.5
F IGURE 5.7: The difference of tan x to its Padé approximants of order 9 around the origin.
C OROLLARY 5.24.
There is an algorithm that either computes the canonical form solution to (22) or
else certifies that (22) is unsolvable, using O(n2 ) arithmetic operations in F .
This algorithm will be put to use in Chapter 7. Using the fast Euclidean Algo-
rithm from Chapter 11, the running time drops to O(n log2 n loglog n) arithmetic
operations in F.
L EMMA 5.25. Let f , g ∈ N and r, s,t ∈ Z with r = s f + tg, and suppose that
f
|r| < k and 0 < t ≤ for some k ∈ {1, . . . , f }.
k
We let ri , si ,ti ∈ Z for 0 ≤ i ≤ ℓ + 1 be the results of the traditional Extended
Euclidean Algorithm for f , g, with ri ≥ 0 for all i. Moreover, we define j ∈
{1, . . . , ℓ + 1} by
r j < k ≤ r j−1 , (26)
and if j ≤ ℓ, we choose q ∈ N≥1 such that
r j t = rt j + f . (30)
Since t j−1 and t j alternate in sign (Exercise 3.15), so do t j and t ∗j , whence rt ∗j > 0
and
r∗j t − rt ∗j < kt − rt ∗j ≤ f − rt ∗j < f .
126 5. Modular algorithms and interpolation
since r∗j + r j = r j−1 − (q − 1)r j ≥ k > |r| ≥ (−1) j r, by the choice of q. After
dividing by the positive integer r j , we obtain r∗j t − rt ∗j > − f , and the claim follows.
As in the first case, we conclude that s∗j t = st ∗j . Then equation (29) implies
that gcd(s∗j ,t ∗j ) = 1 and t = αt ∗j for some nonzero α ∈ Z, and finally s = αs∗j and
r = αr∗j , as above. ✷
The next theorem is an integer variant of Theorem 5.16. We say that a rational
number r/t ∈ Q, with r,t ∈ Z, is in canonical form if t > 0 and gcd(r,t) = 1.
T HEOREM 5.26.
Let g, m ∈ N with g < m, k ∈ {1, . . . , m}, and r j , s j ,t j ∈ Z be the jth row in the
Extended Euclidean Algorithm for m and g, where j is minimal such that r j < k.
(i) There exist r,t ∈ Z satisfying (25), namely (r,t) = (r j ,t j ) if t j > 0, and
(r,t) = (−r j , −t j ) otherwise. If in addition gcd(r,t) = gcd(r j ,t j ) = 1, then r
and t also solve (24).
(ii) If r/t ∈ Q is a canonical form solution to (24), then either (r,t) = (τ r j , τ t j )
or (r,t) = (τ r∗j , τ t ∗j ), where r∗j , t ∗j are as in Lemma 5.25 and τ = sign(t j ) or
τ = sign(t ∗j ), respectively.
(iv) There is at most one canonical form solution to (24) satisfying |r| < k/2.
(iv) Let both r/t and r∗ /t ∗ be canonical form solutions of (24) with |r| < k/2
and |r∗ | < k/2. Since m divides r − tg and r∗ − t ∗ g, it also divides t ∗ (r − tg) −
t(r∗ − t ∗ g) = rt ∗ − r∗t. However, |r|t ∗ < m/2 and |r∗ |t < m/2, whence rt ∗ = r∗t.
The claim now follows from gcd(r,t) = gcd(r∗ ,t ∗ ) = 1. ✷
We note that t j t ∗j < 0 (Exercise 3.15) and r j , r∗j ≥ 0, and hence the two possible
solutions r j /t j and r∗j /t ∗j of (24) have opposite signs (as rational numbers).
j qj rj sj tj
0 22 1 0
1 2 9 0 1
2 2 4 1 −2
3 4 1 −2 5
4 0 9 −22
For k = 10, we have j = 1, and r1 /t1 = 9/1 is obviously a solution of (24). Now
q = 2, (r1∗ ,t2∗ ) = (r2 ,t2 ) = (4, −2), and |t1∗ | = 2 ≤ 22/10 = m/k, whence (r1∗ ,t1∗ ) is
a second solution of (25). But gcd(r1∗ ,t1∗ ) = 2, and r1∗ /t1∗ = −2 is not a solution
of (24). Thus we have two solutions of (25), but only one of them also solves (24).
For k = 9, we have j = 2, and (r2 ,t2 ) = (4, −2) is a solution of (25), but not
of (24). Here, q = 1 and (r2∗ ,t2∗ ) = (r1 − r2 ,t1 − t2 ) = (5, 3), but |t2∗ | = 3 > 22/9 =
m/k, and hence (r2∗ ,t2∗ ) does not solve (25), so that (25) has a unique solution and
(24) is unsolvable.
If k = 7, however, then j and q are as before, but now |t2∗ | = 3 ≤ 22/7 = m/k,
and r2∗ /t2∗ = 5/3 is the only solution of (24).
128 5. Modular algorithms and interpolation
(iii) Let m = 36 and g = 13. The Extended Euclidean Algorithm for m and g
yields
j qj rj sj tj
0 36 1 0
1 2 13 0 1
2 1 10 1 −2
3 3 3 −1 3
4 3 1 4 −11
5 0 −13 36
and for k = 11 we find that j = 2, (r2 ,t2 ) = (10, −2) solves (25) but not (24), q = 1,
and (r2∗ ,t2∗ ) = (r1 − r2 ,t1 − t2 ) = (3, 3) also solves (25) but not (24). Thus (25) has
two solutions while (24) has none. ✸
Together with the Chinese Remainder Algorithm for integers, Theorem 5.26
leads to a Chinese Remainder Algorithm for rational numbers (Exercise 5.44).
L EMMA 5.29. There exist unique polynomials ci ∈ F[x] with deg ci < ei deg fi for
all i such that
g c1 cr
= e1 + · · · + er . (33)
f f1 fr
P ROOF. We multiply both sides in (33) by f and obtain the linear equation
e e
g = c1 ∏ f j j + · · · + cr ∏ f j j (34)
j6=1 j6=r
with “unknowns” c1 , . . . , cr . (We have already seen in Section 4.5 how to find
polynomial solutions of such equations.) For any i ≤ r, each summand with the
e
possible exception of the ith one is divisible by fiei , whence g ≡ ci ∏ j6=i f j j mod fiei .
Now each f j is coprime to fi and hence invertible modulo fiei , and we obtain
−e j
ci ≡ g ∏ f j mod fiei , (35)
j6=i
It remains to say how to obtain the decomposition (31) from (33). This uses the
following generalization of the Taylor expansion. Let R be a ring (commutative,
with 1) and a, p ∈ R[x] with p monic of degree m > 0 and a of degree less than km,
for some k, m ∈ N. The p-adic expansion of a is
L EMMA 5.30. The p-adic expansion exists uniquely, and it can be computed us-
ing at most (km)2 − km2 operations in R.
For the uniqueness, let a = a∗k−1 pk−1 + · · · + a∗1 p + a∗0 be another p-adic expansion.
Then a∗0 is the remainder and a∗k−1 pk−2 + · · · + a∗1 is the quotient of a on division
by p. By induction, the p-adic expansion of the quotient is unique, and hence so is
the p-adic expansion of a.
The cost for the first division with remainder is 2 deg p(1 + deg a − deg p) ≤
2m2 (k − 1), and hence the total number of operations in R is at most
T HEOREM 5.31.
The partial fraction decomposition (31) exists uniquely, and it can be computed
using O(n2 ) operations in F .
P ROOF. The existence follows from the preceding two lemmas by taking the fi -
adic expansion ci = gi,ei fiei −1 + · · · + gi,2 fi + gi,1 with gi j ∈ F[x] of degree less than
deg fi for all i, j. If
is another partial fraction decomposition of g/ f , with g∗i j ∈ F[x] of degree less than
deg fi for all i, j, then Lemma 5.29 implies that ci = g∗i,ei fiei −1 + · · · + g∗i,2 fi + g∗i,1 for
all i, and the uniqueness of the fi -adic expansion implies that gi j = g∗i j , for all i, j.
To prove the running time bound, we let di = ei deg fi and compute mi = fiei
and vi = g rem fiei , at a cost of O(ndi ) operations in F altogether, for 1 ≤ i ≤ r,
taking in total O(n2 ) operations. Then we perform steps 1 and 2 of the Chi-
nese Remainder Algorithm 5.4 with input m1 , . . . , mr and v1 , . . . , vr to compute
ci ≡ vi ( f /mi )−1 ≡ g( f / fiei )−1 mod mi for all i, taking another O(n2 ) operations,
by Theorem 5.7. Finally, we compute the fi -adic expansion of ci , taking O(di2 )
operations, by Lemma 5.30, for each i. This is dominated by the cost for the first
step, and the claim follows. ✷
−1
m
c2 ≡ v2 = 2(x3 + x2 )−1 ≡ 2 · 2−1 = 1 mod x − 1,
m2
−1
m
c3 ≡ v3 = 2(x3 − x2 )−1 ≡ 2 · (−2)−1 = −1 mod x + 1,
m3
and hence
x3 + 4x2 − x − 2 x + 2 1 −1
4
= 2 + + .
x +x x x−1 x+1
Using the x-adic expansion 1 · x + 2 of x + 2 immediately leads to (32). ✸
Notes. 5.1. A general theory of these representations and conversions for polynomials
and rational functions is in von zur Gathen (1986).
5.2. The Lagrange interpolant was invented in Waring (1779) and Lagrange (1795), page
286.
5.3. The secret sharing scheme is from Shamir (1979). Asmuth & Blakley (1982) propose
using the CRA for fault-tolerant communication, and Rabin (1989) uses interpolation.
5.4. The name of the Chinese Remainder Theorem derives from the Suan-ching (arith-
metic) of Sun-Tsŭ, written about the first century AD. He solves a particular problem
(Exercise 5.15) in verse-form, using the integer versions of the “Lagrange interpolants”
li as in the proof of Theorem 5.2; see Shen (1988) and Ku & Sun (1992). Variants of
the question appear later in Chinese, Indian, and European mathematics, for example in
Schwenter (1636), 3. Auffgab, with moduli 3, 5, 7, and 8. General solutions are due to
Euler (1734/35a, 1747/48), Lagrange (1770b), §25, Gauß (1801), article 32, and Cauchy
(1841).
Euler (1760/61) proved Corollary 5.6 about his totient function, and also that ak ≡ 1
er−1 er−1
mod m when gcd(a, m) = 1 and k = lcm(ϕ(pe00 ), . . . , ϕ(pr−1 )), where m = pe00 · · · pr−1 is
the prime factorization of m (Exercise 18.13); this is also in Gauß (1801), article 92. Since
Gauß (1801), article 38, the notation ϕ is used.
In a more general version of the Chinese Remainder Theorem, the moduli mi are not
required to be pairwise coprime, but only that vi ≡ v j mod gcd(mi , m j ) for all i, j. Under
these conditions solutions exist always and are unique modulo the least common multiple
of all mi (Exercise 5.23).
5.5. Gauß introduced his elimination method for astronomical calculations (Gauß 1809,
article 182; Gauß 1810). Lagrange (1759) presented a similar procedure for 2 × 2 and
132 5. Modular algorithms and interpolation
3 × 3 matrices. Edmonds (1967) and Bareiss (1968) showed that the intermediate results
of Gaussian elimination over Q are polynomially bounded.
The modular determinant computation for polynomial matrices, called the interpolation
method, is already in Mikeladze (1948); see also Faddeev & Faddeeva (1963), Section 49.
Early suggestions for modular computer arithmetic are in Svoboda & Valach (1955), Svo-
boda (1957), and Garner (1959); see Szabó & Tanaka (1967) for a discussion.
5.8. Cauchy (1821) discusses his rational interpolation problem without paying attention
to its solvability. Kronecker (1881a), page 544, was the first to point out the bisher wohl
noch nicht bemerkte Einschränkung der Lösbarkeit der Cauchy’schen Aufgabe1, namely,
that (20) may have no solution (Exercise 5.36).
5.9. The Padé approximation problem derives its name from Padé’s (1892) dissertation. It
is a bit of a misnomer, since Kronecker (1881a) already stated and solved the problem, also
proving the necessary and sufficient conditions for solvability (Corollary 5.21). However,
Kronecker’s approach was purely algebraic (as is ours), while Padé also considered func-
tions like exp(x) and brought these approximations to the attention of numerical analysts.
Jacobi (1846) had given an explicit solution to (23). Frobenius (1881) describes relations
between the various Padé approximants of one power series.
Baker & Graves-Morris (1996) explain in detail the theory of Padé approximants, its
connection with continued fractions, and its application to root and singularity finding,
convergence acceleration, and various other problems in numerical analysis and theoretical
physics. They also discuss the numerical stability of different methods for computing Padé
approximants.
5.10. Theorem 5.26 is essentially in Kaltofen √ & Rolletschek (1989). The existence of a
solution to (25) in the special case where k = ⌊ m⌋ + 1 was shown by Thue (1902).
5.11. The partial fraction decomposition is described in Euler (1748a), §39 ff. and Cauchy
(1821), Chapter XI.
Exercises.
5.1 Let m0 , . . ., mr ∈ N≥2 .
(i) Prove that every nonnegative integer a < m0 · · ·mr has a mixed-radix representation of the
form
a = a0 + a1 m0 + a2 m0 m1 · · · + ar m0 · · ·mr−1 ,
with unique integers ai satisfying 0 ≤ ai < mi for all i. Relate this to the usual p-adic representation
of an integer a, for an integer p > 1.
(ii) Compute the above representation of a = 42 for m0 = 2, m1 = 3, m2 = 2, and m3 = 5.
(iii) What is the analogous mixed-radix representation for polynomials?
5.2∗ Let a = s/t ∈ Q, with coprime s,t ∈ N such that 0 < s < t. With respect to an arbitrary base
p ∈ N≥2 , a has a unique periodic p-adic expansion
a= ∑ ai p−i ,
i≥1
with all ai ∈ {0, . . ., p − 1}. We say that this expansion is purely periodic if there is a positive l ∈ N
such that ai+l = ai for all i ≥ 1, and the least such l is the length of the period. Moreover, we let k ∈ N
be the smallest integer such that the sequence ak+1 , ak+2 , . . . is purely periodic, and call it the length
of the preperiod. For example, the 10-adic representation of 1/6 is 0.16 = 1 · 10−1 + ∑i≥2 6 · 10−i ,
with k = l = 1.
1 constraint on the solvability of Cauchy ’s problem, apparently unnoticed hitherto
Exercises 133
(i) Show that there exist unique t ∗ , u ∈ N with t = ut ∗ such that gcd(p,t ∗ ) = 1 and every prime
divisor of u divides p.
(ii) Prove that the p-adic expansion of a terminates (so that only finitely many ai are nonzero) if
and only if t ∗ = 1.
(iii) Show that the p-adic expansion of a is purely periodic if and only if p and t are coprime, and
that then l = ordt (p), the order of p in the multiplicative group Zt× .
(iv) Prove that l = ordt ∗ (p) and k = min{n ∈ N: u | pn } in the general case.
(v) Conclude that l ≤ ϕ(t ∗ ) < t and k ≤ log2 t.
5.3 Let R be a ring (commutative, with 1) and u ∈ R. Prove that Horner’s rule not only computes the
remainder f (u) of a polynomial f ∈ R[x] of degree n − 1 on division by x − u but also the coefficients
of the quotient ( f − f (u))/(x − u).
5.4 Let F5 = Z5 be the finite field with 5 elements.
(i) Compute a polynomial f ∈ F5 [x] of degree at most 2 satisfying
f (0) = 1, f (1) = 2, f (2) = 4 (37)
(ii) List all polynomials f ∈ F5 [x] of degree at most 3 satisfying (37). How many of degree at
most 4 are there? Generalize your answer to solutions of degree at most n for n ∈ N.
5.5 Let F7 = Z7 be the finite field with 7 elements and m = x(x + 1)(x + 6) = x3 + 6x ∈ F7 [x].
(i) Let J ⊆ F7 [x] be the set of all polynomials h ∈ F7 [x] solving the interpolation problem
h(0) = 1, h(1) = 5, h(6) = 2.
Compute the unique polynomial f ∈ J of least degree.
(ii) Find a surjective ring homomorphism χ: F7 [x] −→ F73 such that ker χ = hmi = {rm: r ∈ F7 [x]},
and compute χ( f ) and χ(x2 + 3x + 2).
(iii) Show that J = f + ker χ = { f + rm: r ∈ F7 [x]}.
5.6 Let r = x3 + x2 ∈ F5 [x].
(i) List all polynomials f ∈ F5 [x] of degree at most 5 satisfying
f (a) = r(a) for all a ∈ F5 . (38)
(ii) How many polynomials f ∈ F5 [x] of degree at most 6 solve (38)?
5.7 (i) Show that ∑ li = 1, where li are the Lagrange interpolants as in (2).
0≤i<n
(ii) Let un ∈ F be another point different from u0 , . . ., un−1 . Show how one can obtain the Lagrange
interpolants l0∗ , . . ., ln−1
∗ , l ∗ corresponding to u , . . ., u from l , . . ., l
n 0 n 0 n−1 .
5.8 Let R be an integral domain, u0 , . . ., un−1 ∈ R, and V = VDM(u0 , . . ., un−1 ) ∈ Rn×n . Prove that
detV = ∏ (ui − u j ).
1≤ j<i≤n
5.11∗ Another possibility to compute the interpolating polynomial of least degree is Newton inter-
polation. Suppose that u0 , . . ., un−1 , v0 , . . ., vn−1 in a field F are given, with distinct u0 , . . ., un−1 , and
let f ∈ F[x] of degree less than n be the interpolating polynomial with f (ui ) = vi for all i. We divide
f by x − u0 with remainder and obtain f = (x − u0 )g + f (u0 ) = (x − u0 )g + v0 for some g ∈ F[x] of
degree deg f − 1. For i ≥ 1, the value of g at ui is g(ui ) = (vi − v0 )/(ui − u0 ), and we can determine
g recursively in the same fashion.
(i) Design an algorithm for Newton interpolation, prove that is works correctly, and analyze its
cost. It is possible to solve the problem with at most 52 n2 operations in F.
(ii) Trace your algorithm on the examples of Exercises 5.4 and 5.5.
(iii) What is the connection to the mixed-radix representation of f , as discussed in Exercise 5.1,
when mi = x − ui for 0 ≤ i < n?
5.12∗ Let F be a field, u0 , . . ., un−1 ∈ F \ {0} with ui 6= ±u j for 0 ≤ i < j < n, and v0 , . . ., vn−1 ∈ F.
(i) Let f ∈ F[x] of degree less than 2n be such that f (ui ) = f (−ui ) for 0 ≤ i < n. Prove that
f (x) = f (−x), so that f is even.
(ii) Use the Lagrange interpolation formula and (i) to show that there is a unique even interpolating
polynomial f ∈ F[x] of degree less than 2n such that f (ui ) = vi for 0 ≤ i < n.
(iii) Let g ∈ F[x] be the unique polynomial of degree less than n such that g(u2i ) = vi for 0 ≤ i < n.
How is the polynomial f from (ii) related to g?
(iv) What are the statements corresponding to (i) through (iii) for odd interpolating polynomials,
provided that ui 6= 0 for all i?
(v) Compute an even polynomial f0 ∈ R[x] of degree at most 4 interpolating the cosine function at
u0 = π/6, u1 = π/3, and u2 = π/2, and an odd polynomial f1 ∈ R[x] of degree at most 5 interpolating
the sine function at those points.
(Euler (1783) stated interpolation formulas for odd and even functions.)
5.13∗ In this exercise, we discuss bivariate interpolation.
(i) Develop an algorithm for computing f ∈ F[x, y], F a field, where the degree of f in y is less
than n and
f (x, ui ) = vi for i = 0, 1, . . ., n − 1,
for distinct ui ∈ F and arbitrary vi ∈ F[x]. Show that f is unique.
(ii) Assuming that the degree of each vi is less than m, what is the computing time of your algorithm
(in terms of m and n)?
(iii) Compute f ∈ F11 [x, y] such that
f (x, 0) = x2 + 7, f (x, 1) = x3 + 2x + 3, f (x, 2) = x3 + 5.
5.14 Let F be a field, f ∈ F[x] of degree less than n, and u0 , . . ., un−1 ∈ F \ {0} distinct. Determine
the set of all interpolation polynomials g ∈ F[x] of degree less than n with g(ui ) = f (ui ) for 0 ≤
i ≤ n − 2. (In the situation of Section 5.3, this represents the knowledge of all players minus player
n − 1.) Let c ∈ F. How many of these g have constant coefficient c? (Your answer should imply that
the secret sharing scheme is secure.)
5.15 What is the least nonnegative integer f with f ≡ 2 mod 3, f ≡ 3 mod 5, and f ≡ 2 mod 7?
5.16 How many common solutions f ∈ Z with 0 ≤ f < 106 do the following congruences possess?
f ≡ 2 mod 11, f ≡ −1 mod 13, f ≡ 10 mod 17.
5.17 Carl Friedrich, Joachim, and Jürgen met at a Sylvester party on Thursday, 31 December 1998.
They agreed to play Skat (a German card game) together some day as soon as all of them find the time
to do so. But they got into the usual troubles: Carl Friedrich was busy except on Fridays, Joachim
had time on 7 January and then again every 9th day, and Jürgen was free on 6 January and then again
every 11th day. Which date did they agree upon?
Exercises 135
5.18 Ernie, Bert, and the Cookie Monster want to measure the length of Sesame Street. Each of
them does it his own way. Ernie relates: “I made a chalk mark at the beginning of the street and
then again every 7 feet. There were 2 feet between the last mark and the end of the street.” Bert tells
you: “Every 11 feet, there are lamp posts in the street. The first one is 5 feet from the beginning,
and the last one is exactly at the end of the street.” Finally, the Cookie Monster says: “Starting at the
beginning of Sesame Street, I put down a cookie every 13 feet. I ran out of cookies 22 feet from the
end.” All three agree that the length does not exceed 1000 feet. How long is Sesame Street?
5.19 (i) Find a polynomial in F5 [x] of degree four which is reducible but has no roots in F5 . Are
there such examples of lower degree?
(ii) Which of the following polynomials in F5 [x] are irreducible, which are reducible?
m0 = x2 + 2, m1 = x2 + 3x + 4, m2 = x3 + 2, m3 = x3 + x + 1.
f ≡ x + 1 mod m0 , f ≡ 3 mod m1
has a solution f ∈ F5 [x], and compute the unique solution of least degree.
5.20 Compute a solution f ∈ F5 [x] of the system of congruences
such that deg f < 5. Hint: First bring each of the congruences into the form f ≡ v mod m for some
v, m ∈ F5 [x], using Exercise 4.15. What is the set of all solutions without the degree constraint?
5.21−→ Let m0 = x2 + 1, m1 = x2 − 1, m2 = x3 + x − 1, v0 = −x, v1 = x + 1, and v2 = x5 − x in
F3 [x].
(i) How many polynomials f ∈ F3 [x] are there with f ≡ vi mod mi for i = 0, 1, 2, and deg f ≤ 8?
Answer this without solving (ii).
(ii) Give a list of all f as in (i).
5.22∗ Let p0 , p1 ∈ N be distinct primes, m = p0 p1 , n ∈ N, and u0 , . . ., un−1 , v0 , . . ., vn−1 ∈ Z.
(i) Show that there exists an interpolating polynomial f ∈ Z[x] such that
f has coefficients in {0, . . ., m − 1}, deg f < n, and f (ui ) ≡ vi mod m for 0 ≤ i < n (39)
if and only if
ui ≡ u j mod pk =⇒ vi ≡ v j mod pk
for 0 ≤ i < j < n and k = 0, 1.
(ii) Show that (39) has a unique solution if and only if ui 6≡ u j mod pk for 0 ≤ i < j < n and
k = 0, 1.
(iii) Compute all interpolating polynomials f ∈ Z[x] with coefficients in {0, . . ., 14}, deg f < 3,
and
f (1) ≡ 2 mod 15, f (2) ≡ 5 mod 15, f (4) ≡ −1 mod 15.
5.23∗ (i) Let R be a Euclidean domain, m0 , m1 ∈ R \ {0}, and v0 , v1 ∈ R. Show that
f ≡ v0 mod m0 , f ≡ v1 mod m1
5.27 Make a list showing all integers m for which ϕ(m) ≤ 10, and prove that your list is complete.
e
5.28 Let Fq be a finite field with q elements and f = f0e0 · · · fr−1 r−1
with f0 , . . ., fr−1 ∈ Fq [x] irreducible
and pairwise coprime and e0 , . . ., er−1 ∈ N>0 . Let n = deg f and ni = deg fi for all i. Recall the analog
Φ of Euler’s totient function (Exercise 4.19). Prove that
1
Φ( f ) = (qn0 − 1)qn0 (e0 −1) · · ·(qnr−1 − 1)qnr−1 (er−1 −1) = qn ∏ 1 − n .
0≤i<r qi
Hint: CRT.
5.29∗ Prove Theorem 5.8.
5.30 Let An = (i j )1≤i, j≤n ∈ Z n×n .
(i) Compute a good upper bound on | det An | in terms of n using Hadamard’s inequality 16.6.
(ii) Compute det A3 with the small primes modular algorithm.
5.31 Use the familiar formula det A = ∑σ∈Sn sign(σ) · a1σ(1) · · ·anσ(n) for the determinant of a
square matrix A ∈ Z n×n , where Sn is the symmetric group of all n! permutations of {1, . . ., n} (Sec-
tion 25.1), to derive an upper bound on | det A| in terms of n and B = max1≤i, j≤n |ai j |. Compare this
to the Hadamard bound, and tabulate both bounds and their ratio for 1 ≤ n ≤ 10.
5.32−→ Let F be a field, n ∈ N>0 , and A = (ai j )1≤i, j≤n ∈ F[x]n×n a square matrix with polynomial
entries. Moreover, let m = max{deg ai j : 1 ≤ i, j ≤ n}.
(i) Find a tight upper bound r ∈ N on deg(det A) in terms of m and n.
(ii) Describe an algorithm for computing det A using a small primes modular approach if the field
F has more than r elements. Hint: Choose linear moduli. How many operations in F does your
algorithm use (in terms of n and m)?
(iii) Use your algorithm to compute the determinant of the matrix
−x + 1 0 2
A= x x + 1 2x ∈ F7 [x]3×3 .
2x 3x + 1 x
(iv) Find a tight upper bound on deg(det A) in terms of the maximal degrees mi in the ith row of A
for 1 ≤ i ≤ n. (Sometimes, this bound or the corresponding bound arising from the maximal column
degrees is better than the bound from (i).)
(v) Using the bound from (iv), compute the determinant of
x−1 x−2 x−3
A = 2x + 1 2x + 3 2x − 2 ∈ F7 [x]3×3 .
x − 1 x + x + 1 (x − 1)2
2 2
5.33∗ The goal of this exercise is to show that nonsingular linear systems over Q can be solved in
polynomial time using a modular approach. Thus let A ∈ Z n×n and b ∈ Z n for some n ∈ N, and
assume that det A 6= 0. Then there is a unique solution x ∈ Q n of the linear system Ax = b, namely
x = A−1 b.
(i) Given a bound B ∈ N on the absolute values of the entries of A and b, show that the numerators
and denominators of the coefficients of x are less than nn/2 Bn in absolute value. Hint: Use Cramer’s
rule 25.6 and Hadamard’s inequality 16.6.
Exercises 137
(ii) We consider the following modular algorithm. Choose a prime p ∈ N greater than 2nn B2n , and
perform Gaussian elimination on A mod p and b mod p. Convince yourself that p ∤ det A. Find a
y ∈ Z n such that y mod p is the unique solution of the modular linear system (A mod p)(y mod p) =
b mod p. Now x ≡ y mod p, and we can reconstruct x from y using rational number reconstruction
(Section 5.10) for each of the coefficients. Prove that this algorithm works correctly.
(iii) Show that the running time of the algorithm is O(n3 log2 p) word operations, or O∼ (n5 log2 B)
when p is close to 2nn B2n .
(iv) Run your algorithm on the matrix A3 from Example 5.30 and the vector b = (1, 1, 1)T .
5.34∗ Given are a positive integer n ∈ N, two polynomials a = ∑0≤i<n ai xi , b = ∑0≤i<n bi xi in
Z[x], and a bound B ∈ N on the coefficients such that |ai |, |bi | ≤ B for 0 ≤ i < n. Moreover, let
ab = c = ∑0≤i<2n ci xi ∈ Z[x].
(i) Find a tight common upper bound on the |ci | in terms of n and B.
(ii) Describe an algorithm for the computation of c using a small primes modular approach.
(iii) Trace your algorithm on the computation of the product of
a = 987x3 + 654x2 + 321x, b = −753x3 − 333x2 − 202x + 815.
5.35−→ Let n + 1 points u0 < u1 < · · · < un in R be given, and v0 , . . ., vn ∈ R arbitrary. You are to
find a twice continuously differentiable function f : [u0 , un ] −→ R which takes the value vi at point ui
and has f ′ (u0 ) = f ′′ (u0 ) = 0, as follows. Construct a sequence of polynomials f0 , . . ., fn ∈ R[x] of
degree at most 3 such that f0 = v0 ,
′
fi (ui−1 ) = fi−1 (ui−1 ), fi′ (ui−1 ) = fi−1 ′′
(ui−1 ), fi′′ (ui−1 ) = fi−1 (ui−1 ), fi (ui ) = vi ,
for 1 ≤ i ≤ n. This amounts to solving a Hermite interpolation problem for each interval [ui−1 , ui ],
with three conditions on fi and its first two derivatives at the left boundary and one condition on fi
at the right boundary. Then f is defined to be equal to fi on the interval [ui−1 , ui ], for all i. Such an
f is called a cubic spline.
(i) Prove that f0 , . . ., fn exist uniquely.
(ii) Compute and draw the cubic spline for the data ui = i for 0 ≤ i ≤ 3, v0 = v3 = 1, v2 = 0, and
v3 = −1.
(iii) In (ii), give various other values to v2 , say −5, −3, −2, −1, 1, 2, 3, 5, 7.
5.36 (Kronecker 1881a, page 546) Let F = Q, n = 4, ui = i + 1 for i = 0, . . ., 3, v0 = 6, v1 = 3,
v2 = 2, v3 = 3. Show that for k = 2, (21) has a unique solution r,t ∈ Q[x] with t monic, while (20) is
unsolvable.
5.37 For 1 ≤ k ≤ 5, try to solve the Cauchy interpolation problem
r
t(i) 6= 0 and (i) = vi for 0 ≤ i ≤ 4, gcd(r,t) = 1 (40)
t
for polynomials r,t ∈ F5 [x] with deg r < k and degt ≤ 5 − k, where the vi are given by the following
table.
i 0 1 2 3 4
vi 1 2 3 2 1
For which values of k is there no solution?
5.38 Let F be a field, u0 , . . ., un−1 ∈ F distinct, v0 , . . ., vn−1 ∈ F, and S = {0 ≤ i < n: vi = 0}. Show
that the Cauchy interpolation problem (20) has no solution if k ≤ #S < n.
5.39 Tabulate all (k, n − k)-Padé approximants to g = x4 + x3 + 3x2 + 1 ∈ F5 [x] for 0 ≤ k ≤ n ≤ 5.
Mark the entries in the table where no approximant exists.
5.40−→ Give all Padé approximants in Q(x) to the exponential function exp(x) = 1 + x + x2 /2 +
x3 /6 + x4 /24 + · · · modulo x5 .
138 5. Modular algorithms and interpolation
5.41 Let F be a field, n ∈ N, g ∈ F[x] of degree less than n, and ℓ ∈ N>0 the number of division
steps in the Euclidean Algorithm for the pair (xn , g).
(i) Show that there are at most ℓ distinct coprime pairs (r,t) ∈ F[x] such that t 6= 0 is monic,
gcd(t, mi ) = 1 and rt −1 ≡ vi mod mi for 0 ≤ i < l, deg r < k, and degt ≤ n − k, (41)
where t −1 is the modular inverse of t modulo mi (Section 4.2). Let g ∈ F[x] be the polynomial
solution of the system of congruences g ≡ vi mod mi for all i. Furthermore, let r j , s j ,t j ∈ F[x] be the
jth row in the Extended Euclidean Algorithm for m and g, where j is minimal such that deg r j < k.
Prove:
(i) There exist polynomials r,t ∈ F[x] satisfying
where A, B,C, D are points in R2 , i ∈ N, and the parameter u runs through the real interval [i, i + 1].
(These curves, and also similar surfaces, were introduced in the late 1960s by Bézier at the Renault
car company, and by de Casteljau at Citroën; see Bézier (1970) and de Casteljau (1985).) A cubic
Bézier spline is a parametric curve on the real interval [0, . . ., n] which is defined by
for u ∈ [i, i + 1] and 0 ≤ i < n, i.e., it is a Bézier curve on each interval [i, i + 1]. The points
A0 , B0 ,C0 , A1 , . . ., An−1 , Bn−1 ,Cn−1 , An ∈ R2 are the control points of the Bézier spline.
(i) Show that the Bézier spline is continuous and passes through the points A0 , . . ., An .
Exercises 139
(ii) Prove that the Bézier spline is continuously differentiable with respect to the parameter u if
and only if Bi − Ai = Ai −Ci−1 for 1 ≤ i < n. Show that in this case, Bi − Ai is the tangent vector to
the curve at the point Ai for 0 ≤ i < n. What is the tangent vector at the point An ?
(iii) Consider the following control points for n = 4:
i 0 1 2 3 4
Ai (−1.8, 0) (−3.8, 8.5) (0, 12.8) (3.8, 8.5) (1.8, 0)
Bi (−1.8, 2) (−3.8, 11.17) (2, 12.8) (3.8, 5.83)
Ci (−3.8, 5.83) (−2, 12.8) (3.8, 11.17) (1.8, 2)
The corresponding Bézier spline models the inner boundary of the uppercase greek letter Ω. Plot this
Bézier spline. Is it continuously differentiable? Is it twice continuously differentiable?
(iv) Prove that for arbitrary points A0 , . . ., An ∈ R2 , there exists a Bézier spline passing through
these points that is twice continuously differentiable with respect to the parameter u. Show that there
is a unique such spline if B0 and C0 are prescribed as well. Hint: Exercise 5.35.
The mathematician’s pattern, like a painter’s or the poet’s, must be
beautiful. [. . . ] Beauty is the first test; there is no permanent place
in the world for ugly mathematics.
Godfrey Harold Hardy (1940)
1 Furthermore, it is an error to believe that rigor in proof is an enemy of simplicity. On the contrary we find it
confirmed by numerous examples that the rigorous method is at the same time the simpler and the more compre-
hensible one. The very effort for rigor forces us to find simpler proof methods.
2 The mathematician is perfect only in so far as he is a perfect being, in so far as he perceives the beauty of truth;
only then will he appear to be thorough, transparent, comprehensive, pure, clear, gracious, and even elegant.
6
The resultant and gcd computation
We start this chapter with a typical example illustrating the growth of coefficients
in the Euclidean Algorithm for polynomials over Q. Much of the rest of this
chapter is devoted to getting a handle on this growth. As an application, we obtain
modular algorithms for the gcd in Q[x] and F[x, y] for a field F; these are much
more efficient than the direct computation.
Gauß’ lemma in Section 6.2 illuminates the non-obvious relation between gcds
of integer polynomials in Z[x] and Q[x]. We then introduce the resultant, which
gives control over the Bézout coefficients s and t in the presentation s f + tg =
gcd( f , g). This yields a modular gcd calculation for bivariate polynomials, and,
together with Mignotte’s factor bound, also for integer polynomials. Section 6.10
discusses the more general subresultants, which govern the coefficient growth in
the whole Extended Euclidean Algorithm, and provide a modular approach to the
EEA.
In between, we digress to two applications: computing the intersection points
of two plane algebraic curves, and an unexpectedly efficient way of computing the
gcd of many polynomials.
ρ0 r0 = f , ρ0 s0 = 1, ρ0t0 = 0,
ρ1 r1 = g, ρ1 s1 = 0, ρ1t1 = 1,
ρ2 r2 = r0 − q1 r1 , ρ2 s2 = s0 − q1 s1 , ρ2t2 = t0 − q1t1 ,
.. .. ..
. . . (1)
ρi+1 ri+1 = ri−1 − qi ri , ρi+1 si+1 = si−1 − qi si , ρi+1ti+1 = ti−1 − qiti ,
.. .. ..
. . .
0 = rℓ−1 − qℓ rℓ , sℓ+1 = sℓ−1 − qℓ sℓ , tℓ+1 = tℓ−1 − qℓtℓ ,
141
142 6. The resultant and gcd computation
with deg ri+1 < deg ri for all i ≥ 1. Thus ri−1 = qi ri + ρi+1 ri+1 is the division of
ri−1 by ri with remainder ρi+1 ri+1 ; the leading coefficient ρi+1 serves to have a
normalized remainder ri+1 . A basic invariant is ri = si f +ti g. We define the degree
sequence (n0 , n1 , . . . , nℓ ) by ni = deg ri for all i. Then
n = n0 ≥ n1 > n2 · · · > nℓ ≥ 0.
It is convenient to set ρℓ+1 = 1, rℓ+1 = 0, and nℓ+1 = −∞. The number of arithmetic
operations in F performed by the (Extended) Euclidean Algorithm for f and g is
O(nm) (Theorem 3.16).
In order to get a bound on the number of word operations of Euclid’s algorithm
over F = Q, we need to get a bound on the length of the numbers involved in the
computation. We extend the definition of the length of an integer from Section 2.1
to rational numbers and polynomials with rational coefficients. We bring all coef-
ficients of a polynomial a ∈ Q[x] to a common denominator, and then λ(a) is the
maximal number of words required to encode the denominator or a coefficient of
the numerator of a. More precisely, we use
◦ λ(a) = ⌊(log2 |a|)/64⌋ + 1, when a ∈ Z \ {0}, and λ(0) = 0,
◦ λ(a) = max{λ(b), λ(c)}, if a = b/c ∈ Q \ {0} with b, c ∈ Z and gcd(b, c) = 1,
◦ λ(a) = max{λ(a0 ), . . . , λ(an ), λ(b)}, when a = ∑0≤i≤n ai xi /b ∈ Q[x] with all
ai ∈ Z and b ∈ N≥1 such that gcd(a0 , . . . , an , b) = 1.
Thus a can be represented with about λ(a)(2 + deg a) words. Then for a, b ∈ Z[x]
and c, d ∈ Q, we have
an−1 d − bm−1 c
q = x+ , λ(q) ≤ λ(a) + λ(b) + 1,
cd
acd 2 − xbcd 2 − (an−1 d − bm−1 c)bd
ρr = a − qb = ,
cd 2
λ(ρr) ≤ λ(a) + 2λ(b) + 3,
and the latter estimate also holds for λ(r) since the cd 2 in the denominator of ρr
and the numerator of 1/ρ cancel. Assuming that λ(a) ≤ λ(b), we see that the
6.1. Coefficient growth in the Euclidean Algorithm 143
coefficient size grows at most by a factor of about 3 in one division. Some exper-
iments with pseudorandom polynomials of degree n = 10 and with 10, 100, and
1000 decimal digit coefficients indicate that this is essentially sharp: the average
length ratio between the remainder coefficients and those of the input was 2.92,
2.998, and 2.9999, respectively, for 10 experiments each.
In a typical execution of the Euclidean Algorithm, the degrees of all the quotient
polynomials will be 1. From the above worst-case estimate, we find that λ(rℓ ) ∈
O(3ℓ · max{λ( f ), λ(g)}). This looks like bad news: an exponential upper bound on
the size of the gcd and the number of word operations of the Euclidean Algorithm!
In reality, however, the sizes do not grow like that at every step, and we can prove
that the coefficient sizes in the Euclidean Algorithm remain polynomially bounded
in the input size. To prove this non-obvious result, we need a “global view” of the
Euclidean Algorithm provided by the theory of (sub-)resultants. This theory will
give us explicit formulas for the coefficients that appear in the polynomials in the
Euclidean Algorithm. As a bonus, this theory will allow us to compute gcds in
Q[x] using a modular approach, yielding a much more practical algorithm.
The following example illustrates the huge coefficients that actually occur in
the Euclidean Algorithm in Q[x]. It is typical in the sense that for most pairs of
polynomials, with about as many coefficient digits as the degree, a similar growth
of intermediate results occurs.
each step, is run in Section 6.11 on the same example; its intermediate results are
considerably bigger than here. The example also illustrates the phenomenon of in-
termediate expression swell: The 25-digit coefficients of a4 contract to 18 digits
in its normalized version r4 . At the next step, the relation between a5 and r5 is
even more drastic. In the normal case, where all the quotients have degree 1, this
is not a serious problem: the discussion in Section 6.11 implies that then λ(ai ) is
at most about 3λ(ri ). A more important issue is that the upper bound on the size
of the coefficients of the gcd is smaller by about one order of magnitude than the
corresponding bound for the other remainders, even when the gcd is nonconstant.
This follows from the estimates in Section 6.6 and 6.11 below. ✸
The basic question now is: does this algorithm really run in polynomial time?
In other words: do the coefficients that occur have polynomially bounded length?
The naive exponential upper bound and the above example may raise some doubt
about this. But not to worry, all is well! Our proofs of polynomial bounds proceed
in two stages: first for the computation of the gcd in Sections 6.5 and 6.6, and
finally for all results of the EEA in Section 6.11.
Once we have a good bound on the final result, the basic idea to circumvent the
intermediate expression swell is to use a modular approach. When the input poly-
nomials f , g are in Z[x], then we may choose an appropriate prime p ∈ N, compute
gcd( f mod p, g mod p) in F p [x], and recover the gcd from its image modulo p.
printlevel := 2:
for i from 1 to 5 do
q[i] := Quo(r[i - 1], r[i], x, ’a[i + 1]’) mod 7;
a[i + 1] := a[i + 1];
if (a[i + 1] <> 0) then
rho[i + 1] := lcoeff(a[i + 1], x);
r[i + 1] := a[i + 1] / rho[i + 1] mod 7;
fi;
od;
146 6. The resultant and gcd computation
q1 := x + 6 a4 := x + 2
3 2 ρ4 := 1
a2 := x + 4 x + 5 x + 3
ρ2 := 1 r4 := x + 2
3 2 q4 := x + 1
r2 := x + 4 x + 5 x + 3
q2 := x + 5 a5 := 6
2
a3 := 5 x + x + 5 ρ5 := 6
ρ3 := 5 r5 := 1
2
r3 := x + 3 x + 1 q5 := x + 2
q3 := x + 1 a6 := 0
In the above example, the modular approach has revealed that f and g have
no nonconstant common divisors in Z[x], but does this also imply that they have
no nonconstant common divisors in Q[x]? The answer is yes, but it requires an
important tool, Gauß’ lemma, which we will discuss in Section 6.2 below.
Besides that, the following questions have to be addressed in order to make the
idea from the above example into an algorithm.
◦ How big do we have to choose the modulus p so that we can recover the gcd
from its image modulo p? This requires an upper bound on the size of the
coefficients of the gcd, which is provided by Mignotte’s bound 6.33 in Sec-
tion 6.6. The corresponding question for polynomials with coefficients in F[y]
for a field F is trivial: the degree in y of the gcd is at most that of the input
polynomials.
◦ How do we find the denominators of the monic gcd? If the gcd is constant, as
in Example 6.1, then this is not an issue, but in general a monic nonconstant
gcd will have rational coefficients that are not integers. One solution is rational
number reconstruction, as discussed in Section 5.10. Another possibility is to
multiply the modular gcd by a known multiple of all denominators; the results
of Section 6.2 will provide such a multiple.
◦ Does the approach work for any prime, or are there primes where the degree of
the modular gcd is too large? Unfortunately, there are such “unlucky” primes,
but fortunately, not too many of them. This can be shown by using resultants,
which we discuss in Section 6.3.
6.2. Gauß’ lemma 147
Then
f = (y3 + 3y2 + 2y)x3 + (y2 + 3y + 2)x2 + (y3 + 3y2 + 2y)x + (y2 + 3y + 2),
g = (2y3 + 3y2 + y)x2 + (3y2 + 4y + 1)x + (y + 1)
L EMMA 6.5. For f ∈ R[x] and c ∈ R, cont(c f ) = cont(c) · cont( f ) and pp(c f ) =
pp(c) · pp( f ).
The following result, due to Gauß, is the cornerstone for unique factorization of
polynomials over UFDs.
C OROLLARY 6.7.
For f , g ∈ R[x], cont( f g) = cont( f ) cont(g) and pp( f g) = pp( f ) pp(g).
P ROOF. Let h = pp( f g). By Gauß’ lemma, h∗ = pp( f ) pp(g) is primitive. Then
by Lemma 6.5 and since cont( f ) cont(g) is normalized, and the claim follows. ✷
6.2. Gauß’ lemma 149
Lemma 6.5 is just the special case of Corollary 6.7 when g = c is constant.
It is convenient to extend the definition of content and primitive part to poly-
nomials in K[x]. If f = ∑0≤i≤n (ai /b)xi ∈ K[x], with a common denominator b ∈
R \ {0} and all ai ∈ R, then we let cont( f ) = gcd(a0 , . . . , an )/ cont(b) ∈ K and
pp( f ) = f / cont( f ). For example, we have cont(−3x − 9/2) = 3/2 ∈ Q and
pp(−3x − 9/2) = −2x − 3 ∈ Z[x]. Then pp( f ) is a primitive polynomial in R[x],
and Exercise 6.4 shows that Lemma 6.5 and Corollary 6.7 hold for c ∈ K and
f , g ∈ K[x].
We recall the following notions. A nonzero nonunit p of a ring R is prime if
p | ab implies that p | a or p | b, and p is irreducible if p = ab implies that one of
a and b is a unit. Multiplication by units does not change the property of being (or
not being) prime or irreducible. Prime elements are irreducible, and if R is a UFD,
then the two notions coincide (Section 25.2). We can now prove the following
celebrated theorem of Gauß.
P ROOF. Since R is an integral domain, deg( f g) = deg f + deg g holds for any
nonzero polynomials f , g ∈ R[x]. This implies that the units of R[x] are precisely
the units of R, and that a prime p ∈ R is irreducible in R[x].
Let f ∈ R[x] be a nonzero nonunit. Since R is a UFD, cont( f ) can be written as a
product of irreducibles of R, by the above. Let K denote the field of fractions of R.
Then K[x] is a Euclidean domain and therefore a UFD, and pp( f ) = f1 f2 · · · fr
in K[x] with (over K) irreducible nonconstant polynomials f1 , . . . , fr . Extracting
contents, Corollary 6.7 yields the factorization
pp( f ) = pp( f1 ) · · · pp( fr ) (2)
into primitive polynomials in R[x]. Since each pp( fi ) is primitive in R[x] and irre-
ducible in K[x], it is irreducible in R[x]. This proves the existence of a factorization
into irreducibles in R[x].
By the additivity of the degree, every irreducible factor of a constant f ∈ R
belongs to R, and the uniqueness of the factorization of f in R[x] follows from the
one in R. Now we assume that f ∈ R[x] is nonconstant, and let
p1 · · · pk · f1 · · · fr = f = q1 · · · ql · g1 · · · gs
be two factorizations of f into irreducibles, with normalized p1 , . . . , pk , q1 , . . . , ql in
R and nonconstant primitive f1 , . . . , fr , g1 , . . . , gs ∈ R[x]. Then p1 · · · pk = cont( f ) =
q1 · · · qs , by Corollary 6.7. Thus k = l and p1 = q1 , . . . , pk = qk after reordering,
since R is a UFD. Furthermore,
f1 · · · fr = pp( f ) = g1 · · · gs (3)
150 6. The resultant and gcd computation
In particular, since R[x] is a UFD, any two elements of R[x] have a gcd. In
order to have a function gcd on R[x], we extend “lu” to R[x] via lu( f ) = lu(lc( f ))
(Exercise 3.8 (iii)) to define a normal form on R[x]. Then a polynomial in R[x] is
normalized precisely when its leading coefficient is, and gcd( f , g) is the unique
normalized associate in R[x] of all greatest common divisors of f and g, as usual.
Both 5 and 5x + 1 are primes in Z[x], but 5 is a unit in Q[x], while 5x + 1 is a
prime also in Q[x]. More generally, nonconstant polynomials are not units, so that
R× = (R[x])× , and {1, −1} = Z× = (Z[x])× ⊂ Q \ {0} = Q× = (Q[x])× , where R×
is the group of units of a ring R.
C OROLLARY 6.9.
Let R be Z or a field, and n ≥ 0. Then R[x1 , . . . , xn ] is a Unique Factorization
Domain.
C OROLLARY 6.10.
Let R be a UFD with field of fractions K , f , g ∈ R[x], and h the normalized gcd of
f and g in R[x].
(i) The primes of R[x] are the primes of R plus the primitive polynomials in R[x]
that are irreducible in K[x].
(ii) cont(h) = gcd(cont( f ), cont(g)) in R and pp(h) = gcd(pp( f ), pp(g)) in R[x].
In particular, h = gcd(cont( f ), cont(g)) · gcd(pp( f ), pp(g)), and h is primi-
tive if one of f and g is.
(iii) h/ lc(h) ∈ K[x] is the monic gcd of f and g in K[x].
P ROOF. (i) Let p ∈ R[x]. We first assume that p is prime. If p is a constant, then
p is prime in R. Otherwise, it is a primitive polynomial and irreducible in K[x],
since a factorization in K[x] leads to one in R[x], as in (2).
On the other hand, if p is not prime, then a factorization p = uv with u, v 6∈ R×
shows that p is not prime in R, and, if p is primitive and nonconstant, that p is
reducible in K[x].
6.2. Gauß’ lemma 151
(ii) The polynomial h divides f , and hence cont(h) divides cont( f ), and, by sym-
metry, it divides cont(g) and hence gcd(cont( f ), cont(g)). On the other hand, this
gcd is in R and a common factor of f and g, hence divides h and then also cont(h).
This proves the first claim. The second one follows similarly, using the fact that
pp(h) divides pp( f ), by Corollary 6.7, and that pp(h) is normalized since h is
(Exercise 3.8 (iv)).
(iii) Since h/ lc(h) is a divisor of f and g in K[x], it also divides their monic
gcd h∗ . On the other hand, f = f ∗ h∗ for some f ∗ ∈ K[x], and taking contents
together with Corollary 6.7 shows that pp(h∗ ) | pp( f ) | f in R[x], and similarly
pp(h∗ ) | g. Thus pp(h∗ ) divides h = gcd( f , g) in R[x], which implies that h∗ and
h/ lc(h) divide each other in K[x], and since both are monic, they are equal. ✷
We note that part (ii) is wrong when h is not normalized: for example, if R = Z,
f = g = x, and h = −x, then pp(h) = −x 6= x = gcd(pp( f ), pp(g)). The following
examples illustrate the difference between gcds in R[x] and K[x].
E XAMPLE 6.3 (continued). With the Euclidean Algorithm in Q[x], we find that
gcd( f , g) = gcd(pp( f ), pp(g)) = x − 1/3 in Q[x]; see the continuation of Example
3.7 on page 58. Hence
The polynomials f and pp( f ) are normalized in Z[x] since their leading coeffi-
cients are positive, but g and pp(g) are not. Both gcd( f , g) and gcd(pp( f ), pp(g))
are normalized. ✸
gcd(cont( f ), cont(g)) = y + 1,
gcd(pp( f ), pp(g)) = yx + 1 in F5 [y][x] = F5 [x, y],
1
gcd( f , g) = gcd(pp( f ), pp(g)) = x + in F5 (y)[x],
y
gcd( f , g) = gcd(cont( f ), cont(g)) · gcd(pp( f ), pp(g))
= (y2 + y)x + (y + 1) in F5 [y][x].
Thus f and pp( f ) are normalized in R[x], while g and pp(g) are not. Both gcd( f , g)
and gcd(pp( f ), pp(g)) are normalized. ✸
152 6. The resultant and gcd computation
We obtain the following algorithm for calculating gcds in Z[x] and F[x, y]. By
Corollary 6.10 (ii) we may assume that the input polynomials are primitive.
T HEOREM 6.12.
The algorithm works correctly as specified.
realize clearly that for gcd calculations the resultant is purely an (indispensable)
conceptual tool and does not enter the algorithms, but only their analysis.
Now let F be a field and f , g ∈ F[x]. The following lemma says that the van-
ishing linear combination (−g) · f + f · g = 0 has the smallest possible coefficient
degrees if and only if gcd( f , g) = 1.
L EMMA 6.13. Let f , g ∈ F[x] be nonzero. Then gcd( f , g) 6= 1 if and only if there
exist s,t ∈ F[x] \ {0} such that s f + tg = 0, deg s < deg g, and degt < deg f .
be the “linear combination map”. For d ∈ N, we let Pd = {a ∈ F[x]: deg a < d},
with the convention that P0 = {0}. Then ϕ is a linear mapping of infinite-dimen-
sional vector spaces over F. (It is also an F[x]-linear map of F[x]-modules, in the
natural way.) The restriction of ϕ to ϕ0 : Pm × Pn −→ Pn+m is an F-linear mapping
between vector spaces of the same finite dimension, and Lemma 6.13 says the
following.
T HEOREM 6.14.
Let f , g ∈ F[x] be nonzero of degrees n, m, respectively.
For our map ϕ0 between vector spaces of equal (finite) dimension, the following
three properties are equivalent:
154 6. The resultant and gcd computation
◦ ϕ0 is an isomorphism,
◦ ϕ0 is injective (or one-to-one),
◦ ϕ0 is surjective (or onto).
Claim (i) now follows. For (ii), we recall from Lemma 3.15 (b) that (sℓ ,tℓ ) ∈
Pm × Pn . Since ϕ0 is an isomorphism, the solution ϕ0 (sℓ ,tℓ ) = 1 is unique. ✷
with m columns of f j ’s and n columns of g j ’s, and all entries outside the two
“parallelograms” equal to zero. This means that when we write
s= ∑ y jx j, t = ∑ z j x j , s f + tg = ∑ u jx j,
0≤ j<m 0≤ j<n 0≤ j<n+m
This is the central step; we advise the reader to understand it thoroughly. Theorem
6.14 can now be restated as follows.
C OROLLARY 6.15.
Let f , g, n, m be as in Theorem 6.14.
If we divide out the gcd, so that r0 = f /(x−1) = x3 −2x2 −2x and r1 = g/(x−1) =
x2 + x + 1, we have
r0 = q1 r1 + r2 = (x − 3)r1 + 3 · 1,
r1 = q2 r2 = (x2 + x + 1)r2 .
C OROLLARY 6.17.
Let F be a field, and f , g ∈ F[x] nonzero. Then the following are equivalent:
(i) gcd( f , g) = 1,
C OROLLARY 6.20.
Let R be a UFD and f , g ∈ R[x] not both zero. Then gcd( f , g) is nonconstant in
R[x] if and only if res( f , g) = 0 in R.
C OROLLARY 6.21.
Let R be an integral domain and f , g ∈ R[x] nonzero with deg f + deg g ≥ 1. Then
there exist nonzero s,t ∈ R[x] such that s f + tg = res( f , g), deg s < deg g, and
degt < deg f .
When f , g ∈ F[x, y], we write resx ( f , g) for the resultant in F[y] with respect
to x. Symmetrically, there is also a polynomial resy ( f , g) ∈ F[x]. We have the
following bound on degy resx ( f , g), where degy denotes the degree with respect to
the variable y (Section 25.3).
T HEOREM 6.22.
Let f , g ∈ F[x, y] with n = degx f , m = degx g, and degy f , degy g ≤ d . Then
P ROOF. When we write the determinant resx ( f , g) as the familiar sum of (n + m)!
terms, then each nonzero term has m factors that are coefficients of f , and n factors
that are coefficients of g. Hence the degree of each term is at most md + nd. ✷
|| f ||2 = (∑0≤i≤n fi2 )1/2 . The max-norm is || f ||∞ = max{| fi |: 0 ≤ i ≤ n}, and the
relation || f ||∞ ≤ || f ||2 ≤ (n + 1)1/2 || f ||∞ shows that the two norms differ only by a
small factor (Section 25.5).
T HEOREM 6.23.
Let f , g ∈ Z[x], n = deg f , and m = deg g. Then
E XAMPLE 6.24. To get a taste of what can go wrong without further assumptions,
we let R = Z and p = 2. When f = x + 2 and g = x, then res( f , g) = −2 6= 0 and
res( f , g) = 0, as expected. But when f = 4x3 − x and g = 2x + 1, then res( f , g) = 0
and res( f , g) = res(x, 1) = 1 6= 0; in particular, res( f , g) 6= res( f , g). ✸
The reason for the unexpected behavior in the last example is that the two rele-
vant Sylvester matrices are formed in rather different ways. Fortunately, this nui-
sance disappears when p does not divide at least one of the leading coefficients.
P ROOF. We write f = ∑0≤ j≤n f j x j , g = ∑0≤ j≤m g j x j , with nonzero fn , gm and all
f j , g j ∈ R. If deg f = 0, then both Sylvester matrices Syl( f , g) and Syl( f , g) are
6.4. Modular gcd algorithms 159
diagonal with f and f on the diagonal, respectively, and both r and res( f , g) are
nonzero. So let deg f ≥ 1. If g = 0, then res( f , g) = 0 and each column of g j ’s in
the Sylvester matrix Syl( f , g) vanishes modulo I, so that r = 0.
We now assume that g 6= 0, and let i be the smallest index with gm−i 6= 0. Then
we can partition Syl( f , g) as in Figure 6.1. The lower right submatrix, taken
fn gm
i
. ..
. .. ..
. . . .
f fn gm−i ..
n−i .
.. .. .. .. .. gm
. . . . .
.. .. .. ..
f0 .
fn
. . .
Syl( f , g) =
.. .. .. g0 gm−i n+m−i
. . .
.. .. ..
f0 .
. .
.. .. .. ..
. . . .
f0 g0
| {z }| {z }| {z }
i m−i n
modulo I, is Syl( f , g). All g j in the first i rows are zero modulo I, and repeated
Laplace expansion (Section 25.5) of r = det Syl( f , g) along the first row yields
modulo I that r = fni res( f , g). This proves (i), and the second claim follows from
Corollary 6.20. ✷
The conclusion may be false when both leading coefficients vanish modulo I, as
in the second case of Example 6.24.
T HEOREM 6.26.
Let R be a Euclidean domain, p ∈ R prime, and f , g ∈ R[x] nonzero. Furthermore,
let h = gcd( f , g) ∈ R[x], e = deg h, α = lc(h), and assume that p does not divide
b = gcd(lc( f ), lc(g)) ∈ R. A bar denotes reduction modulo p, and we let e∗ =
deg gcd( f , g). Then
(i) α divides b,
(ii) e∗ ≥ e,
(iii) e∗ = e ⇐⇒ α · gcd( f , g) = h ⇐⇒ p ∤ res( f /h, g/h) in R.
160 6. The resultant and gcd computation
P ROOF. Since h divides f and g in R[x], lc(h) divides lc( f ) and lc(g) in R, and (i)
follows. Let u = f /h and v = g/h ∈ R[x]. Then deg h = e since p ∤ b and by (i),
and
uh = f and vh = g (6)
imply that h divides gcd( f , g), which shows (ii) and the first equivalence in (iii).
(Recall that over a field such as R/hpi, polynomial gcds are always taken to be
monic.)
Now p ∤ b implies that p divides at most one of lc(u) and lc(v), say p ∤ lc(u).
Then Lemma 6.25 (ii) implies that p divides res(u, v) if and only if gcd(u, v) 6= 1
in R/hpi. From (6), we find that gcd( f , g) = gcd(u, v) · h/α, and this implies the
second equivalence in (iii). ✷
We write resx to indicate that we consider x as the main variable; there is also
resy ( f , g) = x2 +1 ∈ F5 [x]. If we now let a = a(−1) for a ∈ R, corresponding to p =
y + 1, then b = gcd(lcx ( f ), lcx (g)) = y does not vanish modulo p, res( f /h, g/h) =
res( f /h, g/h)(−1) 6= 0, and hence deg gcd( f , g) = 1. Actually
On the other hand, if a = a(1) for a ∈ R, then b 6= 0, res( f /h, g/h) = 0, and
deg gcd( f , g) > 1. In fact, gcd( f , g) = x2 + 3x + 2 = g/3. ✸
2. repeat
4. f ←− f mod p, g ←− g mod p
call the Euclidean Algorithm 3.14 over R/hpi to compute the monic
v ∈ R[x] with degy v < degy p and v mod p = gcd( f , g) ∈ (R/hpi)[x]
If also the cofactors f /h and g/h are needed, they can easily be obtained as
ppx ( f ∗ ) and ppx (g∗ ). Before computing f ∗ and g∗ in step 5, one will first test
whether the constant coefficient of w divides the constant coefficients of b f and bg,
and go back to step 3 if this test fails. We may compute f ∗ and g∗ as f ∗ ≡ f /v
mod p and g∗ ≡ g/v mod p.
To compute the gcd of non-primitive polynomials, we first compute the gcd of
their contents, then apply the algorithm to their primitive parts, and finally multiply
its result by the gcd of the contents. If the gcd of the constant coefficients of
6.5. Modular gcd algorithm in F[x, y] 163
f and g is smaller than b, then exchanging the roles of the leading and the constant
coefficients decreases the required degree of p.
The remarks above also apply to the modular gcd algorithms 6.34, 6.36, and
6.38 below.
T HEOREM 6.29.
Let f , g be an input, h = gcd( f , g) in R[x], and r = resx ( f /h, g/h) ∈ R = F[y].
Then r is a nonzero polynomial of degree at most 2nd , the halting condition in
step 6 is satisfied if and only if p does not divide r, and then the correct output is
returned in step 7. The cost for one iteration of steps 4 through 6 is no more than
48n2 d 2 + O(nd(n + d)) or O(n2 d 2 ) operations in F . If b = 1, then the cost is at
most 12n2 d 2 + O(nd(n + d)). Steps 1 and 7 take O(nd 2 ) operations in F .
P ROOF. We have gcd( f /h, g/h) = 1. Since h and f /h divide f , their degrees in y
are at most degy f ≤ d, and similarly for g/h, and Corollary 6.20 and Theorem 6.22
yield the first claim. Moreover, degy b < degy p, and hence p ∤ b. We first assume
that p ∤ r, and let α = lc(h) ∈ R. Then Theorem 6.26 implies that αv ≡ h mod p.
Moreover, α | b, and hence w ≡ bv ≡ (b/α)h mod p. Both w and (b/α)h have
degree in y less than degy p, whence they are equal. Similarly, we find that f ∗ =
b f /w and g∗ = bg/w, and the degree conditions in step 6 are satisfied since all
congruences in (7) are in fact equalities. Now h is primitive, by Corollary 6.10,
and the algorithm returns the correct result ppx (w) = ppx ((b/α)h) = h in step 7
since h, α, and b are all normalized.
On the other hand, if p | r, then Theorem 6.26 implies that degx w = degx v >
degx h. If the degree conditions in step 6 were true, then the congruences in (7)
would be equalities, and pp(w) would be a common divisor of f and g of higher
degree in x than degx h. This contradiction finishes the correctness proof.
Computationally, nothing happens in reducing f and g modulo p in step 4. The
cost for the Euclidean Algorithm is at most 2n2 + O(n) additions and multiplica-
tions in R/hpi, plus at most n + 2 modular inversions, by Theorem 3.16. The cost
for one addition or multiplication in this residue class ring is at most 4(deg p)2 +
O(deg p) operations in F, by Corollary 4.6. Since deg p = d + 1 + deg b ≤ 2d + 1,
the total cost for step 4 is at most 32n2 d 2 + O(nd(n + d)) operations in F (the
cost for the modular inversions is subsumed by the “O” term), and only at most
8n2 d 2 + O(nd(n + d)) if b = 1.
By Section 2.4, the cost for the three multiplications by leading coefficients
and the two modular divisions in step 5 is at most 4 degx w · (n − degx w) + O(n)
additions and multiplications modulo p. Since m(n − m) ≤ n2 /4 for all m ∈ R,
this amounts to at most n2 + O(n) modular operations or 16n2 d 2 + O(nd(n + d))
operations in F, and only 4n2 d 2 + O(nd(n + d)) if b = 1. Steps 1 and 7 use at most
n + 1 gcds and divisions of polynomials in F[y] of degree at most 2d, or O(nd 2 )
operations in F. ✷
164 6. The resultant and gcd computation
We have ignored the cost for finding p in step 3. For a finite field F = Fq , we
will discuss this in Section 14.9: Corollary 14.44 implies that this can be done
with an expected number of O∼ (d 2 log q) operations in Fq , and that the expected
number of iterations of the algorithm is at most two if d ≥ 4 + 2 log2 n. Here the
O∼ notation ignores logarithmic factors (Section 25.7).
is trivial and quite sufficient. Over Z, we could use the subresultant bound of
Theorem 6.52 below, but we now derive a much better bound. It actually depends
only on one argument of the gcd, say f , and is valid for all factors of f . We will
use this again for the factorization of f in Chapter 15.
We extend the 2-norm to a complex polynomial f = ∑0≤i≤n fi xi ∈ C[x] by
1/2
|| f ||2 = ∑0≤i≤n | fi |2 ∈ R, where |a| = (a · a)1/2 ∈ R is the norm of a ∈ C and
a is the complex conjugate of a. We will derive a bound for the norm of factors
of f in terms of || f ||2 , that is, a bound B ∈ R such that any factor h ∈ Z[x] of f
satisfies ||h||2 ≤ B. One might hope that we can take B = || f ||2 , but this is not
the case. For example, let f = xn − 1 and h = Φn ∈ Z[x] be the nth cyclotomic
polynomial (Section 14.10). Thus Φn divides xn − 1, and the direct analog of (8)
would say that each coefficient of Φn is at most 1 in absolute value, but for ex-
ample Φ105 , of degree 48, contains the term −2x7 . In fact, the coefficients of Φn
are unbounded in absolute value if n −→ ∞, and hence this is also true for ||h||2 .
Worse yet, for infinitely many integers n, Φn has a very large coefficient, namely
larger than exp(exp(ln 2 · ln n/ lnln n)), where ln is the logarithm in base e; such a
coefficient has word length somewhat less than n. It is not obvious how to control
the coefficients of factors at all, and it is not surprising that we have to work a little
bit to establish a good bound.
L EMMA 6.30. For f ∈ C[x] and z ∈ C, we have ||(x − z) f ||2 = ||(zx − 1) f ||2 .
= ||(zx − 1) f ||22 . ✷
Let
f= ∑ f i xi = f n ∏ (x − zi ),
0≤i≤n 1≤i≤n
P ROOF. We arrange the roots so that |z1 |, . . . , |zk | > 1 and |zk+1 |, . . . , |zn | ≤ 1 for
some k ∈ {0, . . . , n}, so that M( f ) = | fn · z1 · · · zk |. Let
g = fn ∏ (zix − 1) ∏ (x − zi ) = gn xn + · · · + g0 ∈ C[x].
1≤i≤k k<i≤n
Then
g 2
M( f )2 = | fn z1 · · · zk |2 = |gn |2 ≤ ||g||22 = (x − z1 ) = · · ·
z1 x − 1 2
g 2
= (x − z1 ) · · · (x − zk ) = || f ||22 ,
(z1 x − 1) · · · (zk x − 1) 2
It is convenient to use also the 1-norm || f ||1 = ∑0≤i≤n | fi |, so that || f ||∞ ≤ || f ||2 ≤
|| f ||1 ≤ (n + 1)|| f ||∞ .
T HEOREM 6.32.
If h = ∑0≤i≤m hi xi ∈ C[x] of degree m divides f = ∑0≤i≤n fi xi ∈ C[x] of degree
n ≥ m, then
hm
||h||2 ≤ ||h||1 ≤ 2 M(h) ≤ 2m || f ||2 .
m
fn
by the sum formula for the binomial coefficients and Landau’s inequality. ✷
(i) ||g||∞ ||h||∞ ≤ ||g||2 ||h||2 ≤ ||g||1 ||h||1 ≤ 2m+k || f ||2 ≤ (n + 1)1/2 2m+k || f ||∞ ,
(ii) ||h||∞ ≤ ||h||2 ≤ 2k || f ||2 ≤ 2k || f ||1 and ||h||∞ ≤ ||h||2 ≤ (n + 1)1/2 2k || f ||∞ .
Suppose that the polynomials f , g ∈ Z[x] have degrees n = deg f ≥ deg g and
max-norm || f ||∞ , ||g||∞ at most A. Then the max-norm of gcd( f , g) ∈ Z[x] is at
most (n + 1)1/2 2n A, by Corollary 6.33. We now have the following algorithm for
computing a gcd in Z[x], completely analogous to Algorithm 6.28.
2. repeat
4. f ←− f mod p, g ←− g mod p
call the Euclidean Algorithm 3.14 over Z p to compute the monic v in
Z[x] with ||v||∞ < p/2 such that v mod p = gcd( f , g) ∈ Z p [x]
6.6. Mignotte’s factor bound and a modular gcd algorithm in Z[x] 167
In step 3, we need primes satisfying certain conditions. We do not yet have the
tools to solve this task, and postpone its discussion to Section 18.4. The following
is analogous to Theorem 6.29.
T HEOREM 6.35.
Let h be the normalized gcd of f and g in Z[x], so that lc(h) > 0. Then r =
res( f /h, g/h) is a nonzero integer with |r| ≤ (n + 1)n A2n , the halting condition in
step 6 is true if and only if p does not divide r, and then the output in step 7 is
correct. The cost for one execution of steps 4 and 5 is O(n2 (n2 + log2 A)) word
operations, and steps 1 and 7 take O(n(n2 + log2 A)) word operations.
P ROOF. For the correctness, it is sufficient to see that the condition in step 6
holds if and only if pp(w) = h. If the condition holds, then || f ∗ w||∞ ≤ || f ∗ w||1 ≤
|| f ∗ ||1 ||w||1 ≤ B < p/2, and ||b f ||∞ < p/2 and f ∗ w ≡ b f mod p imply that f ∗ w =
b f . Similarly, we find g∗ w = bg. Thus w | gcd(b f , bg), and Theorem 6.26 (ii) im-
plies that deg w = deg gcd(b f , bg), and hence pp(w) = gcd( f , g) since both poly-
nomials are normalized.
On the other hand, if pp(w) = gcd( f , g) with the w calculated in step 5, then
w divides b f , Mignotte’s bound 6.33 shows that ||b f /w||∞ ≤ B < p/2, and hence
the congruence f ∗ ≡ b f /w mod p is an equality. Similarly, we find g∗ = bg/w,
and another application of Corollary 6.33 implies the condition in step 6. Exercise
6.25 shows that p ∤ r if and only if pp(w) = h.
With k = deg h, we have || f /h||2 , ||g/h||2 ≤ (n + 1)1/2 2n−k A, again by Corol-
2
lary 6.33, and Theorem 6.23 gives |r| ≤ 4n (n + 1)n A2n ; Exercise 6.24 yields the
better bound stated in the theorem. Step 4 takes O(n2 ) arithmetic operations in Z p ,
and the cost for each of these is O(log2 p) word operations. Now log p ≤ log(4B) ∈
O(n+log A), whence step 4 uses O(n2 (n2 +log2 A)) word operations, and the same
bound holds for the divisions in step 5. Steps 1 and 7 take O(n) gcd’s and divisions
on integers of length O(n + log A), or O(n(n2 + log2 A)) word operations. ✷
In Section 18.4, we show that we can find a random number p between 2B and
4B such that p is prime and p ∤ r with probability at least 1/2 by a probabilistic
algorithm using O∼ (log3 B) or O∼ (n3 + log3 A) word operations (Corollary 18.11).
Then the expected number of iterations of the algorithm is at most two.
168 6. The resultant and gcd computation
w(x, u) = b(u)vu ,
In practice, one will choose the points from F adaptively, starting with about l
or even fewer elements in S, remove “unlucky” points that are detected in steps 4,
5, or 7 from S, and add some new random points to S if the condition in step 7
is violated. If the gcd is constant, then only one “lucky” point is sufficient to
detect this. The analysis of the above algorithm is somewhat easier, though. These
remarks also apply to Algorithm 6.38 below.
6.7. Small primes modular gcd algorithms 169
T HEOREM 6.37.
Algorithm 6.36 correctly computes the gcd of f and g. One iteration of the loop
uses at most 10n2 d + 36nd 2 + O((n + d)d) arithmetic operations in F , and only
5n2 d + 13nd 2 + O((n + d)d) if b = 1. If d ≥ 1 and we choose S in step 3 as a
uniform random subset with 2l elements of a fixed finite set U ⊆ F of cardinality
#U ≥ (4n + 2)d , then the expected number of iterations is at most 2. The cost for
steps 1 and 8 is at most 10nd 2 +O(nd) operations in F , or even 52 nd 2 +O((n+d)d)
if b = 1.
By increasing the size of U, the failure probability in a single run can be re-
duced and the expected number of iterations of the algorithm can be brought down
arbitrarily close to one. A variant of the algorithm is analyzed in Section 24.3.
The running time of the small primes modular gcd algorithm is better by about
one order of magnitude than for the big prime variant when n ≈ d. If fast polyno-
mial arithmetic, as described in Part II, is used, then the cost even drops to O∼ (nd)
(Corollary 11.12).
170 6. The resultant and gcd computation
When F does not have sufficiently many elements, say when F = F2 , then we
have a problem in step 3. This can be circumvented by either making a suit-
able field extension, which increases all timings by a factor of O(log2 (nd)) (Exer-
cise 6.32), or by choosing nonlinear moduli.
Here is the analogous algorithm for Z[x]. We denote the natural (base e) log-
arithm by ln.
2. repeat
4. S ←− {p ∈ S: p ∤ b}
for each p ∈ S call the Euclidean Algorithm 3.14 over Z p to com-
pute the monic v p ∈ Z[x] with coefficients in {0, . . . , p − 1} such that
v p mod p = gcd( f , g) ∈ Z p [x], where the bar indicates reduction of
each coefficient modulo p
5. e ←− min{deg v p : p ∈ S}, S ←− {p ∈ S: deg v p = e}
if #S ≥ l then remove #S − l elements from S else goto 3
6. call the Chinese Remainder Algorithm 5.4 to compute each coeffi-
cient of the unique polynomials w, f ∗ , g∗ ∈ Z[x] with max-norms less
than (∏ p∈S p)/2 and
for all p ∈ S
7. until || f ∗ ||1 ||w||1 ≤ B and ||g∗ ||1 ||w||1 ≤ B
8. return pp(w)
T HEOREM 6.39.
Algorithm 6.38 works correctly. One execution of steps 4 through 7 can be per-
formed with O(n(n2 + log2 A)(log n + loglog A)2 ) word operations, and the same
estimate holds for steps 1 and 8.
P ROOF. Correctness follows as in the proof of Theorem 6.35. For the running
time estimate, we first note that log p ∈ O(log k) for each prime p ∈ S. In step 4,
the cost per prime p is O(n log A · log k) word operations for reducing b and all
coefficients of f and g modulo p, and O(n2 ) operations in Z p or O(n2 log2 k) word
operations for the gcd, a total of O(n(n log k + log A)l log k) word operations. In
step 6, we perform two divisions with remainder f /v p and g/v p modulo p for
each p ∈ S, taking O(n2 log2 k) word operations, and then apply the Chinese Re-
mainder Algorithm to each of the at most 2n + 2 coefficients of w, f ∗ , and g∗ .
We have log ∏ p∈S p = ∑ p∈S log p ∈ O(l log k), Theorem 5.8 implies that the cost
for each coefficient is O(l 2 log2 k) word operations, and the cost for all coeffi-
cients is O(nl 2 log2 k). The cost for steps 1 and 8 is as in Theorem 6.35. We have
l ∈ O(n + log A) and log k ∈ O(log n + loglog A), and the claims follow. ✷
As in the polynomial case, the cost estimate for the small primes algorithm is
smaller by about one order of magnitude as for the big prime variant. If we use
single precision primes, then the cost is about O(nl(n + l)) word operations. In
Section 11.1, we will show that the cost drops to O∼ (n2 + n log A) when using the
fast methods for polynomial and integer arithmetic from Part II. In Section 18.4,
we show that the first k primes p1 = 2, . . . , pk can be computed deterministically
by the sieve of Eratosthenes, taking O(k log2 k loglog k) or O∼ (n(n + log A)) word
operations, and that each of them is at most 2k ln k. The value k is an upper bound
on 2 log2 |b res( f /h, g/h)|, by Theorem 6.35, and this guarantees that at least k/2
of our k primes do not divide b res( f /h, g/h). By Theorem 6.26, at least half of
the primes p1 , . . . , pk are “lucky”. We have 2l ≤ k, and if we choose the set S as
a uniform random subset with 2l elements of {p1 , . . . , pk } in step 3, then Exercise
6.31 shows that at least l of the primes in S are lucky with probability no less than
1/2. As in the bivariate case, the condition in step 7 is satisfied if and only if at
least l primes are lucky, and the expected number of iterations of the algorithm is
at most two.
In practice, one would use an adaptive approach as described for the bivariate
case, in particular since the Mignotte bound on the coefficients of h is often too
large. We present running times of such an implementation in Section 6.13.
The historical purpose of the resultant was to solve geometric problems by elim-
ination of variables. As an example, we want to determine the common roots of
two polynomials in two variables, or, equivalently, the intersection of two plane
curves. Suppose we are given f , g ∈ F[x, y], where F is a field, and want to inter-
sect the two plane curves
Bézout’s theorem says that there are deg f · deg g = 2 intersection points; they are
depicted in Figure 6.2 (black). We might compute them by solving g = 0 for y and
plugging this into f = 0, but let us proceed systematically to illustrate the resultant
method. We have
1 4 0
resy ( f , g) = det 0 3x 4 = 25x2 − 16,
x2 − 1 0 3x
and the projection Z of X ∩ Y onto the x axis consists of the two zeroes Z =
{4/5, −4/5} of resy ( f , g) (red). We obtain the corresponding values for y by tak-
ing gcds:
4 4
2 9 12 3
gcd f , y , g , y = gcd y − , 4y + = y+ ,
5 5 25 5 5
4 4 9 12 3
gcd f − , y , g − , y = gcd y2 − , 4y − = y− ,
5 5 25 5 5
and hence the two intersection points are
n 4 3 4 3 o
X ∩Y = ,− , − , .✸
5 5 5 5
E XAMPLE 6.41. We consider the two plane curves X,Y ⊆ C 2 given by the two
polynomials
Exchanging x and y corresponds to a swap of f and g, and hence the whole situa-
tion is symmetric with respect to this exchange.
Before any calculations, let us look at a picture, in Figure 6.3 on page 174. This
is easy to generate with M APLE’s implicitplot command. The projection Z of
X ∩Y onto the x-axis is readily calculated: the resultant
y
✻
Y
•
X
• • ✲
x
Z •
3
y
0 1 2 x 3 4 5
F IGURE 6.3: The three curves f = 0 (blue), g = 0 (green), and f + g = 0 (pink), and the
projection of their intersection points to the x-axis (red).
and
!
1 ± √15i 1 ± √15i √
1 ∓ 15i
gcd f ,y ,g ,y = y− .
2 2 2
one observes that in f + g the terms of degree 3 cancel, and in fact f + g = 0 is the
equation of a circle, the pink curve in Figure 6.3.
Bézout’s theorem says that X ∩Y consists of 3 · 3 = 9 points. We only found six
of them. Where are the others? This book’s margin is too narrow to contain them,
because they lie at infinity! ✸
This linear polynomial has a root if and only if either the leading coefficient vp−uq
is nonzero (then X ∩Y consists of one point), or if it and vr − wq both vanish (then
X = Y ). ✸
The general theory of linear algebra generalizes this well-known criterion for
simultaneous solvability of two linear equations in two variables. In a similar way,
geometric elimination theory tries to generalize our curve intersection method to
higher dimensions. This is a much more difficult problem, and the current algo-
rithmic methods are feasible only for a fairly small number of variables. We give
an introduction to one successful method in Chapter 21: Gröbner bases.
We give a further application of resultants from the theory of algebraic field
extensions. Suppose we have two elements α, β in an algebraic extension E of a
field F, with minimal polynomials f , g ∈ F[x], respectively (Section 25.3). How
can we find the minimal polynomial h of α + β ? Since (α + β , β ) ∈ E 2 is a com-
mon zero of g(y) and of f (x − y), the resultant r = resy ( f (x − y), g(y)) ∈ F[x] is
nonconstant and has α + β as a root. Thus h is a factor of r.
√ √
E XAMPLE 6.43. We let F = Q, α = i = −1, β = 3. Then f = x2 + 1, g =
x2 − 3, f (x − y) = y2 − 2xy + x2 + 1, and
1 0 1 0
−2x 1 0 1 4 2
r = resy ( f (x − y), g(y)) = det
x2 + 1 −2x −3 0 = x − 4x + 16.
0 x2 + 1 0 −3
(i) If r is not the zero polynomial, then r has at most dsn−1 zeroes in Sn .
P ROOF. (i) We prove the claim by induction on n. The case n = 1 is clear, since
a nonzero univariate polynomial of degree at most d over an integral domain has
at most d zeroes (Lemma 25.4). For the induction step, we write r as a polynomial
in xn with coefficients in x1 , . . . , xn−1 : r = ∑0≤i≤k ri xni with ri ∈ R[x1 , . . . , xn−1 ] for
0 ≤ i ≤ k and rk 6= 0. Then deg rk ≤ d − k, and by the induction hypothesis, rk has
at most (d − k)sn−2 zeroes in Sn−1 , so that there are at most (d − k)sn−1 common
zeroes of r and rk in Sn . Furthermore, for each a ∈ Sn−1 with rk (a) 6= 0, the uni-
variate polynomial ra = ∑0≤i≤k ri (a)xni ∈ R[xn ] of degree k has at most k zeroes, so
that the total number of zeroes of r in Sn is bounded by
For the probabilistic algorithm below, we assume that we have a finite set S ⊆ F
and a “random element generator for S”, which produces a uniform random mem-
ber of S. Instead of computing many gcds, it just uses one.
2. g ←− f2 + ∑3≤i≤n ai fi
3. return gcd( f1 , g)
T HEOREM 6.46.
Suppose that deg fi ≤ d for each i, and h∗ = gcd( f1 , . . . , fn ). Then the algorithm
uses at most 2(n − 2)(d + 1) + 2d 2 + O(d) operations in F , h∗ divides h, and
prob{h 6= h∗ } ≤ d/#S.
P ROOF. The cost estimate is immediate from Theorem 3.16. Since h∗ divides
f1 , . . . , fn , it divides g and gcd( f1 , g) = h. It remains to establish the bound on the
error probability.
Dividing each fi by h∗ if necessary, we may assume that gcd( f1 , . . . , fn ) = 1, and
also that f1 6= 0. Let A3 , . . . , An be new indeterminates over F(x), R = F[A3 , . . . , An ],
K = F(A3 , . . . , An ) the field of fractions of R, G = f2 + ∑3≤i≤n Ai fi ∈ R[x], and
r = resx ( f1 , G) ∈ R. Then r is a polynomial in A3 , . . . , An of degree at most d, and
Lemma 6.25, applied to the ideal I = hA3 − a3 , . . . , An − an i for which R/I ∼ = F,
shows that
In order to apply Lemma 6.44, we have to show that r is not the zero polynomial.
Let u be a common divisor of f1 and G in R[x]. Since u divides f1 , its coefficients
lie in the splitting field E of f1 over F. But E[x] ∩ K[x] = F[x], and hence u ∈ F[x].
If we think of G as a linear polynomial in A3 , . . . , An with coefficients in F[x], then
u | G implies that u divides the coefficients of G in that representation, so that u
divides f1 , . . . , fn . Since gcd( f1 , . . . , fn ) = 1, it follows that u ∈ F. Therefore the
gcd of f1 and G in R[x] is a constant. By Corollary 6.20, r is not the zero element
of R, and Lemma 6.44 yields the bound on the error probability. ✷
178 6. The resultant and gcd computation
The 2d 2 + O(d) from the time bound can be replaced by O(d log2 d · loglog d)
when using the fast Euclidean Algorithm from Chapter 11. The dominating cost
of about dn for Algorithm 6.45 is unavoidable, since this is the input size.
In practice, one would choose f1 to have minimal degree among f1 , . . . , fn . To
reduce the error probability to zero, we can in addition compute the remainders
f1 rem h, . . . , fn rem h; this is somewhat cheaper than n gcds, and h = h∗ if and
only if all remainders are zero. In the rare event that they are not, one can rerun the
algorithm with h and these remainders. This is particularly useful for computing
the primitive part of a bivariate polynomial with respect to one variable, since then
the quotients f1 /h∗ , . . . , fn /h∗ are needed anyway.
Using the Extended Euclidean Algorithm in step 3 yields a representation of h as
a linear combination of f1 , . . . , fn (Exercise 6.38). Using Algorithm 6.45, one can
also compute the least common multiple of several polynomials (Exercise 6.39).
6.10. Subresultants
In this section, we extend the resultant theory—which governs the gcd—to the
subresultants which cover all results of the Extended Euclidean Algorithm. As
before, this leads to efficient modular methods, but now for the whole algorithm.
The reader only interested in efficient gcd algorithms may skip this and proceed
directly to the implementation report in Section 6.13.
So now let F be an arbitrary field, and f , g ∈ F[x] nonzero of degrees n ≥ m,
respectively. We use the notation for the results of the Extended Euclidean Algo-
rithm, as in (1) on page 141, and ni = deg ri for 0 ≤ i ≤ ℓ + 1, with rℓ+1 = 0 and
deg rℓ+1 = −∞.
T HEOREM 6.47.
Let 0 ≤ k ≤ m ≤ n. Then k does not appear in the degree sequence if and only if
there exist s,t ∈ F[x] satisfying
P ROOF. “=⇒”: Suppose that k does not appear in the degree sequence. Then
there exists an i with 2 ≤ i ≤ ℓ + 1 such that ni < k < ni−1 . We claim that s = si
and t = ti do the job. We have s f + tg = ri , and deg ri = ni < k. Furthermore, from
Lemma 3.15 (b) we have
The case i = ℓ + 1 gives s = g/rℓ and t = − f /rℓ , where k < nℓ and rℓ+1 = 0.
6.10. Subresultants 179
“⇐=”: Suppose there exist s,t ∈ F[x] satisfying (11). The Uniqueness Lemma
5.15 implies that there exist i ∈ {1, . . . , ℓ + 1} and α ∈ F[x] \ {0} such that t = αti
and r = s f + tg = αri . Then from Lemma 3.15 (b) we find
Together these imply that ni < k < ni−1 , so that k is between two consecutive
remainder degrees and does not occur in the degree sequence. ✷
As we did for the resultant, we now restate Theorem 6.47 in the language of
linear algebra. The reader should keep comparing our development with the ma-
terial about the resultant in Section 6.3, which is just the special case k = 0. We
recall that Pd ⊆ F[x] denotes the vector space of all polynomials of degree less
than d ∈ N. For 0 ≤ k ≤ m, we consider the restriction of the map ϕ from (4) to
Pm−k × Pn−k . These polynomials are mapped to Pn+m−k . But now
This is now a linear map between spaces of the same dimensions. Then Theorem
6.47 becomes the following.
C OROLLARY 6.48.
Let 0 ≤ k ≤ m ≤ n, and 1 ≤ i ≤ ℓ + 1.
We have used the fact that s 6= 0 and ϕk (s,t) = 0 imply t 6= 0. This proves (i).
For (ii), we note that if k = ni < n, then si ∈ Pm−k and ti ∈ Pn−k satisfy ϕk (si ,ti ) = 1.
Since ϕk is an isomorphism, this implies the claim. ✷
then
Sk · (ym−k−1 , . . . , y0 , zn−k−1 , . . . , z0 )T = (un+m−k−1 , . . . , uk )T
where T denotes transposition. Again, the reader is advised to understand this rela-
tion carefully. We have immediately the following consequence of Corollary 6.48.
C OROLLARY 6.49.
Let 0 ≤ k ≤ m ≤ n, and 1 ≤ i ≤ ℓ + 1.
(i) k appears in the degree sequence ⇐⇒ det Sk 6= 0.
(ii) If k = ni < n, and y0 , . . . , ym−k−1 , z0 , . . . , zn−k−1 ∈ F form the unique solution
to
Sk · (ym−k−1 , . . . , y0 , zn−k−1 , . . . , z0 )T = (0, . . . , 0, 1)T , (12)
then si = ∑ y j x j and ti = ∑ z jx j.
0≤ j<m−k 0≤ j<n−k
6.10. Subresultants 181
E XAMPLE 6.1 (continued). The following M APLE code computes the subresul-
tants of the two polynomials from Example 6.1.
f := 824 x5 − 65 x4 − 814 x3 − 741 x2 − 979 x − 764
g := 216 x4 + 663 x3 + 880 x2 + 916 x + 617
with(LinearAlgebra):
S[0] := Transpose(SylvesterMatrix(f, g, x));
824 0 0 0 216 0 0 0 0
−65 824 0 0 663 216 0 0 0
−814 −65 824 0 880 663 216 0 0
−741 −814 −65 824 916 880 663 216 0
S0 :=
−979 −741 −814 −65 617 916 880 663 216
−764 −979 −741 −814 0 617 916 880 663
0 −764 −979 −741 0 0 617 916 880
0 0 −764 −979 0 0 0 617 916
0 0 0 −764 0 0 0 0 617
182 6. The resultant and gcd computation
T HEOREM 6.50.
Let f , g ∈ Z[x], n = deg f , m = deg g, and 0 ≤ k ≤ min{n, m}. Then
T HEOREM 6.51.
Let f , g ∈ F[x, y] with n = degx f , m = degx g, degy f , degy g ≤ d , and 0 ≤ k ≤
min{n, m}. Then degy σk ≤ (n + m − 2k)d .
T HEOREM 6.52.
Let f , g ∈ Z[x] have degrees n ≥ m and max-norm || f ||∞ , ||g||∞ at most A, and let
δ = max{ni−1 − ni : 1 ≤ i ≤ ℓ} be the maximal degree difference of consecutive
remainders. The results ri , si ,ti of the Extended Euclidean Algorithm 3.14 for f and
g in Q[x] have numerators and denominators (in lowest terms) absolutely bounded
by B = (n + 1)n An+m . The corresponding bound for qi and ρi is C = (2B)δ+2 . The
algorithm can be performed with O(n3 m δ 2 log2 (nA)) word operations.
P ROOF. Let 2 ≤ i ≤ ℓ and ni = deg ri . In the EEA, si and ti form the unique solution
to the system (12) of linear equations, so that σni si , σni ti , and σni ri = σni si f + σni ti g
are in Z[x], and by Cramer’s rule 25.6 and Hadamard’s inequality 16.6 we have
σnk+1
i
(σni−1 ri−1 ) = (σnki σni−1 qi ) · (σni ri ) + (σnk+1
i
σni−1 ρi+1 ri+1 ), (13)
where the four terms in parentheses are in Z[x]. By Exercise 6.44, we have
||σnki σni−1 qi ||∞ ≤ ||σni−1 ri−1 ||∞ · (||σni ri ||∞ + |σni |)k ≤ (2B)k+1 ,
||σnk+1
i
σni−1 ρi+1 ri+1 ||∞ ≤ ||σni−1 ri−1 ||∞ · (||σni ri ||∞ + |σni |)k+1 ≤ (2B)k+2
For random inputs (say, of fixed degrees and coefficient lengths), the expected
value of δ is quite small if the degrees n and m of the two inputs are close to each
other (Exercise 6.46). It is conceivable that the δ in the estimates for qi and ρi
is an artifact and that a more careful analysis would in fact reveal that it can be
replaced by 1. Lickteig & Roy (1996, 2001) discuss a variant of the EEA where
this is indeed the case.
For comparison, we state the analogous bounds for the traditional EEA 3.6,
where the remainders are given by ri+1∗ ∗
= ri−1 rem ri∗ for all i, without dividing out
the leading coefficient.
T HEOREM 6.53.
We denote by q∗i , ri∗ , s∗i ,ti∗ ∈ Q[x] the results of the traditional Extended Euclidean
Algorithm, and
ρi ρi−2 · · · ρ2 ρ0 if i ≥ 0 is even,
αi =
ρi ρi−2 · · · ρ3 ρ1 if i ≥ 1 is odd.
(i) The length of the algorithm equals that of the monic EEA, and for all i we
have
αi−1
q∗i = qi , ri∗ = αi ri , s∗i = αi si , ti∗ = αiti .
αi
(ii) Let n, m, δ , A,C be as in Theorem 6.52. The numerators and denominators of
the coefficients of all results of the traditional algorithm in Q[x] are bounded
by Cm+2 in absolute value, and the computing time is O(n3 m3 δ 2 log2 (nA)).
Exercise 6.47 asks for a proof, and Exercise 6.49 gives a slightly better bound
for the ri∗ , s∗i ,ti∗ in the traditional EEA, essentially replacing δ by 1.
We compare the two bounds from Theorems 6.52 and 6.53 with Mignotte’s
bound, say when A is an n-digit number and δ = 1. Then the “traditional” bound
is a number of about n3 digits, the “monic” one has about n2 digits, and Mignotte’s
only about n digits! Of course Mignotte’s bound only applies to the gcd, and one
cannot hope for a bound of similar quality for all results of the EEA.
Theorem 6.52 provides a clear explanation for the coefficient growth, as in Ex-
ample 6.1. The results of the EEA are governed by subresultants and grow at a
quadratic rate in length. But the leading coefficients αi in the traditional Euclid-
ean Algorithm are a product of i/2 such entries, and thus grow at a cubic rate.
6.11. Modular Extended Euclidean Algorithms 185
This does not literally follow from Theorem 6.53, which gives only upper bounds,
but there seems to be typically little cancellation in the product defining αi . For
instance, in the example below, the products of numerators and denominators in
r5 = α5 = ρ1 · ρ3 · ρ5 have 50 and 48 digits, respectively, and only the 2-digit fac-
tor 24 cancels. A practical recommendation is therefore to use the monic version
wherever possible.
E XAMPLE 6.1 (continued). The traditional Euclidean Algorithm for the polyno-
mials from Example 6.1 produces the following quotients and remainders; almost
any (random) input will exhibit a similar behavior:
r0 := 824 x5 − 65 x4 − 814 x3 − 741 x2 − 979 x − 764
r1 := 216 x4 + 663 x3 + 880 x2 + 916 x + 617
for i from 1 to 5 do
q[i] := quo(r[i - 1], r[i], x, ’r[i + 1]’);
r[i + 1] := sort(r[i + 1]);
od;
103 5837
q1 := x−
27 486
614269 3 1539085 2 1863490 3230125
r2 := x + x + x+
162 243 243 486
34992 30072401334
q2 := x+
614269 377326404361
23256341085690 2 27844657381944 32938754949612
r3 := − x − x+
377326404361 377326404361 377326404361
231779913080427109 212504381367397914300612023767
q3 := − x−
3767527255881780 7301574909368361826957477350
163630473867966784641771618997 276046921899101981276672067323
r4 := x+
15023816685943131331188225 30047633371886262662376450
349399005257174220664364219554244000250
q4 := − x
61742098348486478706658122441075651245917
53605502942609915156276524064879156029311616760832823425
−
26774931978255360791810790390285343980469602246030531286009
14999180998204546086628509444183593910034968673275
r5 :=
141919206653976666794661960809129382074315418338
q5 := 2322230703575610679693717783220005461472383779859614416232408\
.
1189217602966986 22534494575630661208071063858852539249064234\
5609867489818460486857552186875x + 1958818007759640557915662822891\
.
8052861081903680682675547410956194774022384587 22534494575630\
6612080710638588525392490642345609867489818460486857552186875
186 6. The resultant and gcd computation
r6 := 0
One can see clearly that the numerators and denominators are considerably
larger than in the monic Euclidean Algorithm on page 143. ✸
The following analog of Theorems 6.52 and 6.53 for bivariate polynomials is
proven in Exercise 6.48.
T HEOREM 6.54.
Let F be a field, f , g ∈ F[x, y] with n = degx f ≥ m = degx g and degy f , degy g ≤ d ,
and let δ = max{ni−1 − ni : 1 ≤ i ≤ ℓ} be the maximal degree difference of consec-
utive remainders in the Euclidean Algorithm for f and g in F(y)[x].
(i) The results ri , si ,ti of the Extended Euclidean Algorithm 3.14 for f and g
in F(y)[x] have numerators and denominators (in lowest terms) of degree in
y at most (n + m − 2ni )d ≤ (n + m)d . The corresponding bound for the qi
and ρi is (δ + 2)(n + m)d . The Extended Euclidean Algorithm 3.14 can be
performed with O(n3 m δ 2 d 2 ) operations in F .
(ii) For the traditional EEA, the degree bound is (m + 2)(δ + 2)(n + m)d , and
the number of operations in F is O(n3 m3 δ 2 d 2 ).
T HEOREM 6.55.
Let R be a Euclidean domain with field of fractions K , p ∈ R prime, and f , g ∈ R[x]
nonzero with deg f ≥ deg g and such that p does not divide b = gcd(lc( f ), lc(g)).
Furthermore let 1 ≤ i ≤ ℓ and ri , si ,ti ∈ K[x] be the results in the ith row of the
monic EEA, ni = deg ri < deg f , and σ = σni ∈ R the ni th subresultant of f , g.
A bar denotes the reduction modulo p.
(ii) The remainder degree ni occurs in the EEA for f , g over R/hpi if and only
if p ∤ σ .
P ROOF. (i) follows from Cramer’s rule, as in the proof of Theorem 6.52. We first
assume that ni ≤ min{deg f , deg g}. Then σ is, up to a unit modulo p, equal to the
6.11. Modular Extended Euclidean Algorithms 187
The degrees 2 and 0 are missing in the degree sequence modulo 3, but nonetheless
the two remainders r3 and r2∗ of degree 1 are equal modulo 3. ✸
We obtain the following modular algorithm for the results of the EEA in Q[x].
188 6. The resultant and gcd computation
T HEOREM 6.58.
The algorithm returns the correct values as specified. If S in step 1 consists of the
first r primes, then the algorithm uses O(n3 m log2 (nA)(log2 n + (loglog A)2 )) word
operations.
modulo p takes O(nm log2 r) word operations (Theorem 3.16 and Corollary 4.7),
and O(nmr log2 r) for all p ∈ S. Since log ∏ p∈S p = ∑ p∈S log p ∈ O(r log r), we have
O(r2 log2 r) word operations for reconstructing one rational coefficient in step 3
from its image modulo all primes in S by means of the Chinese Remainder Algo-
rithm 5.4 and the (traditional) Extended Euclidean Algorithm 3.6 over Z. Since all
ri , si ,ti together have O(nm) coefficients, the total cost for step 3 is O(nmr2 log2 r)
word operations. This dominates the cost for the other steps, and the claim follows
from r ∈ O(n log(nA)). ✷
T HEOREM 6.60.
The algorithm returns the correct values as specified. It uses O(n3 md 2 ) operations
in F .
See Exercise 6.50 for the proof. As for the modular gcd algorithm, we make a
suitable field extension when F does not have sufficiently many elements.
The timing estimate for the small primes modular EEA is the same as for both
the big prime variant and direct calculation, and better by a factor of m if we
only want to compute a single row ri , si ,ti of the EEA, as in the integer case. The
estimate drops to O∼ (n3 d) when using fast arithmetic (Part II), or even to O∼ (n2 d)
when only one row of the EEA is required (Corollary 11.12). Both bounds are
optimal up to logarithmic factors since the output size for all results is about n3 d,
and for one row about n2 d, at least in a generic sense.
Our purpose in studying subresultants has been to gain a conceptual understand-
ing of Euclid’s algorithm and a bound on the coefficients occurring in it. One
might be tempted to actually execute Euclid’s algorithm by calculating subresul-
tants via Gaussian elimination. This would be highly inefficient; in Section 11.2
we show how to calculate subresultants efficiently from the ρi in the Euclidean Al-
gorithm. They may then be used to replace the rational number reconstruction and
the Cauchy interpolation, respectively, in step 3 of the modular EEA algorithms,
by a (computationally easier) polynomial Chinese remainder or interpolation al-
gorithm, after multiplying all modular images by the corresponding subresultant.
The same modular techniques also apply to gcds of multivariate polynomials
over Q or a finite field. The rational case is reduced to the finite field case by com-
puting modulo small prime numbers, and the computation of multivariate polyno-
mial gcds over finite fields is reduced to univariate gcd computations by evaluating
one of the variables at distinct points and proceeding recursively.
(assuming b 6= 0). The integer factor multiplied to a ensures that the division can
be carried out in Z[x] (see also Exercise 2.9). This works with any integral domain
R instead of Z, and is useful when R is a ring of multivariate polynomials over an
integral domain. As in Section 6.2, we assume that we have some normal form
normal on R, which we extend to R[x] via normal( f ) = normal(lc( f )) f / lc( f ).
1. r0 ←− f , r1 ←− g, n0 ←− n, n1 ←− m
2. i ←− 1
while ri 6= 0 do
{ Pseudodivision }
ai−1 ←− lc(ri )1+ni−1 −ni ri−1 , qi ←− ai−1 quo ri ,
ri+1 ←− pp(ai−1 rem ri ), ni+1 ←− deg ri+1
i ←− i + 1
3. ℓ ←− i − 1
return normal(rℓ )
T HEOREM 6.62.
The algorithm correctly computes the gcd as specified. We let δ = max{ni−1 − ni :
1 ≤ i ≤ ℓ} be the maximal quotient degree.
(i) If R = Z and || f ||∞ , ||g||∞ ≤ A, then the max-norm of the intermediate results
is at most (2(n + 1)n An+m )δ+2 , and the algorithm uses O(n3 m δ 2 log2 (nA))
word operations.
(ii) If R = F[y] for a field F and degy f , degy g ≤ d , then the degree in y of all
intermediate results is at most (δ + 2)(n + m)d , and the time is O(n3 m δ 2 d 2 )
operations in F .
||qi ||∞ , ||ai−1 rem ri ||∞ ≤ ||ri−1 ||∞ (||ri ||∞ + |αi |)ni−1 −ni +1 ≤ (2B)δ+2 .
The latter number bounds all integers in the algorithm. The number of operations
in Z is O(nm), and the estimate follows from log B ∈ O(n log(nA)). ✷
The time estimate for the primitive Euclidean Algorithm is the same as for the
monic variant; Exercise 6.53 gives a slightly better bound. Its main advantage over
the monic algorithm is that it avoids rational numbers or functions completely. Ex-
periments with R = Z in Section 6.13 show that the primitive algorithm clearly
beats the monic algorithm in practice, but it is still slower than the modular algo-
rithms.
We can profitably use Algorithm 6.45 for computing the content and the prim-
itive part of ai−1 rem ri in step 2 when R = F[y]. This content is usually quite
large: Exercise 6.54 shows that its degree is about (ni−1 − ni + 1)(n + m − 2ni )d −
2(ni−1 − ni+1 )d ≥ 2(n + m − 2ni − 2)d.
E XAMPLE 6.1 (continued). We run the primitive Euclidean Algorithm 6.61 on the
polynomials from Example 6.1 in M APLE.
r0 := 824 x5 − 65 x4 − 814 x3 − 741 x2 − 979 x − 764
r1 := 216 x4 + 663 x3 + 880 x2 + 916 x + 617
for i from 1 to 5 do
a[i - 1] := r[i - 1] * lcoeff(r[i], x)
^ (degree(r[i - 1], x) - degree(r[i], x) + 1);
q[i] := quo(a[i - 1], r[i], x, ’r[i + 1]’);
r[i + 1] := sort(primpart(r[i + 1], x));
od;
a0 := 38444544 x5 − 3032640 x4 − 37977984 x3 − 34572096 x2 − 45676224 x
− 35645184
q1 := 177984 x − 560352
r2 := 1842807 x3 + 3078170 x2 + 3726980 x + 3230125
6.13. Implementations 193
6.13. Implementations
Table 6.5 gives an overview of the different variants of the Euclidean Algorithm
for computing gcds in Z[x] and F[x, y] that we have discussed in this chapter.
We have implemented all algorithms discussed in this chapter for computing
the gcd of two polynomials with integral coefficients in C++, using Victor Shoup’s
“Number Theory Library” N TL 1.5 for integer and polynomial arithmetic (see
http://www.shoup.net/ntl/); we will describe parts of it in Section 9.7. The
running times are given in Figures 6.4 and 6.6 for various degrees and coefficient
sizes. The integer arithmetic of N TL uses Karatsuba’s multiplication algorithm
(Section 8.1) which is asymptotically faster than classical multiplication, so that,
for example, the running time of the big prime gcd algorithm is only about n3.18 .
All timings are the averages over 10 pseudorandom inputs. The software ran in
1998 on a Sun Sparc Ultra 1 clocked at 167 MHz.
The experiments were as follows. For each choice of n and k, we pseudo-
randomly and independently chose three polynomials a, b, c ∈ Z[x] of degree less
than n2 and with nonnegative coefficients less than 2k/2 , and computed the gcd of
194 6. The resultant and gcd computation
0.2
0.15
CPU seconds
0.1
0.05
0
8 16 24 32 40 48 56 64
n
60
50
40
CPU minutes
30
20
10
0
1024 2048 3072 4096 5120 6144 7168 8192
n
F IGURE 6.4: Various gcd algorithms in Z[x] for pseudorandom polynomials of degree less
than n − 1 with nonnegative coefficients less than n2n−1 , for 2 ≤ n ≤ 64 and for 64 ≤ n ≤
8192.
6.13. Implementations 195
TABLE 6.5: Comparison of various Euclidean Algorithms in Z[x] and F[x, y]. The time
(word and field operations, respectively) is for polynomials of degree at most n in x and
with coefficients of length or degree at most n, respectively, with a normal degree sequence,
and ignores logarithmic factors.
30
n = 128
25 n = 2048
n=k
20 k = 128
CPU minutes
k = 2048
15
10
4 8 12 16 20 24 28 32
input size nk in megabits
F IGURE 6.6: The small primes modular gcd algorithm in Z[x] of NTL for various pseudo-
random polynomials of degree less than n − 1 with about k-bit coefficients.
196 6. The resultant and gcd computation
ac and bc in Z[x]. Thus the degree of the gcd was at least 2n − 1; in fact, it was
equal to 2n − 1 in all cases when n ≥ 6.
In these cases where the gcd is essentially c, the Mignotte bound for the length of
the coefficients of the gcd is too large by a factor of about 2n , which discriminates
against our implementation of the big prime algorithm. For that reason we also ran
a variant of the big prime method using the known bound 2n/2 on the coefficients
of c, and it computed the correct gcd in all cases, in time faster than the original
big prime algorithm but still slower than the small primes algorithm. The standard
deviations in the experiments with the big prime algorithm are considerably higher
than for the other algorithms. The reason is that there were enormous differences
in the time spent for finding a big prime with the routines of N TL that implement
the probabilistic primality testing algorithms of Chapter 18. Figure 6.4 also shows
the timings for the big prime algorithm with bound 2n/2 and without the cost of
the prime search; one can see that the corresponding curves are much smoother.
We implemented two variants of the “heuristic” gcd algorithm (Exercise 6.27).
In the first variant, the two input polynomials are evaluated at a random point,
and the evaluation point is a power of two in the second variant. The most time
consuming part in both variants is the gcd calculation of two integers with about
n2 bits.
We give timings for two variants of the small primes algorithm: our implemen-
tation and the built-in routine of N TL. Both routines differ from Algorithm 6.38 in
that they work in an adaptive fashion. They do not compute the Mignotte bound
at all, but take only as many single precision primes as needed to recover the co-
efficients of the gcd. This is achieved by deterministically adding one new prime
each time, discarding the “unlucky” ones which lead to a modular gcd of too large
degree, and performing a divisibility test after each new “lucky” prime, starting
with the divisibility check for the constant coefficients.
We did not try to optimize our routines and merely implemented them as de-
scribed in the text, using low-level routines of N TL. The one exception is the small
primes algorithm where we employed the adaptivity. By their nature, such compar-
isons depend on the effort spent on the various subroutines and hence contain an
element of unfairness. In particular, the different types of integer and polynomial
arithmetic of N TL favor some algorithms and disfavor others.
Nevertheless, the timings confirm the ranking that the theoretical bounds of Ta-
ble 6.5 suggest, in particular, the efficiency of small primes modular algorithms.
Moreover, they show a clear distinction between the monic and the primitive Eu-
clidean Algorithm, which is probably caused by the absence of arithmetic with
rational numbers in the latter, and between the big prime and the small primes
modular algorithm, which is partly due to the adaptivity and partly reflects our in-
tuition that it is cheaper to solve many “small” problems than one “big” problem
of the same total size. In summary, an adaptive small primes modular algorithm
appears to be the most favorable method to implement.
Notes 197
Notes. 6.1. When researchers started experimenting in the late 1960s with the first
computer algebra systems (often built by themselves), they observed an unpleasant phe-
nomenon: the rapid coefficient growth in the traditional Euclidean Algorithm, say in
Q[x], as in Example 6.1 on page 185 (and almost any random example). If pseudodivi-
sion is used at each step without removing common factors, then the remainder coeffi-
cients actually grow exponentially. As long as each rational number is reduced to lowest
terms, Theorem 6.52 guarantees that all coefficient lengths in the (monic) Extended Eu-
clidean Algorithm 3.14 are polynomially bounded. This was discovered by Collins (1966,
1967), and led to several new variants of the traditional Euclidean Algorithm: using the
monic versions, as discussed in Chapter 3, or the primitive versions (Section 6.12) of the
remainders. See also Collins (1971), Brown (1971), Brown & Traub (1971), and von zur
Gathen & Lücking (2000). Computationally, they are inferior to the modular approach,
introduced by Brown (1971) and Collins (1971); see also Notes 6.7 and 6.10.
6.2. Gauß (1801) proves his important “Lemma” in article 42. He shows in article 340 of
Gauß (1863b) that F p [x] is a UFD, for a prime p.
6.3. Leibniz (1683) drafted a letter to Tschirnhaus, but never mailed it. He describes how
to calculate the resultant of two polynomials of degree five by Euclid’s Algorithm, and
says that its vanishing means that the two polynomials have a nontrivial gcd. After earlier
work of Newton and Maclaurin, Euler (1748c) and Bézout (1764) introduced the resul-
tant; the name comes perhaps from Bézout’s équation resultante de l’élimination. Bézout
obtains the resultant as the determinant of a matrix, today called Bézout’s matrix , with
only min{n, m} rows and columns (Exercise 6.14). He describes how to calculate an k × k
determinant as the familiar sum of k! terms, and gives the linear equations describing the
Bézout coefficients s,t with s f + tg = constant, tacitly assuming the gcd to be trivial.
Later algebraic geometers generalized the resultant to more than two variables and poly-
nomials: Euler (1764), Sylvester (1840, 1853), Cayley (1848), Macaulay (1902, 1916,
1922), and many others. The basics of the subresultant theory for univariate polynomials,
as presented here, were developed by Jacobi (1836, 1846), Cayley (1848), Kronecker
(1873, 1878, 1881b), and Frobenius (1881). Jacobi (1836), § 4, shows that the resul-
tant is irreducible (as a polynomial in indeterminate coefficients of the two input polyno-
mials) and proves our Uniqueness Lemma 5.15 in his §15. (He only considers the normal
case.) He performs Euclid’s algorithm with pseudodivision, and obtains the description
si f + ti g = ri of the remainders. Cauchy (1840) discusses various elimination methods,
Euler’s and Bézout’s among them, proves irreducibility of the resultant, and writes down
explicitly the 5 × 5 Sylvester matrix for two polynomials of degrees 2 and 3, respectively.
Cauchy presents an early use of indices: he writes “ f = a0 xn + · · · + an ”. The lack of such
a notation had made earlier work cumbersome. Kronecker (1881b) contains many of the
(non-computational) results of this section, including Theorem 6.47. A “modern” presen-
tation along these lines is in von zur Gathen (1984b), where the goal is parallel algorithms
for the results of the Extended Euclidean Algorithm—not a topic of this text.
The general notion of a field emerged only towards the end of the 19th century; before
that, results were proven separately for various cases. As an example, Sylvester (1881)
wrote a note saying that Corollary 6.17 is also valid for polynomials with integer coeffi-
cients modulo a prime number.
Sylvester (1840) contains an explicit description of the resultant and of subresultants,
as determinants of his matrix and its submatrices, and how to compute the remainders in
the Euclidean Algorithm—which he calls derivation—from them. Apparently ignorant of
198 6. The resultant and gcd computation
Díaz & Kaltofen (1995), Theorem 6.2 and “Note Added in Proof”, analyze Algorithm
6.45, the latter also for multivariate polynomials. A method similar to Algorithm 6.45 also
works to calculate the gcd of many integers (von zur Gathen & Shparlinski (2006)). It is
particularly useful for calculating the content of a polynomial in Z[x]. Rowland & Cowles
(1986), Chen & Kao (1997, 2000), Lewin & Vadhan (1998), and Moeller (1999) use alge-
braic field extensions to reduce the amount of randomness for zero testing of polynomials.
The unsolved question of a deterministic polynomial-time zero test for polynomials given
by an arithmetic circuit has an unexpected connection to other areas of complexity theory.
See Shpilka & Yehudayoff (2010) for a survey of this active research area.
6.10. Subresultants were introduced into computer algebra by Collins (1966, 1967, 1973);
see also Brown (1971, 1978) and Brown & Traub (1971). In fact, they work with a slightly
different notion of “subresultant”; in our presentation, both definitions and theorems take
a somewhat simpler form. Their “subresultants” are constant multiples of the remainders
of the Euclidean Algorithm, rather than just constants. Mulders (1997) describes an error
in software implementations of an integration algorithm due to a confusion about subre-
sultants; see Section 22.3.
Subresultants were introduced by Sylvester (1840) and are treated in Trudi (1862) and
Gordan’s (1885) textbook, §132 ff. Habicht (1948) studies subresultants systematically
in the generic case where the coefficients of the input polynomials are indeterminates.
He calls our subresultants Nebenresultanten1 and also gives explicit formulas for the si ,ti
in the EEA in terms of determinants of submatrices of the Sylvester matrix. Von zur
Gathen (1984b) discusses the relation between the monic and the traditional Euclidean
Algorithm. The “primitive polynomial remainder sequence” discussed in Section 6.12 was
introduced by Collins (1967). Two further algorithms, based on the so-called “reduced
polynomial remainder sequence” and the “subresultant polynomial remainder sequence”,
were invented by Collins (1967) and Brown & Traub (1971). Both avoid rational arithmetic
by using pseudodivision, but in contrast to the primitive Euclidean Algorithm, they do not
divide out the complete content but a divisor of it which can be computed without gcd
calculations. The “reduced” algorithm appears to use exponential time in the worst case
(Brown 1971, page 485). This is not the case for the “subresultant” algorithm: Brown
(1978) gives an estimate for its running time which is essentially the same as the bound
for the primitive Euclidean Algorithm from Exercise 6.53. Lickteig & Roy (1996, 2001),
Ducos (2000), and Lombardi, Roy & Safey El Din (2000) present clever variants of the
“subresultant” algorithm that eliminate the factor δ from the time bound of Exercise 6.53.
Von zur Gathen & Lücking (2003) give a historic overview and a systematic treatment of
subresultants and polynomial remainder sequences.
Exercises.
6.1 Give a sharp estimate for λ(ab) when a, b ∈ Q[x].
6.2 Let a = qb + r be a division with remainder, with a, b, q, r ∈ Q[x], −1 + deg a = deg b > deg r,
and λ(a), λ(b) ≤ l ∈ N. Give estimates for λ(q) and λ(r) in terms of l (a and b need not be monic).
6.3 Let f ∈ R[x] for a Unique Factorization Domain R. Show that f = pp( f ) if and only if f is
primitive.
1 minor resultants
200 6. The resultant and gcd computation
6.4 Prove that Lemma 6.5 and Corollary 6.7 hold when c ∈ K and f , g ∈ K[x], where K is the field
of fractions of R.
6.5 Let R be a UFD on which a normal form luR in the sense of Section 3.4 is given, and let K be
the field of fractions of R. We extend cont and pp to K[x] as described in Section 6.2. Prove that
taking luK[x] ( f ) = luR (lc(pp( f ))) cont( f ) defines a normal form for K[x]. Hint: Exercise 3.8. Why
is luK[x] ( f ) = cont( f ) not a normal form?
6.6 Let f ∈ Z[x] be monic, and α ∈ Q be a root of f . Show that α ∈ Z.
6.7 Let p be a prime and ϕ: Z[x] −→ Z p [x] be defined by taking coefficients modulo p. Show that
when f ∈ Z[x], p ∤ lc( f ), and ϕ( f ) is irreducible in Z p [x], then f is irreducible in Q[x].
6.8 Show that the probability for two random polynomials in Z[x] of degree at most n and max-norm
at most A to be coprime in Q[x] is at least 1 − 1/(2A + 1). Hint: Exercise 4.18.
6.9 Consider the ring R = Z[1/2] = {a/2n : a ∈ Z, n ∈ N} of binary rationals.
(i) Prove that R is the smallest subring of Q containing Z and 1/2.
(ii) What are the units of R?
(iii) You may use the fact that R is a UFD and that any two elements of R have a gcd which is
unique up to associates. Find a normal form on R and use this to define a gcd function on R.
(iv) Determine the content and primitive part of the polynomial f = 2x2 + 6x − 4 with respect to
the three rings Z, R, and Q. Is f primitive with respect to R?
6.10 Let f , g ∈ Z[x], r = res( f , g) ∈ Z, and u ∈ Z. Prove that gcd( f (u), g(u)) divides r. Hint:
Corollary 6.21.
6.11 Let F be a field and f = ∑0≤i≤n fi xi and g = ∑0≤i≤m gi xi in F[x, y] have total degrees n and m,
respectively, so that each fi , gi ∈ F[y] with degy fi ≤ n − i, degy gi ≤ m − i. Let r = resx ( f , g) ∈
F[y]. Show that each of the (n + m)! summands contributing to r has degree at most nm, and hence
degy r ≤ nm.
6.12∗ Let R be a UFD with field of fractions F, f , g ∈ R[x] nonzero of degrees n, m, respectively,
and α1 , . . ., αn and β1 , . . ., βm the roots of f and g, respectively, in an extension field of F, counted
with multiplicities.
(i) Prove:
res( f , g) = lc( f )m ∏ g(αi ) = (−1)nm lc(g)n ∏ f (β j ) = lc( f )m lc(g)n ∏ (αi − β j ).
1≤i≤n 1≤ j≤m 1≤i≤n
1≤ j≤m
Hint: First prove the claim in the case where the roots are considered to be indeterminates. Then
apply the ring homomorphism which maps them to the actual roots.
(ii) Conclude that res( f , gh) = res( f , g) res( f , h) for all f , g, h ∈ R[x].
6.13 This exercise provides an alternative proof of Corollaries 6.20 and 6.21. Let R be a UFD and
f , g ∈ R[x] nonzero of degrees n, m, respectively, where n + m ≥ 1.
(i) Prove that
(xn+m−1 , . . ., x, 1) · Syl( f , g) = (xm−1 f , . . ., f , xn−1 g, . . ., g) in R[x]n+m ,
and conclude that there exist nonzero s,t ∈ R[x] with deg s < m and degt < n such that s f + tg =
res( f , g). Hint: Cramer’s rule.
(ii) Conclude that res( f , g) = 0 if and only if gcd( f , g) is nonconstant.
6.14∗ Let f = ∑0≤i≤n fi xi , g = ∑0≤i≤n gi xi ∈ F[x], with a field F and f0 6= 0. For 0 ≤ k < n, cross-
multiply each polynomial by the leading k + 1 terms of the other polynomial and subtract:
bk = f · ∑ gn−k+ j x j − g · ∑ fn−k+ j x j = ∑ bkl xl .
0≤ j≤k 0≤ j≤k 0≤l
Exercises 201
6.24∗ (i) Let R be a UFD and f , g, h ∈ R[x] nonzero of degrees n, m, k, respectively, such that h
divides f and g, and f ∗ = f /h and g∗ = g/h. Moreover, let S = Syl( f ∗ , g∗ ) ∈ R(n+m−2k)×(n+m−2k) ,
r = det S = res( f ∗ , g∗ ) ∈ R, and
hk 0 0 ··· 0
hk−1 hk 0 ··· 0
hk−2 hk−1 hk · · · 0
H = .. .. .. . .
.. ∈ R
(n+m−2k)×(n+m−2k)
. . . . .
.. .. ..
. . . ··· h k
the Toeplitz matrix whose rows are shifts of the coefficient sequence h0 , . . ., hk ∈ R of h. Prove that
T = HS is a matrix whose first m − k columns are shifts of the coefficient sequence of f and whose
last n − k columns are shifts of the coefficient sequence of g, and show that det T = lc(h)n+m−2k r.
(In fact, det T is the kth subresultant of f and g.)
(ii) Let R = Z, m ≤ n, and || f ||∞ , ||g||∞ ≤ A. Show that |r| ≤ (n + 1)n A2(n−k) .
6.25 Complete the proof of Theorem 6.35 by showing that p ∤ r holds if and only if pp(w) = h.
6.26 Let F be a field. This exercise discusses the task to decide whether a polynomial g ∈ F[x, y]
divides another polynomial f ∈ F[x, y], and if so, to compute the quotient f /g ∈ F[x, y], using a
modular approach. Suppose that degx g ≤ degx f = n and degy g ≤ degy f = d, and let p ∈ F[y] be
nonconstant and coprime to lcx (g).
(i) Convince yourself that g mod p divides f mod p in (F[y]/hpi)[x] if g divides f in F[x, y].
(ii) Now assume that g mod p divides f mod p. One might be tempted to assume that degy p > d
is sufficient to conclude that g divides f . Prove that this is wrong in general by considering the
example f = xn + (yd + yd−1 )xn−2 , g = x − yd , and p = yd+1 + y + 1 for n ≥ 2 and d ≥ 1.
(iii) Assume that g mod p divides f mod p and degy p > d, and let h ∈ F[x, y] be the modular
quotient, with degx f ≥ degx g + degx h, degy h < degy p, and f ≡ gh mod p. Prove that f = gh if
degy f ≥ degy g + degy h. Given p, what is the running time of this method? Compute h in the
example of (ii).
(iv) Find and prove analogs of (ii) and (iii) for f , g ∈ Z[x] and p ∈ Z. Hint: Use Mignotte’s bound
6.33 and look at the proof of Theorem 6.35.
6.27∗ This exercise discusses a modular gcd algorithm for Z[x] by Char, Geddes & Gonnet (1989)
(who in fact give an algorithm for multivariate polynomials over Z; they call it “heuristic gcd”) and
Schönhage (1985, 1988). The modulus is not a prime but a linear polynomial x − u. Let f , g ∈ Z[x]
be nonzero and primitive of degree at most n and with max-norm at most A, h = gcd( f , g) ∈ Z[x],
and u ∈ N such that u > 4A.
(i) Prove that h(u) | c = gcd( f (u), g(u)) in Z and that h(u) 6= 0.
(ii) Let v ∈ Z[x] whose coefficients vi satisfy −u/2 < vi ≤ u/2, and v(u) = c. Give an algorithm
for computing v from c.
(iii) Now assume that pp(v) | f and pp(v) | g. Writing h = pp(v)w with a primitive w ∈ Z[x], prove
that w(u) | cont(v). Use Exercise 6.23 to show that u/2 ≥ |w(u)| ≥ | lc(w)| · (u −2A)degw > (u/2)deg w
if w is nonconstant, and conclude that h = ± pp(v).
(iv) Compute gcd(3x4 + 6x3 + 5x2 − 2x − 2, x3 + 4x2 + 6x + 4) by the above method. Find out the
smallest evaluation point where the method works, and compare it to your choice of u.
Schönhage (1988) proves that for u > 4(n + 1)n A2n the divisibility conditions assumed in (iii) are
always satisfied, so that the method always terminates. He also discusses a probabilistic variant
where u is chosen at random from a “small” interval and the length of u is dynamically increased
(say, doubled) on failure, and proves that the expected length of a successful u is only O∼ (n), in
contrast to O∼ (n log A) for the deterministic algorithm.
Exercises 203
X = {(a, b) ∈ R 2 : b − a3 + 7a − 5 = 0},
Y = {(a, b) ∈ R 2 : 20a2 − 5ab − 4b2 + 35a + 35b − 21 = 0}
in R 2 . Determine the intersection of X and Y in two ways: by projecting it to the first coordinate,
and by projecting it to the second coordinate. Comment on the differences. Plot the two curves and
mark their intersection points.
√ √
6.34 Compute the minimal polynomial f ∈ Q[x] of 2 + 3 over Q. Let F192 = F19 [z]/hz2 − 2i
and α = z mod x2 − 2 ∈ F192 a square root of 2. Check that 7α is a square root of 3, and compute the
minimal polynomial of α + 7α over F19 . How is it related to f ?
6.35∗ Let α, β be two nonzero algebraic numbers, with (monic) minimal polynomials f , g ∈ Q[x] of
degrees n, m, respectively.
(i) Prove that the reversal rev( f ) = xn f (x−1 ) of f is the minimal polynomial of α−1 .
(ii) Let r = resy (rev( f )(y), g(xy)) ∈ Q[x]. Show that degx r = nm and r(αβ) = 0 (hint: Exer-
cise 6.12), and conclude that r is the minimal polynomial of αβ if it is irreducible.
(iii) Find multiples of degree nm of the minimal polynomials of aα + bβ, where a, b ∈ Q \ {0} are
arbitrary, and of α/β.
√ √ √ √
(iv) Compute the minimal polynomials of 2 − 2 3 over Q and of 2 3 3 over Q and over F13 .
6.36∗ Let α be an algebraic number and f , g ∈ Q[x] of degrees n, m ∈ N≥1 such that f is the minimal
polynomial of α. We want to compute the minimal polynomial of g(α) and therefore may assume
that n > m.
(i) Let r = resy ( f (y), x − g(y)) ∈ Q[x]. Show that degx r = n and that the minimal polynomial of
g(α) divides r (hint: Exercise 6.12). (In fact, r is a power of the minimal polynomial of g(α), which
equals r/ gcd(r, r′ ).)
√
(ii) Compute the minimal polynomials of 3 + 1 and 22/3 + 21/3 + 1 over Q.
A different algorithm is given in Exercise 12.10.
204 6. The resultant and gcd computation
6.37 This exercise discusses a variant of Lemma 6.44, due to Zippel (1993). Let R be an integral
domain, n ∈ N, S ⊆ R finite with s = #S elements, and r ∈ R[x1 , . . ., xn ] a polynomial of degree at
most di ≤ s in the variable xi .
(i) Show that r has at most sn − (s − d1 ) · · ·(s − dn ) ≤ (d1 + · · · + dn )sn−1 zeroes in Sn if it is not
the zero polynomial. Hint: Prove inductively that the number of elements of S that are not zeroes of
r is at least (s − d1 ) · · ·(s − dn ).
(ii) Let u1 , . . ., us be the elements of S. Prove that the polynomial
r= ∏ ∏ (xi − u j )
1≤i≤n 1≤ j≤di
(i) Let ||a||∞ ≤ A, ||b||∞ ≤ B, and |c| ≤ C. Prove that we have |qi | ≤ A(B + C)k−iCi and ||ri ||∞ ≤
A(B +C)k+1−iCi for k ≥ i ≥ 0, and ||r||∞ ≤ A(B +C)k+1 .
(ii) Conclude that the cost for computing q, r from a, b is O(mk2 log2 B) word operations if A ≤ B.
(iii) Let A, B,C ∈ N>0 , and assume that a has positive coefficients not smaller than A, and that
b = Cxm − b∗ for a polynomial b∗ ∈ Z[x] with deg b∗ < m and positive coefficients greater or equal
to B. Show that qi ≥ A(B +C)k−iCi for k ≥ i ≥ 0 and ||r||∞ ≥ A(B +C)k+1 . (Thus the bound from (i)
is essentially sharp.)
(iv) Give statements analogous to (i) and (ii) for pseudodivision of bivariate polynomials.
6.45 Let F be a field, f , g ∈ F[x] nonzero of degree n ≥ m, ri , si ,ti ∈ F[x] the ith row in the EEA for
f , g and some i ≥ 1, ni = deg ri , S the ni th submatrix of the Sylvester matrix of f and g, and σ = det S
the ni th subresultant.
(i) We have shown in Theorem 6.52 that the coefficients of σsi and σti are determinants of sub-
matrices of S of order n + m − 2ni − 1. Let U,V be the matrices that arise from S by replacing
the last row by (xm−ni −1 , . . ., x, 1, 0, . . ., 0) and (0, . . ., 0, xn−ni −1 , . . ., x, 1), respectively. Prove that
σsi = detU and σti = detV .
(ii) Let W be the matrix S with its last row replaced by (xm−ni −1 f , . . ., x f , f , xn−ni −1 g, . . ., xg, g).
Conclude from (i) that σri = detW .
(iii) Prove that every coefficient of σri has absolute value at most (n + 1)n−ni An+m−2ni if f , g are
in Z[x] with max-norms at most A. Hint: The coefficient of x j in σri is obtained by taking only terms
containing x j in the last row of W .
6.46∗ Let Fq be a finite field with q elements and n, m ∈ Z with n ≥ m ≥ 0.
(i) Let X0 , . . ., Xm−1 be independent random variables with prob(Xi = 0) = q−1 for all i, and ρ the
random variable that counts the longest run of zeroes in X0 , . . ., Xm−1 :
ρ = max{0 ≤ i ≤ m: ∃ j ≤ m − i X j = X j+1 = · · · = X j+i−1 = 0}.
Prove that prob(ρ ≥ d) ≤ (m − d + 1)q−d for 1 ≤ d ≤ m, and conclude that the expected value
E(ρ) = ∑ d prob(ρ = d) = ∑ prob(ρ ≥ d)
0≤d≤m 0≤d≤m
of ρ is at most 1+m/(q−1). (In fact, the better bound E(ρ) ∈ O(log m) holds; see Guibas & Odlyzko
(1980) for a proof and references.)
(ii) For two uniform random polynomials f , g ∈ Fq [x] of degrees n and m, respectively, let δ denote
the maximal degree difference of two consecutive remainders in the Euclidean Algorithm for f , g,
with δ( f , g) = 0 if g | f (the first difference deg f − deg g is not counted). Use Exercise 4.17 to
conclude that E(δ) ∈ O(log m).
(iii) Let A ≥ 1. Derive the same upper bound on the expected value of δ for random f , g ∈ Z[x] of
degrees n and m, respectively, and with || f ||∞ , ||g||∞ ≤ A.
6.47∗ Prove Theorem 6.53.
6.48∗ Prove Theorem 6.54.
6.49∗ The aim of this exercise, which follows Shoup (1991), is to prove a bound on the coefficients
of the results ri∗ , s∗i ,ti∗ of the traditional EEA for two nonzero elements f , g of Z[x] or F[x, y], where
F is a field, that is independent of the value δ from Theorems 6.53 and 6.54. So let αi = lc(ri∗ )
and ni = deg ri∗ for 0 ≤ i ≤ ℓ, σk the kth subresultant, and Sk the submatrix of the Sylvester matrix
Syl( f , g) whose determinant is σk , for 0 ≤ k ≤ n1 , as usual.
(i) Let κi , λi be the constant coefficients of si = α−1 ∗ −1 ∗
i si and ti = αi ti , respectively, for 2 ≤ i ≤ ℓ.
By Theorem 6.48 and Cramer’s rule, we have
detYi det Zi
κi = , λi = for 2 ≤ i ≤ ℓ,
σni σni
206 6. The resultant and gcd computation
where Yi , Zi are matrices that result from Sni by replacing a certain column by a unit vector. Let
γ2 = detY2 , γi = detYi−1 · det Zi − det Zi−1 · detYi for 3 ≤ i ≤ ℓ,
and prove that
σn2 (−1)i−1 σni σni−1
α2 =, αi = for 3 ≤ i ≤ ℓ.
γ2 γi αi−1
Hint: Lemma 3.15 and Theorem 6.53. Conclude that
(−1)i+ j−1
αi = (−1)(i+1)(i+2)/2 σni ∏ γj for 2 ≤ i ≤ ℓ.
2≤ j≤i
1 The instruction of children should aim gradually to combine knowing and doing. Among all sciences mathe-
matics seems to be the only one that satisfies this purpose best.
7
Application: Decoding BCH codes
Coding theory deals with the detection and correction of transmission errors. The
scenario is that a message m is sent over a transmission channel, and due to noise
on the channel some of the symbols in the received message r are different from
those in m. How can we correct them?
• ✲ •
m channel r
A simple strategy is to send m three or five times and take a majority vote on
each symbol. If errors occur too frequently, then this may not help much, but the
usual assumption is that errors occur only with fairly small probability, and then
this strategy will give an erroneous result only with much smaller probability than
accepting r as is.
However, the cost (= length) of transmission has increased by a factor of three
or five. The fundamental task of coding theory is to see whether small error prob-
ability can be achieved at reasonable cost. The basic framework of this theory was
established in the pioneering work of Shannon (1948). Error correcting codes are
employed in numerous situations, from computer networks to satellite TV, digi-
tal telephony, and the technology that make CDs so remarkably resistant against
scratches. They must not be confused with cryptography , the art of sending secret
messages that only the intended receiver can read (see Section 20).
It turns out that the tools of algebra provide many useful codes. We describe a
particular class of such codes. Let Fq be a finite field with q elements, n, k ∈ N,
and C ⊆ Fqn a k-dimensional linear subspace. C is called a linear code over Fq .
Any basis of C provides an isomorphism Fqk −→ C, and ε: Fqk −→ C ⊆ Fqn is the
encoding map. The number n is the length of C, k is its dimension, and the ratio
k/n ≤ 1 is the rate of C.
To transmit a message m, we first identify it with an element of Fqk . If, say,
q = 2 and k = 64, and we want to transmit messages in ASCII, then each ASCII
letter can be identified with an 8-bit string, and a block of 8 letters with a “word”
209
210 7. Application: Decoding BCH codes
in F264 . Now the simple code which sends each “word” three times has length 192,
dimension 64, and rate 1/3.
For an element a = (a1 , . . . , an ) ∈ Fqn , we denote by
w(a) = #{i: 1 ≤ i ≤ n, ai 6= 0}
the minimal distance of C. Since C is a linear subspace, w(a − b) ≥ d(C) for all
distinct a, b ∈ C. Our triple repetition code is C = {(a, a, a) ∈ F2192 : a ∈ F264 } and
has minimal distance d(C) = 3.
On receiving a word r ∈ Fqn , it is decoded as c ∈ C with w(r − c) minimal. Since
fewer errors are more probable, this is called maximum likelihood decoding.
If less than d(C)/2 errors occurred in transmitting the word, then this will work
correctly. If a single letter in Fq is received incorrectly with probability ε ≪ 1, and
errors occur independently, then this decoding procedure makes a mistake with
probability no more than
n
∑ ε j (1 − ε)n− j .
d(C)/2≤ j≤n
j
One of the goals in coding theory is to make this probability small without de-
creasing the rate too much.
For example, ε ≈ 10−4 seems to be a reasonable value for transmissions over
copper wires. In Table 7.1 below, we have a code C over F2 with dimension 8,
length 15, and minimal distance 5. Then this error probability becomes ≈ 5 · 10−8 :
a tremendous gain, at the cost of not even halving the transmission rate. This
is much better than the triple repetition code mentioned above, which has error
probability of about 10−5 and transmission rate 1/3.
We now describe a popular class of codes, the BCH codes, together with an
efficient way of implementing the decoding procedure.
Let Fq be a finite field and f ∈ Fq [x] be irreducible and monic with deg f = m.
Then Fqm = Fq [x]/h f i, and α = x mod f ∈ Fqm is a root of f (Lemma 4.5). Since
2 m−1
f (xq ) = f (x)q for each f ∈ Fq [x], the elements αq , αq , . . . , αq ∈ Fqm are also
i
roots of f . Furthermore, the αq for 0 ≤ i < m are all distinct (we will prove this in
Section 14.10 when α is a primitive root of unity). Hence they are all roots of f ,
m−1
and f = (x − α)(x − αq ) · · · (x − αq ). The minimal polynomial of an element
β ∈ Fqm is the monic (nonzero) polynomial f ∈ Fq [x] of least degree such that
f (β ) = 0. It exists and is unique, and for all g ∈ Fq [x], we have g(β ) = 0 if and
only if f | g. These basic facts about finite fields are explained in Section 25.4.
7. Application: Decoding BCH codes 211
(i) β n = 1, and
(ii) β k 6= 1 for 0 < k < n.
Thus a primitive nth root of unity is just an element of order n (Section 25.1)
in the multiplicative group F×qm = Fqm \ {0}. Such roots of unity will play a major
role for the Fast Fourier Transform in Section 8.2. We are now in a position to say
what a BCH code is.
D EFINITION 7.3. Let q = pr for some prime p and let n, δ ≥ 1, β a primitive nth
root of unity in some extension Fqm of Fq , and g ∈ Fq [x] the monic lcm of the
minimal polynomials of β , β 2 , . . . , β δ−1 . Then the vector space
C= ∑ xi g · Fq ⊆ Fq [x]/hxn − 1i = R ∼
= Fqn
0≤i<n−deg g
The notation BCH(q, n, δ ) does not reflect the fact that the code depends on
the choice of the primitive nth root of unity β , but the properties of the code (in
particular, its minimal distance) are essentially independent of β . We will discuss
in Section 14.10 how to construct BCH codes in general, and only give an example
here.
E XAMPLE 7.4. We will construct all BCH codes of length 15 over F2 . The fac-
torization of x15 − 1 over F2 into irreducible factors is
mod 2. We take F16 = F2 [x]/h f5 i, as in Example 7.1 (iii). For β = x mod f5 ∈ F16 ,
the elements β 3 , β 2 , β , 1 form a basis of F16 over F2 , and
F16 = {a3 β 3 + a2 β 2 + a1 β + a0 : a3 , a2 , a1 , a0 ∈ F2 }.
The parameter δ is called the designed distance of the BCH code. The next
theorem shows that the minimal distance is at least as great.
T HEOREM 7.5.
The minimal distance d(C) of the code C = BCH(q, n, δ ) is at least δ .
Furthermore we have a primitive nth root of unity β ∈ Fqm for some m ≥ 1, and for
a ∈ R we have
If we divide it by β i , we obtain
1
βi
.. ,
.
β (δ−2)i
Table 7.1 shows that the minimal distance of a BCH code can be strictly larger
than the designed distance.
Now we will see how the decoding of a BCH code works. Let C = BCH(q, n, δ )
be given via β , and let δ be odd. Suppose that c ∈ C is the transmitted and r the
received word. We want to correct up to t = (δ − 1)/2 errors. Let
Then #M ≤ t, deg u ≤ t, and deg v ≤ t. If we know u and v, then the errors can
be corrected in the following way. By evaluating u at 1, β −1 , β −2 , . . . , β −n+1 , we
obtain M. If i ∈ M, then we use the following observations to calculate ei (this is
only necessary, of course, if q > 2). The formal derivative u′ of u with respect to y
(Section 9.3) is
u′ = ∑ (−β i ) ∏ (1 − β j y).
i∈M j∈M\{i}
214 7. Application: Decoding BCH codes
Thus
v(β −i ) = ei ∏ (1 − β j−i ) = −ei β −i u′ (β −i ),
j∈M\{i}
and hence
−v(β −i )β i
ei = .
u′ (β −i )
To compute u and v, we define
v ei β i y
w= =∑ = ∑ ∑ ei (β i y)k = ∑ yk ∑ ei β ki = ∑ yk e(β k ).
u i∈M 1 − β i y i∈M k≥1 k≥1 i∈M k≥1
Notes. Coding theory was founded by Shannon (1948). There are many good texts
available, among them Berlekamp (1984), MacWilliams & Sloane (1977), and van Lint
(1982). The coding technology for CDs is described in detail in Hoffman, Leonard, Lind-
ner, Phelps, Rodger & Wall (1991).
For arbitrary codes, it is not clear how to decode them efficiently, and, in fact, a suffi-
ciently general version of the decoding problem is NP-complete (Berlekamp, McEliece
& van Tilborg 1978). BCH codes were discovered by Bose & Ray-Chaudhuri (1960) and
independently by Hocquenghem (1959). Berlekamp (1984), already in the 1968 edition,
and Massey (1965) discovered the decoding procedure for BCH codes, in a different for-
malism, and Dornstetter (1987) pointed out the relation to the Euclidean Algorithm.
Rabin (1989), Albanese, Blömer, Edmonds, Luby & Sudan (1994), and Alon, Edmonds
& Luby (1995) describe erasure codes , a related class of codes which is used for commu-
nication over faulty networks that occasionally lose (or delay) packets (but do not change
them).
Exercises.
7.1 Let F be a field, k < n positive integers, and u1 , . . ., un ∈ F distinct. For f ∈ F[x], let χ( f ) =
( f (u1 ), . . ., f (un )) ∈ F n , that is, χ is the evaluation map at u1 , . . ., un . We define the linear code
C ⊆ F n by C = {χ( f ): f ∈ F[x], deg f ≤ k}. Show that C has minimal distance n − k.
7.2 Compute the (2, 1)-Padé approximant to w from (1).
7.3 Determine generator polynomials and minimal distances of all BCH codes for q = 2 and n = 7.
Hint: The polynomial x7 − 1 ∈ F2 [x] factors into three irreducible polynomials
x7 − 1 = (x + 1)(x3 + x + 1)(x3 + x2 + 1),
and β = x mod x3 + x + 1 ∈ F8 = F2 [x]/hx3 + x + 1i is a primitive 7th root of unity.
7.4 Let C = BCH(2, 7, 3) be generated by g = x3 + x + 1 ∈ F2 [x], and β = x mod g be as in Exer-
cise 7.3. Assuming that at most one error has occurred, decode the received words
r1 = x6 + x5 + x3 + 1 mod x7 − 1, r2 = x6 + x + 1 mod x7 − 1.
Find a codeword c ∈ C such that d(r2 − c) = 2.
7.5−→ Let q = 11 and n = 10.
(i) Prove that β = 2 ∈ Fq is a primitive nth root of unity.
(ii) Show that the polynomial x10 − 1 splits into linear factors over Fq .
(iii) Tabulate generator polynomials and minimal distances of all BCH codes for the above values
of q, n, and β.
(iv) Let C = BCH(11, 10, 5). Check that the generator polynomial for C is g = x4 + 3x3 + 5x2 +
8x + 1. Assuming that at most two errors have occurred, decode the received word
r = x6 + 7x + 4 mod x10 − 1 ∈ F11 [x]/hx10 − 1i.
Part II
Newton
Isaac Newton (1642–1727) had a rather tough childhood. His father died during
his mother’s pregnancy and his mother remarried when he was three years
old—and left little Isaac in the care of his grandmother.
In 1661, Newton entered Trinity College in Cambridge, and graduated with a
BA in 1664, after an unimpressive student career. But then the university shut
down for two years because of the Great Plague, and Newton, back in his native
Woolsthorpe, laid the ground for much of his future work in the anni mirabiles
1664–1666. He invented calculus (his method of fluxions) and the law of
gravitation, and showed by experiment the prismatic composition of white light.
All this before he turned 25. (Inventing calculus means that he developed a
widely applicable theory; its roots go back, of course, to the work of many
people, Archimedes and Fermat among them.)
Back at Cambridge, Newton became Lucasian Professor of Mathematics, at the
age of 26. His former teacher, Isaac Barrow, resigned from that position to make
way for the greater scientist (and to prepare his own move into a better position as
chaplain to King Charles II). At that time, Newton was the prototype of the
“forgetful professor”, rather negligent about trifles such as his appearance. His
nephew Humphrey Newton wrote: He very rarely went to Dine in ye Hall unless
upon some Publick Dayes, & then, if He has not been minded, would go very
carelesly, wth Shooes down at Heels, Stockins unty’d, surplice on, & his Head
scarcely comb’d.
Newton did not publish his early results; this was later to work against him in
disputes over priority. This was partly due to the publishers who were reluctant to
invest in a money pit like a mathematical monograph. A 1672 paper on optics
was so heavily criticized by overbearing referees (against whose beliefs his new
and correct theory ran) that he withdrew it in the end.
Finally, he published in 1687 his masterpiece Philosophiae Naturalis Principia
Mathematica, containing his discoveries in mechanics and astronomy.
In the summer of 1669, Newton had finished his De Analysi per Æquationes
Numero Terminorum Infinitas. It circulated among English mathematicians and
also abroad (Scotland and France), but appeared in print only in 1711. Among
other things, he describes what is now called Newton’s method (or Newton
iteration) for approximating real roots of polynomial equations. He takes
ϕ = y3 − 2y − 5 ∈ Q[y] as an example, and proceeds as follows:
218
be added to the Quotient: viz. thus (neglecting p3 + 6p2 upon the
Account of their smallness) 10p − 1 = 0, or p = 0.1 is near the Truth;
therefore I write 0.1 in the Quotient, and then suppose 0.1 + q = p,
and this it’s value I substitute, as formerly, whence results
q3 + 6.3 q2 + 11.23 q + 0.061 = 0.
And since 11.23 q + 0.061 = 0 comes near to the Truth, or since q is
almost equal to −0.0054 ( viz. by dividing until as many Figures arise
as there are places betwixt the first Figures of this and the principal
Quotient) I write −0.0054 in the lower Part of the Quotient, since it is
negative.
His choice of the starting point 2 is justified by the fact that ϕ(2) = −1 < 0
< 16 = ϕ(3), so that there is a root of ϕ between 2 and 3. This example later
became a standard test for root finding methods. Joseph Raphson (1690)
discussed this approach, acknowledging Newton as the originator, and it is
sometimes called the Newton–Raphson method. Newton himself calls it “an
improved version of the procedure, expounded by Viète and simplified by
Oughtred”. We will use Newton iteration in Chapters 9 and 15.
After many years of studying
religious subjects (in particular,
the Biblical chronology), Newton
turned to public office, serving as
Member of (powerless) Parliament
until its dissolution in 1690.
In 1699, he was awarded the
moderately prestigious office of
( )
Warden of the Mint. Bell 1937 writes scathingly about this elevation: “The
crowning imbecility of the Anglo-Saxon breed is its dumb belief in public office
or an administrative position as the supreme honour for a man of intellect.”—is
that restricted to one “breed”?
The “universal genius” Leibniz, in Hannover, invented calculus independently,
probably in the mid-1670s, and published this in 1684, before Newton published
his ideas, almost two decades old by then. At first, the two men seem to have had
mutual respect for each other’s achievements. But fueled by the nationalism of
the day (so, what else is new?), this degenerated into one of the bitterest
controversies about priority in the history of science, an embarrassment for all
persons involved.
Sir Isaac Newton, knighted by Queen Anne in 1705, was President of the
Royal Society until his death at the age of 85.
219
Classical in this context came to mean something like make-believe.
Richard Phillips Feynman (1984)
1 Any mathematical task could, in principle, be solved by direct counting. However, there are counting problems
that can presently be solved in a few minutes, but for which without mathematical method a lifetime would not
be sufficient.
8
Fast multiplication
In this chapter, we introduce fast methods for multiplying integers and polyno-
mials. We start with a simple method due to Karatsuba which reduces the cost
from the classical O(n2 ) for polynomials of degree n to O(n1.59 ). The Discrete
Fourier Transform and its efficient implementation, the Fast Fourier Transform,
are the backbone of the fastest algorithms. These work only when appropriate
roots of unity are present, but Schönhage & Strassen (1971) showed how to cre-
ate “virtual” roots that lead to a multiplication cost of only O(n log n loglog n). In
Chapter 9, Newton iteration will help us extend this to fast division with remainder.
General-purpose computer algebra systems typically only implement the clas-
sical method, and sometimes Karatsuba’s. This is quite sufficient as long as one
deals with fairly small numbers or polynomials, but for many high-performance
tasks fast arithmetic is indispensable. Examples include factoring large polyno-
mials (Section 15.7), finding primes and twin primes (Notes to Chapter 18), and
computing billions of digits of π (Section 4.6) or billions of roots of Riemann’s
zeta function (Notes 18.4).
Asymptotically fast methods are standard tools in many areas of computer sci-
ence, where, say, O(n log n) sorting algorithms like quicksort or mergesort are
widely used and experiments show that they outperform the “classical” O(n2 ) sort-
ing algorithms like bubble sort or insertion sort already for values of n below 100.
In contrast, the asymptotically fast algorithms for polynomial and integer arith-
metic, in particular for multiplication, have received until recently comparatively
little attention in the computer algebra world since their invention around 1970.
Some of the reasons may be that the fast algorithms are often considerably more
complicated than the classical ones, and that the crossover points between these
algorithms may be disappointingly high when the algorithms are implemented “lit-
erally” as described in textbooks, without any further optimization. On the other
hand, experiments with highly optimized software, such as those described in Sec-
tion 9.7, show that Karatsuba’s algorithm has a fairly small crossover with the
classical algorithm, and that even faster multiplication algorithms already come
into play for moderately sized inputs. Designers of a computer algebra system
221
222 8. Fast multiplication
should carefully determine the crossover points and then, depending on the size of
the problems their system is intended to solve, decide which algorithms to offer.
Last but not least there is the intellectual beauty of asymptotic analysis. Com-
plexity theory provides a precise framework in which to compare algorithms via
their asymptotic running time (or some other measure, such as memory or paral-
lel time). For our problems, both Boolean and arithmetic complexity theory play
a role; Bürgisser, Clausen & Shokrollahi (1997) give an overview of the impres-
sive results of the latter. It provides tools for proving lower bounds, saying that
every conceivable algorithm must use at least so and so many operations, and in
lucky cases even that some algorithms are optimal. Furthermore, this crystal-clear
framework allows for a precise statement that “this new method makes progress”
and, if incorrect, its refutation. Practical results, such as the experiments reported
in this book, are also important, but often open to dispute as they take place in
the muddy waters of difficult-to-compare computing environments, difference of
opinion on the “important cases and examples”, and difficulty to reproduce. The
latter is extremely laborious or virtually impossible for a large implementation ef-
fort. As an example, Fürer (2009) improved the O(n log n loglog n) multiplication
algorithm of Schönhage & Strassen (1971); it is difficult to imagine this status of
a well-defined challenge for over a quarter century for an experimental problem.
Some areas have an accepted set of concrete benchmark problems, such as the
“most wanted” Cunningham numbers for integer factorization (see Chapter 19).
But even there, asymptotic progress is the holy grail.
The lower table on the inside back cover lists the problems in polynomial al-
gebra for which we will achieve almost linear-time algorithms in the following
chapters. The algorithms work over an arbitrary ring or field, and fast polynomial
multiplication is crucial for them. For all these problems, the input size is about n,
and the classical algorithms from Part I take quadratic time. All algorithms have
integer analogs, which—as always—are more complicated due to the carries, with
about the same running time in word operations when the input consists of n words.
recursive application will drastically reduce the overall cost (see Figure 8.2). To
explain the general approach, we assume that n = 2k for some k ∈ N, set m = n/2,
and rewrite f and g in the form f = F1 xm + F0 with F0 , F1 ∈ R[x] of degree less than
m and similarly g = G1 xm + G0 . (If deg f < n − 1, then some of the top coefficients
are zero.) Now f g = F1 G1 xn + (F0 G1 + F1 G0 )xm + F0 G0 . In this form, multiplica-
tion of f and g has been reduced to four multiplications of polynomials of degree
less than m. Multiplication by a power of x does not count as a multiplication,
since it corresponds merely to a shift of the coefficients.
So far we have not really achieved anything. But the method by Karatsuba in
Karatsuba & Ofman (1962), explained for n = 1 above, shows how this expression
for f g can be rearranged to reduce the number of multiplications of the smaller
polynomials at the expense of increasing the number of additions. Since multipli-
cation is slower than addition, a saving is obtained when n is sufficiently large. We
rewrite the product as f g = F1 G1 xn + ((F0 + F1 )(G0 + G1 ) − F0 G0 − F1 G1 )xm +
F0 G0 . This expression shows that multiplication of f and g requires only three
multiplications of polynomials of degree less than m and some additions. The
same method is now applied recursively to the smaller multiplications. If T (n)
denotes the time necessary to multiply two polynomials of degree less than n, then
T (2n) ≤ 3T (n) + cn, for some constant c. The linear term comes from the obser-
vation that addition of two polynomials of degree less than d can be done with d
operations in R.
Here is the corresponding algorithm.
1. if n = 1 then return f · g ∈ R
Figure 8.1 visualizes this algorithm in the form of an arithmetic circuit for n = 4.
We first need a lemma which will be helpful in the analysis of several recursive
algorithms. T (n) will be the cost on input size n of the algorithm, which consists
of b recursive calls with inputs of size n/2, plus some cost denoted by S(n). We
denote by log the binary logarithm.
224 8. Fast multiplication
f0 f1 f2 f3 g0 g1 g2 g3
h0 h1 h2 h3 h4 h5 h6
F IGURE 8.1: An arithmetic circuit illustrating Karatsuba’s algorithm for n = 4. The shaded
boxes are Karatsuba circuits for n = 2. A subtraction node computes the difference of its
left input minus its right input. The flow of control is from top do bottom.
L EMMA 8.2. Let b, c ∈ R>0 , d ∈ R≥0 , S, T : N≥1 −→ N≥1 be functions such that
S(2n) ≥ cS(n) for all n ∈ N≥1 , and
T (1) = d, T (n) ≤ bT (n/2) + S(n) for n = 2i and i ∈ N≥1 .
Then for i ∈ N and n = 2i we have
(
dnlog b + S(n) log n if b = c,
T (n) ≤ log b c log(b/c)
dn + b−c S(n)(n − 1) if b 6= c.
If S(1) > 0, S and T are non-decreasing, and S(2n) ≤ eS(n) for some e ∈ R>0 and
all n ∈ N≥0 , then
(
O(S(n) log n) if b = c,
T (n) ∈ log(b/c)
O(S(n)n ) if b 6= c.
8.1. Karatsuba’s multiplication algorithm 225
where the first inequality follows by induction, and we use S(2i− j ) ≤ c− j S(2i ) in
the second one. If b = c, then the last sum simplifies to S(2i ) · i. If b 6= c, then we
have a geometric sum
j
b ( bc )i − 1 c
∑ c = b
= (2i(log(b/c)) − 1),
0≤ j<i c −1
b − c
aeb
T (n) ≤ T (2i ) ≤ a · S(2i )2i log(b/c) ≤ a · S(2n) · (2n)log(b/c) ≤ S(n)nlog(b/c) ,
c
and similarly for the case b = c. ✷
T HEOREM 8.3.
Karatsuba’s algorithm 8.1 for multiplying polynomials of degree less than a power
n of 2 over a ring can be done with at most 9nlog 3 or O(n1.59 ) ring operations.
This is a substantial improvement over the classical method, since log 3 < 2.
The savings are visualized in Figure 8.2.
226 8. Fast multiplication
classical 1 iteration
2 iterations 3 iterations
4 iterations 5 iterations
F IGURE 8.2: Cost (= black area) of Karatsuba’s algorithm for increasing recursion depths.
The image approaches a fractal of dimension log2 3 ≈ 1.59.
8.2. The Discrete Fourier Transform and the Fast Fourier Transform 227
If n is not a power of 2, then there are two ways to proceed. The first one is
to apply the algorithm for the least power of 2 that is greater than n, that is, for
2⌈log n⌉ . This is easy to analyze, but introduces an additional factor of 3 in the
running time, which is annoying if n is only slightly greater than a power of 2. The
second possibility is to split the polynomials into blocks of about half the degree
each time in the recursive process. This leads to an algorithm that performs better
than the first variant, but the analysis is somewhat more involved; see Exercise 8.5.
The same method applies to multiplication of two (positive) integers a and b in
r-ary representation, say with r = 264 (see Section 2.1). When they have length at
most n, the classical integer multiplication algorithm requires O(n2 ) word opera-
tions (Section 2.3). Karatsuba’s algorithm for integers writes a = A1 264m + A0 and
b = B1 264m + B0 , where A0 , A1 , B0 , B1 < 264m and n = 2m is assumed to be a power
of 2. Then ab = A1 B1 264n + ((A0 + A1 )(B0 + B1 ) − A0 B0 − A1 B1 )264m + A0 B0 . As
in the polynomial case, multiplication of two integers has been reduced to multi-
plication of three integers of at most half the size plus O(n) word operations (if
A0 + A1 or B0 + B1 exceed 264n , then one has to take extra care of the leading bits,
or alternatively computes A0 B1 + A1 B0 = A0 B0 + A1 B1 − (A0 − A1 )(B0 − B1 )). This
leads to the following theorem.
T HEOREM 8.4.
Multiplication of two integers of length at most n words can be done with O(nlog 3 )
or O(n1.59 ) word operations using Karatsuba’s algorithm.
8.2. The Discrete Fourier Transform and the Fast Fourier Transform
In this section, we discuss a polynomial multiplication algorithm which works in
nearly linear time. It requires that the coefficient ring contain certain roots of unity.
We recall that an element a of a ring R is a zero divisor if there exists a nonzero
b ∈ R with ab = 0. In particular, 0 is a zero divisor (unless R is the trivial ring
{0}). The reader should note that in many algebra texts, 0 is not considered a zero
divisor.
2πi·2
i=e 8
2πi·3 2πi·1
e 8 e 8
2πi·4 2πi·0
−1 = e 8 1=e 8
2πi·5 2πi·7
e 8 e 8
2πi·6
−i = e 8
F IGURE 8.3: The 8th roots of unity in C. The black square has order 1, the black circle
order 2, the two gray circles order 4, and the four white circles are the primitive 8th roots
of unity.
E XAMPLE
√ 8.6. (i) ω = e2πi/8 ∈ R = C is a primitive 8th root of unity, where
i = −1; see Figure 8.3.
(ii) Z8 has no primitive square root of unity, despite the fact that 32 ≡ 1, since 2
is not a unit.
(iii) For the “Fermat prime” 24 + 1 = 17, the element 3 is a primitive 16th root
of unity in Z17 , and 2 is not. ✸
The following lemma extends the property of Definition 8.5 (ii) for ω ℓ − 1 from
ℓ = n/t to all ℓ that are not divisible by n.
L EMMA 8.7. Let R be a ring, ℓ, n ∈ N≥1 such that 1 ≤ ℓ < n, and ω ∈ R a primitive
nth root of unity. Then
8.2. The Discrete Fourier Transform and the Fast Fourier Transform 229
which holds for all m ∈ N and c ∈ R (in fact, even for an indeterminate c).
(i) Let g = gcd(ℓ, n) and u, v ∈ Z so that uℓ + vn = g. Since 1 ≤ g < n, we
can choose a prime divisor t of n so that g divides n/t. Letting c = ω g and m =
n/tg in (1), we obtain a · (ω g − 1) = ω n/t − 1 for some a ∈ R. If b ∈ R satisfies
b · (ω g − 1) = 0, then also b · (ω n/t − 1) = 0, and hence b = 0 since ω n/t − 1 is not
a zero divisor. Thus ω g − 1 is not a zero divisor either.
Furthermore, (1) with c = ω ℓ and m = u implies that ω ℓ − 1 divides ω uℓ − 1 =
ω ω − 1 = ω g − 1. The same argument as above implies that ω ℓ − 1 is not a zero
uℓ vn
divisor.
(ii) By letting c = ω ℓ and m = n in (1), we see that
(ω ℓ − 1) ∑ (ω ℓ ) j = ω ℓn − 1 = 0.
0≤ j<n
When R is an integral domain (for example, a field), then (i) simply says ω ℓ 6= 1,
and it is sufficient to check this for ℓ = n/t, with t running through the prime
divisors of n, for the last property required of a primitive nth root of unity.
The following lemma, proven in Exercise 8.18, says when primitive roots of
unity exist in a finite field Fq (as defined on page 73) with q elements.
L EMMA 8.8. For a prime power q and n ∈ N, a finite field Fq contains a primitive
nth root of unity if and only if n divides q − 1.
h = f ∗n g = ∑ hℓ xℓ ∈ R[x],
0≤ℓ<n
where
hℓ = ∑ f j gk = ∑ f j gℓ− j for 0 ≤ ℓ < n,
j+k≡ℓ mod n 0≤ j<n
with index arithmetic modulo n. If n is clear from the context, we will simply
write ∗ for ∗n . If we regard the coefficients as vectors in Rn , then h is called
the cyclic convolution of the vectors f and g.
The special form of the binomial x4 − u makes division with remainder particularly
easy: the quotient is the upper part of f g, and the remainder is the lower part of f g
plus u times the upper part. In particular, for u = 1 we have f g ≡ 3x3 + 5x2 + 4x + 2
mod x4 − 1, or equivalently, f ∗4 g = 3x3 + 5x2 + 4x + 2. A similar phenomenon
will help us in the FFT algorithm below. ✸
We may also consider the map R[x] −→ Rn that evaluates f at ω 0 , . . . , ω n−1 . Its
kernel is hxn − 1i, and the lemma says that DFTω : R[x]/hxn − 1i −→ Rn is a homo-
morphism of R-algebras, where multiplication in Rn is pointwise multiplication of
vectors. The following commutative diagram illustrates this:
2 DFTω × DFTω✲
R[x]/hxn − 1i Rn × Rn
cyclic pointwise
(2)
convolution multiplication
❄ ❄
n
R[x]/hx − 1i ✲ Rn
DFTω
In fact, DFTω is an isomorphism. If R is a field, then this is the special case of the
Chinese Remainder Theorem 5.3, where m j = x − ω j for 0 ≤ j < n. We discussed
in Section 5.1 the general principle of change of representation and will now see
how the particular example (2) gives rise to a fast multiplication algorithm.
In the following, polynomials of degree less than n over an integral domain R
are—besides the usual dense representation by their coefficient vectors—represen-
ted by their values at n distinct points u0 , . . . , un−1 ∈ R, namely the powers u j = ω j
for 0 ≤ j < n of a primitive nth root of unity ω ∈ R. The reason for consider-
ing the value representation is that multiplication in that representation is easy:
If f (u0 ), . . . , f (un−1 ) and g(u0 ), . . . , g(un−1 ) are the values of two polynomials f
and g with deg( f g) < n at n distinct points, then the values of the product poly-
nomial f g at those points are f (u0 ) · g(u0 ), . . . , f (un−1 ) · g(un−1 ). Hence the cost
of polynomial multiplication in the value representation is linear in the degree,
while we do not know how to multiply polynomials in the dense representation
in linear time. Thus a fast way of doing multipoint evaluation and interpolation
leads to a fast polynomial multiplication algorithm: evaluate the two input poly-
nomials, multiply the results pointwise, and finally interpolate to get the product
polynomial.
The Discrete Fourier Transform is a special multipoint evaluation at the powers
1, ω , . . . , ω n−1 of a primitive nth root of unity ω , and we will now show that both
the DFT and its inverse, the interpolation at the powers of ω , can be computed with
O(n log n) operations in R, and thus obtain an O(n log n) multiplication algorithm
for polynomials. In Chapter 10, we will see a fast algorithm for evaluation and
interpolation at arbitrary points.
First we show that interpolation at the powers of ω is essentially again a Discrete
Fourier Transform. The Vandermonde matrix
232 8. Fast multiplication
1 1 1 ··· 1
1 ω ω2 ··· ω n−1
1 ω2 ω4 ··· ω 2(n−1)
Vω = VDM(1, ω , . . . , ω n−1 ) =
.. .. .. .. ..
. . . . .
2
1 ω n−1 ω 2(n−1) · · · ω (n−1)
= (ω jk )0≤ j,k<n ∈ Rn×n
is the matrix of the multipoint evaluation map DFTω (Section 5.2).
√
E XAMPLE 8.12. For the primitive 4th root of unity ω = i = −1 ∈ C, we have
1 1 1 1
1 i −1 −i
Vi = VDM(1, i, −1, −i) = 1 −1 1 −1 . ✸
1 −i −1 i
T HEOREM 8.13.
Let R be a ring (commutative, with 1), n ∈ N≥1 , and ω ∈ R be a primitive nth root
of unity. Then ω −1 is a primitive nth root of unity and Vω · Vω−1 = nI , where I is
the n × n identity matrix.
P ROOF. Exercise 8.13 shows that ω −1 is a primitive nth root of unity. Let 0 ≤
j, ℓ < n, and
u = (Vω ·Vω−1 ) jℓ = ∑ (Vω ) jk (Vω−1 )kℓ = ∑ ω jk ω −kℓ = ∑ (ω j−ℓ )k .
0≤k<n 0≤k<n 0≤k<n
In particular, the theorem implies that (Vω )−1 = n−1Vω−1 , so that computing the
inverse is fairly easy.
1 1 1 1
1 1 −i −1 i
E XAMPLE 8.12 (continued). Vi−1 = . ✸
4 1 −1 1 −1
1 i −1 −i
8.2. The Discrete Fourier Transform and the Fast Fourier Transform 233
for some q0 , r0 , q1 , r1 ∈ R[x] of degree less than n/2. Due to the special form of
the divisor polynomials, the computation of the remainders r0 and r1 (we do not
actually need the quotients) can be done by adding the upper n/2 coefficients of
f to, respectively subtracting them from, the lower n/2 coefficients, as in Exam-
ple 8.10, at a total cost of n operations in R. In other words, if f = F1 xn/2 + F0 with
deg F0 , deg F1 < n/2, then xn/2 − 1 divides f − F0 − F1 , and hence r0 = F0 + F1 ;
similarly r1 = F0 − F1 . If we plug in a power of ω for x in (3), we find
f (ω 2ℓ ) = q0 (ω 2ℓ )(ω nℓ − 1) + r0 (ω 2ℓ ) = r0 (ω 2ℓ ),
f (ω 2ℓ+1 ) = q1 (ω 2ℓ+1 )(ω nℓ ω n/2 + 1) + r1 (ω 2ℓ+1 ) = r1 (ω 2ℓ+1 )
for all 0 ≤ ℓ < n/2. We have used the facts that ω nℓ = 1 and ω n/2 = −1, since
and ω n/2 − 1 is not a zero divisor. It remains to evaluate r0 at the even powers of
ω and r1 at the odd powers. Now ω 2 is a primitive (n/2)th root of unity (Exer-
cise 8.13), and hence the first task is a DFT of order n/2. But also the evaluation
of r1 can be reduced to a DFT of order n/2 by noting that r1 (ω 2ℓ+1 ) = r1∗ (ω 2ℓ ) for
r1∗ = r1 (ω x). The computation of the coefficients of r1∗ uses n/2 multiplications by
powers of ω . If n is a power of 2, we can proceed recursively to evaluate r0 and r1∗
at the powers 1, ω 2 , . . . , ω 2n−2 of ω 2 , and obtain the following algorithm.
1. if n = 1 then return ( f0 )
f0 f1 f2 f3 f4 f5 f6 f7
ω0 ω1 ω2 ω3
fj f j+n/2
ω0 ω2 ω0 ω2
ωj
( f j + f j+n/2 )
( f j − f j+n/2 )ω j
ω0 ω0 ω0 ω0
f (1) f (ω) f (ω 2 ) f (ω 3 ) f (ω 4 ) f (ω 5 ) f (ω 6 ) f (ω 7 )
F IGURE 8.4: A butterfly operation (left) and an arithmetic circuit computing the FFT for
n = 8 (right). A subtraction node computes the difference of its left input minus its right
input.
T HEOREM 8.15.
Let n be a power of 2 and ω ∈ R be a primitive nth root of unity. Then Algo-
rithm 8.14 correctly computes DFTω using n log n additions in R and (n/2) log n
multiplications by powers of ω , in total 32 n log n ring operations.
r0 (ω 2ℓ ) = ∑ ( f j + f j+n/2 )ω 2ℓ j = ∑ f j ω 2ℓ j + ∑ f j+n/2 ω 2ℓ j ω ℓn
0≤ j<n/2 0≤ j<n/2 0≤ j<n/2
2ℓ j 2ℓ
= ∑ f jω = f (ω ),
0≤ j<n
r1∗ (ω 2ℓ ) = ∑ ( f j − f j+n/2 )ω j ω 2ℓ j
0≤ j<n/2
= ∑ f j ω (2ℓ+1) j = f (ω 2ℓ+1 ).
0≤ j<n
Let S(n) and T (n) denote the number of additions and multiplications in R,
respectively, that the algorithm uses for input size n. The cost for the individ-
ual steps is: 0 in steps 1 and 4, n additions and n/2 multiplications in step 2,
and 2S(n/2) additions and 2T (n/2) multiplications in step 3. This yields S(1) =
T (1) = 0, S(n) = 2S(n/2) + n, and T (n) = 2T (n/2) + n/2, and by unfolding the
recursions we find that S(n) = n log n and T (n) = 12 n log n. ✷
The FFT can be nicely illustrated in form of an arithmetic circuit. It is built from
elementary blocks that execute step 2 of the above algorithm for one particular
value of j, called a butterfly operation. One such building block as well as the
entire circuit for n = 8 are shown in Figure 8.4.
Figure 8.5 illustrates the cost of Algorithm 8.14 if the recursion is stopped at
depths 0, 1, . . . , 5 and the remaining subproblems are computed by Horner’s rule.
The diagonal lines visualize the linear cost at each recursive step which—in con-
trast to Karatsuba’s method—contributes to the overall cost. Now we use the FFT
to compute convolutions and products of polynomials quickly.
1. compute ω 2 , . . . , ω n−1
2. α ←− DFTω ( f ), β ←− DFTω (g)
3. γ ←− α · β { pointwise product }
1
4. return DFTω −1 (γ ) = DFTω−1 (γ )
n
236 8. Fast multiplication
classical 1 iteration
2 iterations 3 iterations
4 iterations 5 iterations
F IGURE 8.5: Cost of the FFT for increasing recursion depths. The black area is propor-
tional to the total work.
8.2. The Discrete Fourier Transform and the Fast Fourier Transform 237
T HEOREM 8.18.
Let R be a ring that supports the FFT, and n = 2k for some k ∈ N. Then convolution
in R[x]/hxn − 1i and multiplication of polynomials f , g ∈ R[x] with deg( f g) < n
can be performed using 3n log n additions in R, 32 n log n + n − 2 multiplications by
powers of ω , n multiplications in R, and n divisions by n, in total 92 n log n + O(n)
arithmetic operations.
1. n − 2 multiplications by ω ,
3. n multiplications,
C OROLLARY 8.19.
If R supports the FFT, then polynomials in R[x] of degree less than n can be mul-
tiplied with 18n log n + O(n) operations in R.
238 8. Fast multiplication
f= ∑ f j xm j , g= ∑ g j xm j ,
0≤ j<t 0≤ j<t
with f j , g j ∈ R[x] of degree less than m for 0 ≤ j < t. With f ′ = ∑0≤ j<t f j y j , g′ =
∑0≤ j<t g j y j ∈ R[x, y], we then have f = f ′ (x, xm ) and g = g′ (x, xm ). It is sufficient
to compute f ′ g′ modulo yt + 1, since
We want to compute h′ ∈ R[x, y] with degy h′ < t satisfying (4) (this uniquely de-
termines h′ ; see Section 2.4). Comparing coefficients of y j for j ≥ t, we see that
degx q′ ≤ degx ( f ′ g′ ) < 2m and conclude that
With f ∗ = f ′ mod (x2m + 1), g∗ = g′ mod (x2m + 1), and h∗ = h′ mod (x2m + 1)
in D[y], (4) implies
f ∗ g∗ ≡ h∗ mod (yt + 1) in D[y]. (6)
8.3. Schönhage and Strassen’s multiplication algorithm 239
Since the three polynomials have degrees in x less than 2m, by (5), reducing them
modulo x2m + 1 is just taking a different algebraic meaning of the same coefficient
array. In particular, the coefficients of h′ ∈ R[x][y] can be read off the coefficients
of h∗ ∈ D[y].
The following picture illustrates the relations between h, h′ and h∗ ; the arrows
are ring homomorphisms.
h′ ∈ R[x, y]
✠ ❘
∗
h ∈ R[x] h ∈ D[y]
or
f ∗ (η y)g∗ (η y) ≡ h∗ (η y) mod (yt − 1), (7)
since ηt = −1. Given f ∗ (η y) and g∗ (η y) in D[y], Algorithm 8.16 computes h∗ (η y)
with O(t logt) operations in D, using essentially three t-point FFTs. A multipli-
cation of two elements in D is again a negative wrapped convolution over R which
can be handled recursively. Putting things together, we obtain the following algo-
rithm.
1. if k ≤ 2 then
call the classical algorithm 2.3 (or Karatsuba’s algorithm 8.1) to com-
pute f · g
return f g rem xn + 1
240 8. Fast multiplication
2. m ←− 2⌊k/2⌋ , t ←− n/m
let f ′ , g′ ∈ R[x, y] with degx f ′ , degx g′ < m such that f = f ′ (x, xm ) and g =
g′ (x, xm )
3. let D = R[x]/hx2m + 1i
if t = 2m then η ←− x mod (x2m + 1) else η ←− x2 mod (x2m + 1)
{ η is a primitive 2tth root of unity }
f ∗ ←− f ′ mod (x2m + 1), g∗ ←− g′ mod (x2m + 1)
call the fast convolution algorithm 8.16 with ω = η 2 to compute h∗ ∈ D[y]
of degree less than t such that
f ∗ = y2 + 2η + 3, g∗ = (2η + 1)y + 4η + 2,
f (η y) = η 2 y2 + 2η + 3,
∗
g (η y) = (2η 2 + η )y + 4η + 2.
∗
Now Algorithm 8.16 (or, in this case, a direct calculation of f ∗ (η y)g∗ (η y)) yields
and in fact equality holds in the second line since the degrees of both sides are less
than 8. ✸
T HEOREM 8.22.
Algorithm 8.20 works correctly and uses 92 n log n loglog n + O(n log n) operations
in R.
8.3. Schönhage and Strassen’s multiplication algorithm 241
P ROOF. Correctness follows from the discussion preceding the algorithm. Let
T (k) denote the number of arithmetic operations in R that the algorithm uses on
inputs of size n = 2k . The cost for step 1 is O(1). In step 2, no arithmetic operations
in R are performed. By Theorem 8.18, Algorithm 8.16 uses 3t logt additions in D
and 32 t logt multiplications by powers of ω = η 2 in the FFT-steps, plus t divisions
by t ∈ R and t “essential” multiplications of two arbitrary elements of D (the pow-
ers of ω in step 1 of Algorithm 8.16 need not be computed). One addition in D costs
2m additions in R, one division by t costs 2m divisions in R, and one multiplication
of a = ∑0≤ j<2m a j x j mod (x2m + 1) by a power of η corresponds to a cyclic shift of
the coordinates ai and a sign inversion of the “wrapped around” coordinates, using
at most 2m operations in R. Each essential multiplication in D is done recursively,
using T (⌊k/2⌋+1) operations in R. The computation of f ∗ (η y), g∗ (η y) from f ∗ , g∗
and of h∗ = h∗ (η (η −1 y)) from h∗ (η y) amounts to 3t multiplications by powers of η .
Thus the total cost of step 3 is at most 9mt logt + 8mt + t · T (⌊k/2⌋ + 1). In step 4,
the only cost is at most n = mt additions for the computation of h from h′ . Together,
we have j k k l k m
T (k) ≤ 2⌈k/2⌉ T + 1 + 9 · 2k +1
2 2
if k > 2. Thus
j k + 1 k l k + 1 m
2−k T (k + 1) + 45 ≤ 2⌈(k+1)/2⌉−k T + 1 + 90 + 18 + 1 − 45
2 2
l k m j k k 1
= 2 2−⌈k/2⌉ T + 1 + 45 + 18 −
2 2 2
if k > 1, where we used ⌊(k + 1)/2⌋ = ⌈k/2⌉ and ⌈(k + 1)/2⌉ = ⌊k/2⌋ + 1. Writing
S(k) = (2−k T (k + 1) + 45)/(k − 1), we obtain
We note that the value of m in step 2 and also the value of n need not be powers
of 2; it is sufficient that t be a power of 2 dividing 2m. This allows for choices
of n such as n = 3 · 2k or n = 5 · 3k , which have the advantage that fewer zeroes
have to be padded when deg( f g) is just below such a number. For example, if
deg( f g) = 3·22l−1 −1 for some l ∈ N, then the literal approach would use n = 22l+1
and m = 2l , t = 2l+1 in step 2, while it seems better to choose n = 3 · 22l−1 , with
m = 3 · 2l−1 and t = 2l in step 2.
Exercise 8.30 discusses the analog of Algorithm 8.20 when 3 is a unit in R, using
a 3-adic FFT. In particular, this covers the case when R is a field of characteristic 2.
What about arbitrary rings R? All divisions in Algorithm 8.16 are by powers of
two. We replace the last line by
Then it uses only additions and multiplications, but no divisions in R, and returns
n · (a ∗ b) instead of a ∗ b. If we use this modified algorithm in step 3 of Algo-
rithm 8.20, then Exercise 8.31 shows that the modified algorithm works over any
(commutative) ring and returns 2κ · h for some κ ∈ N. Similar modifications of the
3-adic FFT algorithm from Exercise 8.30 lead to an algorithm that computes 3λ · h
for some λ ∈ N.
If we now want to compute the product of two polynomials f , g ∈ R[x] of degree
less than n, we choose k, l ∈ N such that 2k−2 < n ≤ 2k−1 and 3l−1 < n ≤ 3l and
call both the modified 2-adic and the modified 3-adic algorithm to compute 2κ f g
and 3λ f g. Using the Extended Euclidean Algorithm, we find s,t ∈ Z such that
s2κ +t3λ = 1, and obtain s2κ f g +t3λ f g = f g. Thus we have the following result.
T HEOREM 8.23.
Over any commutative ring R, polynomials of degree less than n can be multiplied
using at most (18+72 log3 2) n log n loglog n+O(n log n) or 63.43 n log n loglog n+
O(n log n) arithmetic operations in R.
The constant 63.43 is probably not the best possible, and the reader is encour-
aged to figure out a smaller constant herself.
8.3. Schönhage and Strassen’s multiplication algorithm 243
We do not present the details of this algorithm (it is partly described in Exer-
cise 8.36), but rather a different approach for fast integer multiplication which
only works for integers of bounded length but seems sufficient for most prac-
tical purposes (inputs up to millions of gigabytes). Let a = ∑0≤ j<n a j 264 j , b =
∑0≤k<n bk 264k in 264 -ary representation, and A = ∑0≤ j<n a j x j , B = ∑0≤k<n bk xk in
Z[x], so that a = A(264 ) and b = B(264 ). If C = AB = ∑0≤l<2n−1 cl xl ∈ Z[x], then
we obtain ab = C(264 ). Now 0 ≤ cl = ∑ j+k=l a j bk < ∑ j+k=l 2128 ≤ n · 2128 for all l.
We assume that n < 261 , take three single precision primes p1 , p2 , p3 between 263
and 264 , and multiply A and B modulo each p j . Then the Chinese Remainder
Theorem guarantees that we can reconstruct AB from its images modulo the three
primes.
For the three modular multiplications, we want to use the FFT multiplication
algorithm 8.16, and this requires that each p j − 1 be divisible by a sufficiently
high power of 2; we will call such a prime a Fourier prime. More precisely, if
t = ⌈log(2n − 1)⌉ and 2t divides p j − 1 for j = 1, 2, 3, then F p j contains a primitive
2t th root of unity, by Lemma 8.8, and we may use Algorithm 8.16 with R = F p j to
compute AB mod p j . If n is not too large, then three such primes can be found by
successively testing 2t +1, 2·2t +1, 3·2t +1, . . . for primality, using the algorithms
from Chapter 18. (Exercise 18.16 shows how to find a primitive 2t th root of unity
modulo such a prime.) For example, for each of the six pairs
k 29 71 75 95 108 123
ω 21 287 149 55 64 493
p = k · 257 + 1 is prime and ω is the least positive primitive 257 th root of unity
modulo p. In fact, these are all primes p below 264 such that 257 divides p − 1,
and all but the first one are greater than 263 . (For p = 108 · 257 + 1, p − 1 is even
divisible by 259 ; it is the only prime below 264 with that property, and there is no
prime p below 264 such that p − 1 is divisible by a higher power of 2.) Three such
pairs may be precomputed once and for all. Here is the corresponding algorithm.
In the last line, log∗ is the number of times that logarithms have to be taken until
the result is less than 1. Thus log∗ n ≤ 5 for n < 265 536 . For practical purposes,
log∗ n behaves like a constant, and Fürer’s result comes close to being O(n log n),
which is also conjectured to be optimal.
In principle, any multiplication algorithm leads to a multiplication time. Table
8.6 summarizes the multiplication times for the algorithms we discuss. You find a
8.4. Multiplication in Z[x] and R[x, y] 245
Algorithm M(n)
classical 2n2
Karatsuba (Karatsuba & Ofman 1962) O(n1.59 )
FFT multiplication (provided that R supports the FFT) O(n log n)
Schönhage & Strassen (1971), Schönhage (1977)
O(n log n loglog n)
Cantor & Kaltofen (1991); FFT based
∗ n)
Fürer (2009); FFT based n log n · 2O(log
TABLE 8.6: Various polynomial multiplication algorithms and their running times.
similar table for quick reference on the inside back cover. In the remainder of this
text, we will assume that the multiplication time satisfies
M(n)/n ≥ M(m)/m if n ≥ m, M(mn) ≤ m2 M(n), (8)
for all n, m ∈ N>0 . The first inequality yields the superlinearity properties
M(mn) ≥ m · M(n), M(n + m) ≥ M(n) + M(m), and M(n) ≥ n (9)
for all m, n ∈ N>0 (Exercise 8.33). The last property in (8) says that M is “at most
quadratic” and implies that M(cn) ∈ O(M(n)) for all positive constants c. Theorem
8.23 implies that we may take
M(n) ∈ 63.43 n log n loglog n + O(n log n)
for an arbitrary commutative ring R, and we will mainly use this result.
for 0 ≤ k ≤ 2n−2. If we choose t ∈ N so that n2128l < 264t , then the coefficients of h
can be read off the 264 -adic representation of the number h(264t ) = f (264t )g(264t );
246 8. Fast multiplication
C OROLLARY 8.27.
Polynomials in Z[x] of degree less than n with coefficients of length at most l can
be multiplied using O(M(n(l + log n))) or O∼ (nl) word operations.
and we see that the coefficients of h can be read off the image of f g modulo
x − y2d−1 , which in turn can be computed using fast multiplication of univariate
Notes 247
polynomials in R[y]. Since the degrees of f (y2d−1 , y) and g(y2d−1 , y) are at most
(n − 1)(2d − 1) + d − 1 = 2nd − n − d, we have the following result.
C OROLLARY 8.28.
Polynomials in R[x, y], where R is a ring (commutative, with 1), of degree less
than n in x and less than d in y can be multiplied using O(M(nd)) or O∼ (nd) ring
operations.
Notes. 8.1. Karatsuba and Ofman participated in a seminar run by Kolmogorov, who had
conjectured that the quadratic cost for multiplication cannot be beaten and then actually
wrote (probably with Ofman) and submitted their paper for publication. Karatsuba (1995)
says about the work that made him famous: I learned about the article only when I was
given its reprints.
8.2. Cooley & Tukey (1965) discovered the FFT for computer science, causing a revolution
in digital signal processing methods. Its original invention goes back a century and a half:
Gauß found it around 1805, but it appeared only posthumously (Gauß 1866). Gauß also
discovered the usual Fourier Transform, before Fourier did so in 1807 (published in Fou-
rier 1822). The algorithm was rediscovered several times over the years. The fascinating
history of the FFT is described in Cooley (1987, 1990) and Heideman, Johnson & Burrus
(1984).
8.3. Algorithm 8.20 is an adaption to polynomials of Schönhage & Strassen’s (1971) in-
teger multiplication algorithm, where 2 plays the role of our x; Schönhage (1977) solved
the additional complication that occurs in characteristic 2 by using a 3-adic FFT (Exer-
cise 8.30). These two papers, and also Cantor & Kaltofen (1991), showed Theorem 8.23.
Before Schönhage & Strassen’s breakthrough, Toom (1963), Cook (1966), Schönhage
(1966), and Strassen (1968, unpublished) had found n1+o(1) multiplication algorithms for
integers of length n, but Schönhage & Strassen set the world record that stood for a quarter
century, until Fürer (2009). Gentleman & Sande (1966) had earlier proposed to use the
FFT for polynomial multiplication. See Knuth (1998), §4.3.3, for a description of some of
these methods. An alternative, also briefly discussed there, is to employ the FFT over the
complex numbers, with approximations to sufficiently high precision of the complex roots
of unity. This is used in calculating π to record accuracy; FFT multiplication uses 90%
of the CPU time for such high precision calculations (Kanada (1988); see Section 4.6).
Bernstein (2001) gives an exhaustive discussion of fast multiplication routines. Schönhage
showed that n-bit integers can be multiplied on random access machines (with cost m to
access an m-bit address) using O(n log n) word operations (see Knuth (1998), §4.3.3 C).
Pollard (1971) presents an FFT-based multiplication algorithm for polynomials over
finite fields, over Z, and for integers, including an implementation report, but without
asymptotic analysis or a general construction of the required primitive roots of unity. He
also gives the three primes FFT algorithm 8.25; see also Lipson (1981), §IX.2.2. Moenck
(1976) presents an early implementation report.
For some of the multiplication times that we use, the required properties (8) may fail to
hold for n ≤ 2. We will ignore this systematically.
8.4. Kronecker (1882), §4, invented his substitution for multivariate polynomials; its effect
is to keep distinct coefficients “apart” after the substitution. The algorithm for multiplying
in Z[x] modulo several small primes appears in Pollard (1971).
248 8. Fast multiplication
Exercises.
8.1 Given the real and imaginary parts √ a0 , a1 , b0 , b1 ∈ R of two nonzero complex numbers z1 =
a0 + a1 i and z2 = b0 + b1 i, where i = −1, show how to compute the real and imaginary parts of
the quotient z1 /z2 ∈ C using at most 7 multiplications and divisions in R. Draw an arithmetic circuit
illustrating your algorithm. Can you achieve at most 6 real multiplications and divisions?
8.2 Let R be a ring (commutative, with 1) and f , g ∈ R[x, y], and assume that f and g have degrees
less than m in y and less than n in x. Let h = f · g.
(i) Using classical univariate polynomial multiplication and viewing R[x, y] as R[y][x], bound the
number of arithmetic operations in R to compute h.
(ii) Using Karatsuba’s algorithm bound the number of operations in R to compute h.
(iii) Generalize parts (i) and (ii) to polynomials in an arbitrary number of variables.
8.3 With notation as in Lemma 8.2, assume that in addition S and T are monotonically increasing
and S(2n) ≤ 4S(n) for all n ∈ N>0 . Derive a tight upper bound on T (n) that is valid for all n ∈ N>0
and not only for powers of two. Hint: n lies in some interval [2k−1 + 1, 2k ].
8.4 We have seen in Section 2.3 that the classical multiplication method for polynomials of degree
less than n requires 2n2 − 2n + 1 ring operations. For which values of n = 2k is this larger than the
9 · 3k − 8 · 2k for Karatsuba’s algorithm?
8.5∗ Let R be a ring (commutative, with 1) and f , g ∈ R[x] of degrees less than n. You are to analyze
two variants of Karatsuba’s algorithm 8.1 when n is not a power of two.
(i) The first variant is to call Algorithm 8.1 with 2⌈log n⌉ instead of n. Show that this takes at most
9 · 3⌈logn⌉ ≤ 27nlog 3 operations in R.
(ii) Let m = ⌈n/2⌉, and modify Algorithm 8.1 so that it divides f and g into blocks of degree less
than m. If T (n) denotes the cost of this algorithm, show that T (1) = 1 and T (n) ≤ 3T (⌈n/2⌉) + 4n.
(iii) Show that T (2k ) ≤ 9 · 3k − 8 · 2k and T (2k−1 + 1) ≤ 6 · 3k − 4 · 2k − 2 for all k ∈ N>0 , and
compare this to (i) for n = 2k and n = 2k−1 + 1. Plot the curves of the two running time bounds from
(i) and (ii) for n ≤ 50.
(iv) Implement both algorithms for R = Z. Experiment with various values of n, say 2 ≤ n ≤ 50 and
n = 100, 200, . . ., 1000. Use random polynomials with one-digit coefficients, and also with n-digit
coefficients.
8.6∗ Karatsuba’s algorithm is slower for small inputs than classical multiplication. You are to inves-
tigate a hybrid algorithm which recursively does Karatsuba until the degrees get smaller than some
bound 2d ∈ N and then switches to classical multiplication, that is, we replace line 1 of Karatsuba’s
algorithm 8.1 by
1. if n ≤ 2d then call Algorithm 2.3 to compute f g ∈ R[x]
Algorithm 8.1 then corresponds to d = 0. Let T (n) denote the cost of this algorithm when n = 2k for
some k ∈ N, and prove that T (n) ≤ γ(d)nlog 3 − 8n holds for n ≥ 2d , where γ(d) depends only on d.
Find the value of d ∈ N that minimizes γ(d), and compare the result to the running time bound of
Theorem 8.3.
8.7 Karatsuba’s method for polynomial multiplication can be generalized as follows. Let F be a
field, m, n ∈ N>0 , and f = ∑0≤i<n fi xi , g = ∑0≤i<n gi xi in F[x]. To multiply f and g, we divide each
of them into m ≥ 2 blocks of size k = ⌈n/m⌉:
f= ∑ Fi xki , g= ∑ Gi xki ,
0≤i<m 0≤i<m
with all Fi , Gi ∈ F[x] of degree less than k. Then f g = ∑0≤i<2m−1 Hi xki , where Hi = ∑0≤ j≤i Fj Gi− j
for 0 ≤ i < 2m − 1 and we assume that Fj , G j = 0 if j ≥ m.
Exercises 249
αβ = ∑ v jl j = ∑ γi xi ∈ K[x],
0≤ j≤2m−2 0≤i≤2m−2
since deg(αβ) < 2m − 1 and the interpolating polynomial is unique, and each γi ∈ K is an F-linear
combination
γi = ∑ ci j v j
0≤ j≤2m−2
of v0 , . . ., v2m−2 , with ci j ∈ F for 0 ≤ i, j ≤ 2m − 2. (In fact, the matrix (ci j )0≤i, j≤2m−2 is the inverse
j
of the Vandermonde matrix (ui )0≤i, j≤2m−2 in F (2m−1)×(2m−1) .) This yields the following scheme for
j
computing H0 , . . ., H2m−2 . We assume that the values ui and ci j for 0 ≤ i, j ≤ 2m−2 are precomputed
and stored.
j j
1. Set Pi = ∑0≤ j<m Fj ui and Qi = ∑0≤ j<m G j ui for 0 ≤ i ≤ 2m − 2.
2. Compute Ri = Pi Qi for 0 ≤ i ≤ 2m − 2.
3. Set Hi = ∑0≤ j≤2m−2 ci j R j for 0 ≤ i ≤ 2m − 2.
Prove that this scheme works correctly (hint: first consider k = 1) and figure out the precise number
of additions and multiplications in F that steps 1 and 3 take.
j
(ii) Calculate the values of ui and ci j for F = F5 , m = 3, and ui = i mod 5 for 0 ≤ i ≤ 4.
(iii) Use the scheme from (i) to construct a recursive algorithm for polynomial multiplication, and
determine its asymptotic cost when n is a power of m. Conclude that if F is infinite, then for each
positive ε ∈ R there is an algorithm for multiplying polynomials of degree less than n in F[x] taking
O(n1+ε ) operations in F.
8.9 Let F = F29 .
(i) Find a primitive 4th root of unity ω ∈ F, and compute its inverse ω −1 ∈ F.
(ii) Find the matrices for DFTω and DFTω−1 , and check that their product is 4I.
8.10−→ Let F = F17 and f = 5x3 + 3x2 − 4x + 3, g = 2x3 − 5x2 + 7x − 2 in F[x].
(i) Show that ω = 2 is a primitive 8th root of unity in F, and compute the inverse 2−1 mod 17 of
ω in F.
(ii) Compute h = f · g ∈ F[x].
(iii) For 0 ≤ j < 8, compute α j = f (ω j ), β j = g(ω j ), and γ j = α j · β j . Compare γ j to h(ω j ).
250 8. Fast multiplication
(iv) Show the two matrices V1 = Vω and V2 = 8−1Vω−1 , and compute their product. Compute the
matrix–vector products V1 f ,V1 g, and V2 γ, identifying f and g with their coefficient vectors, and with
γ = (γ j )0≤ j<8 as computed. Comment.
(v) Trace the FFT multiplication algorithm 8.16 to multiply f and g, with ω as above.
8.11−→ Let F = F41 .
(i) Prove that ω = 14 ∈ F is a primitive 8th root of unity. Compute all powers of ω, and mark the
ones that are primitive 8th roots of unity.
(ii) Let η = ω 2 , and f = x7 + 2x6 + 3x4 + 2x + 6 ∈ F[x]. Give an explicit calculation of α =
DFTω ( f ), using the FFT. You only have to do one recursive step, and then can use direct evaluation
at powers of η.
(iii) Let g = x7 + 12x5 + 353 + 1 ∈ F[x]. Compute β = DFTω (g), γ = α · β with coordinate–wise
product, and h = DFTω−1 (γ).
(iv) Compute f · g in F[x] and f ∗8 g. Compare with your result from (iii).
√
8.12−→ The complex number ω = exp(2πi/8) ∈ C, where i = −1, is a primitive 8th root of unity.
3 2 3 2
Let f = 5x + 3x − 4x + 3 and g = 2x − 5x + 7x − 2 in C[x], and run the fast convolution algorithm
8.16 on this example to calculate the coefficients of the product f · g. (Of course, on such a small
example the “fast” algorithm is more tedious than the school method. But, who knows, you may
want to multiply polynomials of degree 1 000 000 one day . . . .) Multiply linear polynomials by the
“classical” method. Use ω only symbolically, with the fact that ω 4 = −1.
8.13 Let R be a ring, n ∈ N≥1 , and ω ∈ R be a primitive nth root of unity.
(i) Show that ω −1 is a primitive nth root of unity.
(ii) If n is even, then show that ω 2 is a primitive (n/2)th root of unity. If n is odd, then show that
ω 2 is a primitive nth root of unity.
(iii) Let k ∈ Z and d = n/ gcd(n, k). Show that ω k is a primitive dth root of unity; this generalizes
both (i) and (ii).
8.14 Let R be a ring, n ∈ N≥2 , ω ∈ R a primitive nth root of unity, and η ∈ R with η 2 = ω. Under
what conditions is η a primitive 2nth root of unity?
8.15∗ Let n ∈ N>0 and R be an integral domain of characteristic coprime to n.
(i) Show that the set Rn of all nth roots of unity is a subgroup of the multiplicative group R× .
(ii) Prove that the following are equivalent for an nth root of unity ω ∈ R:
(a) ω is a primitive nth root of unity,
(b) ω ℓ 6= 1 for 0 < ℓ < n (that is, ω has order n in R),
(c) ω ℓ 6= 1 for all 0 < ℓ < n with ℓ | n,
(d) ω n/p 6= 1 for all prime divisors p of n.
We now assume that R contains a primitive nth root of unity ω.
(iii) Draw all 12th roots of unity for R = C and mark the primitive ones.
(iv) Show that Rn is cyclic and isomorphic to the additive group Zn of integers modulo n (so in
particular, #Rn = n). Hint: The polynomial xn − 1 ∈ R[x] has at most n roots.
(v) Prove that there are precisely ϕ(n) primitive nth roots of unity, where ϕ is Euler’s totient
function.
8.16∗ Let q be a prime power, Fq a finite field with q elements, and n ∈ N a divisor of q − 1,
with prime factorization n = pe11 · · · per r . For a ∈ F×
q , we denote by ord(a) the order of a in the
multiplicative group F× ×
q , and want to show that ord(a) = q − 1 for some a ∈ Fq . Prove:
(i) ord(a) = n if and only if an = 1 and an/p j 6= 1 for 1 ≤ j ≤ r.
Exercises 251
e
(ii) F× j ×
q contains an element b j of order p j , for 1 ≤ j ≤ r. Hint: Consider an element of Fq which
is not a root of the polynomial x(q−1)/p j
− 1.
×
(iii) If a, b ∈ Fq are elements of coprime orders, then ord(ab) = ord(a) ord(b).
(iv) F×
q contains an element of order n.
(v) F×
q is cyclic.
h0 (x) ≡ f0 (x) · g0 (x) mod xn/2 − 1, h1 (ωx) ≡ f1 (ωx) · g1 (ωx) mod xn/2 − 1
1
4. return ((h0 − h1 )xn/2 + h0 + h1 )
2
(i) Prove that the algorithm works correctly and takes 11
2 n log n operations in R.
(ii) For small inputs, it is faster to use classical multiplication (or Karatsuba’s algorithm) and
a subsequent reduction modulo xn − 1 to compute the result. Replace the first line of the above
algorithm by
1. if k ≤ d then call Algorithm 2.3 to compute f g ∈ R[x] and return f g rem xn − 1
The above algorithm corresponds to d = 0. Let T (n) denote the cost of the hybrid algorithm when
n = 2k for some k ∈ N, and prove that T (n) = 11 d
2 n log n+γ(d)n holds for n ≥ 2 , where γ(d) depends
only on d. Find the value of d ∈ N which minimizes γ(d), and compare the result to (i).
8.25∗ Algorithm 8.14 computes DFTω over a (commutative) ring R by dividing the input polyno-
mial f ∈ R[x] of degree less than n by xn/2 − 1 and xn/2 + 1 with remainder. A different approach is
to split f into its odd and even parts, that is, to write f = f0 (x2 ) + x f1 (x2 ) with f0 , f1 ∈ R[x] of degree
less than n/2, and then to compute DFTω2 ( f0 ) and DFTω2 ( f1 ) recursively. Work out the details and
prove that your algorithm uses cn log n operations in R for some positive constant c ∈ Q when n is
a power of 2. Modify, if necessary, your algorithm so that c = 3/2, as in Theorem 8.15. Hint: Use
ω n/2 = −1. Draw an arithmetic circuit illustrating your algorithm for n = 8, and compare it to the
circuit in Figure 8.4.
8.26∗ Let R be a ring (commutative, with 1) containing a primitive 3k th root of unity for any k ∈ N.
(i) Design a 3-adic FFT algorithm, taking as input k ∈ N, a polynomial f ∈ R[x] of degree less than
n = 3k , and a list of powers 1, ω, ω 2 , . . ., ω n−1 of a primitive nth root of unity ω ∈ R, and returning
f (1), f (ω), f (ω 2 ), . . ., f (ω n−1 ). Prove the correctness of your algorithm. Hint: Consider dividing f
with remainder by xn/3 − 1, xn/3 − ω n/3 , and xn/3 − ω 2n/3 .
(ii) Draw an arithmetic circuit illustrating your algorithm for n = 9.
(iii) Let T (n) denote the cost of your algorithm in operations in R when n = 3k for some k ∈ N.
Set up a recursion for T (n) (don’t forget the initial condition) and solve it.
(iv) Assuming that R contains primitive nth root of unity for any n ∈ N, generalize the above to an
m-adic FFT algorithm for arbitrary m ∈ N≥2 .
(v) Formulate an alternative m-adic FFT algorithm as in Exercise 8.25.
8.27 Let F be a field containing a primitive 2k th root of unity for all k ∈ N. Algorithm 8.16 shows
that the convolution ∗n in F[x] can be computed with O(n log n) operations in F if n is a power of 2.
The goal of this exercise is to generalize this to arbitrary n ∈ N. So let f , g ∈ F[x] and m ∈ N be a
power of 2 such that m/2 < 2n ≤ m, and set a = f · (xm−n + 1) and b = g. Show how to obtain the
coefficients of f ∗n g from those of a ∗m b, and derive the claim from this.
8.28 Show that ω = x mod (xn − 1) ∈ R = F[x]/hxn − 1i, where F is a field of characteristic not
dividing n, is not a primitive nth root of unity for n ≥ 2.
Exercises 253
8.30∗∗ In this exercise, we discuss Schönhage’s (1977) 3-adic variant of Algorithm 8.20. It works
over any (commutative) ring R such that 3 is a unit in R, in particular over a field of characteristic 2.
1. if k ≤ 2 then
call the classical algorithm 2.3 (or Karatsuba’s algorithm 8.1) to compute f · g
return f g rem x2n + xn + 1
2. m ←− 3⌈k/2⌉ , t ←− n/m
let f ′ , g′ ∈ R[x, y] with degx f ′ , degx g′ < m such that f = f ′ (x, xm ) and g = g′ (x, xm )
3. let D = R[x]/hx2m + xm + 1i
if m = t then η ←− x mod (x2m + xm + 1) else η ←− x3 mod (x2m + xm + 1)
{ η is a primitive 3tth root of unity }
f ∗ ←− f ′ mod (x2m + xm + 1), g∗ ←− g′ mod (x2m + xm + 1)
4. for j = 1, 2 do
f j ←− f ∗ rem y t − η jt , g j ←− g∗ rem y t − η jt
call the fast convolution algorithm 8.16 with ω = η 3 to compute h j ∈ D[y] of degrees
less than t such that
f j (η j y)g j (η j y) ≡ h j (η j y) mod yt − 1
{ the DFTs are performed by the 3-adic FFT algorithm from Exercise 8.26, and Algorithm
8.30 is used recursively for multiplications of elements in D }
1
5. h∗ ←− (y t (h2 − h1 ) + η 2t h1 − ηt h2 )(2ηt + 1)
3
let h′ ∈ R[x, y] with degx h′ < 2m such that h∗ = h′ mod (x2m + xm + 1)
h ←− h′ (x, xm ) rem (x2n + xn + 1)
return h
(i) Use Exercise 8.29 to prove that the algorithm works correctly.
(ii) Let T (k) denote the cost of the algorithm for n = 3k . Prove that T (k) ≤ 2 · 3⌊k/2⌋ T (⌈k/2⌉) +
(c + 48(⌊k/2⌋ + 1/2))3k for k > 2 and some constant c ∈ N, and conclude that T (k) is at most
24 · 3k · k · log k + O(3k · k) = 24n log3 n log2 log3 n + O(n log n). Hint: Consider the function S(k) =
(3−k T (k) + c)/(k − 1), and prove that S(k) ≤ S(⌈k/2⌉) + 24 if k > 2.
254 8. Fast multiplication
8.31∗ (i) Let R be a (commutative) ring, n ∈ N≥2 a power of two, and ω = (x mod xn/2 + 1) ∈
R[x]/hxn/2 + 1i. Show that the conclusion Vω ·Vω−1 = nI of Theorem 8.13 holds even when n is not
a unit in R. Hint: Show first that ω nt/2 + 1 = 0 for all odd t ∈ N and use the factorization
Mit Ausnahme der paar von Hand gefertigten Möbel, Kleider, Schuhe
und der Kinder erhalten wir alles unter Einschaltung mathematischer
Berechnungen. Dieses ganze Dasein, das um uns läuft, rennt, steht, ist
nicht nur für seine Einsehbarkeit von der Mathematik abhängig,
sondern ist effektiv durch sie entstanden.1
Robert Musil (1913)
1 Except for a few hand-made pieces of furniture, clothes, shoes, and our children we obtain everything by
using mathematical computations. The whole world we live in, everything which walks, runs, stands around us,
depends not only for our understanding on mathematics, but has effectively been created by it.
2 That this subject [the imaginary magnitudes ] has hitherto been considered from the wrong point of view and
√
surrounded by a mysterious obscurity, is to be attributed largely to an unfortunate notation. If +1, −1, −1 had
not been called positive, negative, and imaginary (or even impossible) unit, but rather direct, inverse, and lateral
unit, then such an obscurity would probably not have arisen.
3 Thus spake Al-Khwārizmı̄: [. . . ] So this is everything that is necessary for men concerning the division and
multiplication with an integer, and the other things that are connected with it. Having completed this, we now
begin to discuss the multiplication of fractions and their division, and the extraction of roots, if God so wills.
9
Newton iteration
257
258 9. Newton iteration
(where, as usual, we assume that the zero polynomial has degree −∞). Since b is
monic, such q, r exist uniquely even if D is not a field (Section 2.4).
Substituting 1/x for the variable x and multiplying by xn , we obtain
1 1 1 1
xn a = xn−m q · xm b + xn−m+1 xm−1 r . (1)
x x x x
We define the reversal of a as revk (a) = xk a(1/x). When k = n, this is the poly-
nomial with the coefficients of a reversed, that is, if a = an xn + an−1 xn−1 + · · · +
a1 x + a0 , then
and therefore,
revn (a) ≡ revn−m (q) · revm (b) mod xn−m+1 .
We note that revm (b) has constant coefficient 1 and thus is invertible modulo
xn−m+1 , by Theorem 4.1. Hence we find
It follows that
So now we have to solve the problem of finding, from a given f ∈ D[x] and l ∈ N
with f (0) = 1, a g ∈ D[x] satisfying f g ≡ 1 mod xl .
9.1. Division with remainder using Newton iteration 259
T HEOREM 9.2.
Let D be a ring (commutative, with 1), f , g0 , g1 , . . . ∈ D[x], with f (0) = 1, g0 = 1,
i+1 i
and gi+1 ≡ 2gi − f g2i mod x2 , for all i. Then f gi ≡ 1 mod x2 for all i ≥ 0.
y y = ϕ(z)
✻
• (gi , ϕ(gi ))
z
• • ✲
gi+1 gi
T HEOREM 9.4.
Algorithm 9.3 correctly computes the inverse of f modulo xl . If l = 2r is a power
of 2, then it uses at most 3M(l) + l ∈ O(M(l)) arithmetic operations in D.
r
P ROOF. Correctness follows from Theorem 9.2 and the fact that xl divides x2 . In
step 2, all powers of x up to 2i can be dropped, and since gi ≡ gi−1 · (2 − f gi−1 ) ≡
i−1
gi−1 mod x2 , also the powers of x less than 2i−1 . The cost for one iteration of
i
step 2 is M(2i−1 ) for the computation of g2i−1 , M(2i ) for the product f g2i−1 mod x2 ,
i
and then the negative of the upper half of f g2i−1 modulo x2 is the upper half of gi ,
taking 2i−1 operations. Thus we have M(2i ) + M(2i−1 ) + 2i−1 ≤ 32 M(2i ) + 2i−1 in
step 2, and the total running time is
3 3
∑ M(2i ) + 2i−1 ≤ M(2r ) + 2r−1 ∑ 2i−r < 3M(2r ) + 2r = 3M(l) + l,
1≤i≤r 2 2 1≤i≤r
If l is not a power of 2, then the above algorithm computes too many coefficients
of the inverse. Exercise 9.6 gives a better algorithm with essentially the same
running time bound in this general case.
T HEOREM 9.6.
Let D be a ring (commutative, with 1). Division with remainder of a polynomial
a ∈ D[x] of degree n + m by a monic polynomial b ∈ D[x] of degree n, where
n ≥ m ∈ N, can be done using 4M(m) + M(n) + O(n) ring operations.
P ROOF. Let a = qb + r, with q, r ∈ D[x] such that deg r < n. Then we have deg q =
deg a − deg b = m. The correctness of Algorithm 9.5 follows from the discussion
at the beginning of the section. Using Exercises 8.34 and 9.6, we have at most
3M(m) + O(m) operations in step 2 of Algorithm 9.5, M(m) + O(m) in step 3, and
finally M(n) + O(n) in step 4; only the lower part of a − qb has to be computed
since deg r < deg b. ✷
It may seem circular to use an algorithm that uses the rem operation to perform
division. However, we are only using the rem operation to truncate the polyno-
mial. It is similar to finding the quotient and remainder of a large number written in
base 10 when divided by 10 000. Division in this special case costs no operations.
What is the number of word operations for division with remainder in Z[x]? If
b is monic and a, b have max-norm ||a||∞ , ||b||∞ < 2l , then Exercise 6.44 shows that
||q||∞ , ||r||∞ < 2nl . Exercise 9.15 shows that all intermediate results in Algorithm 9.3
have coefficients of length O(nl), and hence the cost for division using Newton
inversion is O(M(n)M(nl)) or O∼ (n2 l) word operations. Since the output size is
O(n2 l) and Exercise 6.44 also shows that this bound can be achieved, the running
time is—up to logarithmic factors—asymptotically optimal. A similar statement
also holds for division with remainder in F[y][x] for a field F.
Exercises 8.21 and 9.14 discuss slightly faster algorithms for exact division,
where the remainder is known to be zero in advance.
262 9. Newton iteration
C OROLLARY 9.7.
Let D be a ring (commutative, with 1) and f ∈ D[x] monic of degree n. Then one
multiplication in the residue class ring D[x]/h f i can be done using 6M(n) + O(n)
or O(M(n)) arithmetic operations in D.
T HEOREM 9.8.
Division with remainder of integers of length n can be done with O(M(n)) word
operations.
C OROLLARY 9.9.
For an integer m ∈ N of length n, one multiplication in the residue class ring Zm
can be performed using O(M(n)) word operations.
1. r ←− ⌈log l⌉
i
2. for i = 1, . . . , r compute gi ∈ R such that gi ≡ (2gi−1 − f g2i−1 ) mod p2
3. return gr
9.1. Division with remainder using Newton iteration 263
E XAMPLE 9.11. We let R = Z, and wish to compute the inverse of 5 modulo 81.
We begin with g0 = −1, since −1 · 5 ≡ 1 mod 3. Then
T HEOREM 9.12.
Algorithm 9.10 correctly computes the inverse of f mod pl . It uses O(M(l log p))
word operations if R = Z, p > 1, and | f | < pl , and O(M(l deg p)) operations in D
if R = D[x] for a (commutative) ring D, p is monic, and deg f < l deg p.
C OROLLARY 9.13.
Let R be a ring (commutative, with 1), p ∈ R, and l ∈ N>0 . An element f ∈ R is
invertible modulo pl if and only if it is invertible modulo p.
where k = ⌊n/m⌋ + 1 (see Section 5.11). This will be used in the integration algo-
rithm of Chapter 22; the reader may skip the present section at first reading.
A special case is the usual coefficient sequence when p = x, or, more generally,
the Taylor expansion of a around u for p = x − u (Section 5.6). We have seen in
Section 5.11 that the p-adic expansion can be computed using O(n2 ) operations
in R, and we will now see how to do this in softly linear time.
1. if k = 1 then return a0 = a
2. t ←− k/2
call the repeated squaring algorithm 4.8 to compute pt ∈ R[x]
3. q ←− a quo pt , r ←− a rem pt
5. return a0 , . . . , ak−1
T HEOREM 9.15.
Algorithm 9.14 correctly computes the p-adic expansion of a and uses at most
(3M(km) + O(km)) log k or O(M(km) log k) operations in R.
a = qpt + r = ∑ ai+t pi pt + ∑ ai pi = ∑ ai pi .
0≤i<t 0≤i<t 0≤i<k
Let T (k) denote the cost of the algorithm. Step 1 is for free, and hence T (1) = 0.
By treating leading coefficients in polynomial multiplication separately, we have
9.3. Formal derivatives and Taylor expansion 265
One may also take k = ⌊(deg f )/m⌋ + 1, not necessarily a power of 2, and
t = ⌊k/2⌋ in step 2. The effect is a more “balanced” binary splitting in steps 3
and 4, possibly resulting in a slightly faster algorithm, but the analysis is more
involved. If k is a power of 2, however, one may precompute p2 , p4 , . . . , pk/4 , pk/2 ,
thus performing repeated squaring only once instead of every time the algorithm
passes through step 2 in the recursive process.
Exercise 9.20 shows that the “reverse” task of computing the coefficients of a
from its p-adic expansion (4) can also be done in time O(M(mk) log k).
C OROLLARY 9.16.
Let n ∈ N be a power of 2. The Taylor expansion of a polynomial a ∈ R[x] of
degree n around u ∈ R can be computed using at most (3M(n) + O(n)) log n or
O(M(n) log n) operations in R.
The analog of Algorithm 9.14 for integers can be used to convert an integer
from the 264 -ary representation to an expansion with respect to the powers of an
arbitrary base p ∈ N>1 in softly linear time. The following theorem about this
radix conversion is proven in Exercise 9.21.
T HEOREM 9.17.
Given a, p ∈ N with p of length m and a of length at most km for some k, m ∈ N,
we can compute the p-adic expansion of a using O(M(km) log k) word operations.
modulo p. But first we need to adapt some well known tools from calculus to our
purely algebraic setting.
ϕ′ = ∑ iϕi yi−1 .
0≤i≤n
For R = R, this is the familiar notion usually defined by a limit process. But
in general, say over a finite field, there is no concept like a “limit”. We note that
i plays two different roles here: as a summation index, where it is really just a
convenient notation for the vector (ϕ0 , . . . , ϕn ) ∈ Rn+1 of coefficients, and the ring
element i = 1 + · · · + 1 ∈ R.
The formal derivative has some familiar properties.
(ii) Because of linearity, it is enough to show the claim for powers of y. So let
n, m ∈ N.
(iii) Again, it is sufficient to show the claim for ϕ being a power of y, ϕ = yn for
n ∈ N say. But then the claim reduces to (ψ n )′ = nψ n−1 ψ ′ , which is easily proven
using the Leibniz rule and induction on n. ✷
We note one difference from the usual derivatives, say over R. Over F p (or,
more generally, any field of characteristic p > 0) any pth derivative is zero. For
example, ϕ′′ = 0 for all ϕ ∈ F2 [y].
9.4. Solving polynomial equations via Newton iteration 267
P ROOF. We have seen in Section 5.6 that ϕ has the Taylor expansion
ϕ= ∑ ϕi · (y − g)i = ϕ0 + ϕ1 · (y − g) + ψ · (y − g)2 ,
0≤i≤n
P ROOF. By Corollary 9.13, ϕ′ (g) is invertible modulo m2 , and hence the right
hand side of (5) is well defined; Algorithm 9.10 computes ϕ′ (g)−1 mod m2 given
ϕ′ (g)−1 mod m. Since m | m2 , the congruence (5) also holds modulo m, and
h ≡ g − ϕ(g)ϕ′ (g)−1 ≡ g mod m
because ϕ(g) vanishes modulo m. This proves the second assertion.
268 9. Newton iteration
For the first one, we make use of the Taylor expansion given by Lemma 9.20 of
ϕ around g and substitute h for y:
Here, we use the fact that m2 divides (−g)2 , by the second assertion.
Since h ≡ g mod m, we have ψ (h) ≡ ψ (g) mod m for any ψ ∈ R[y], in particular
for ψ = ϕ′ . This is just a special case of a general principle: since the reduction
map modulo m is a ring homomorphism, it commutes with the ring operations +
and ·, and hence with any polynomial over R. Now Corollary 9.13 proves the last
claim. ✷
1. r ←− ⌈log l⌉
{ The second computation is the ith execution of step 2 in the Newton iter-
ation of Algorithm 9.10 for the inversion of ϕ′ (gi ). }
T HEOREM 9.23.
Algorithm 9.22 works correctly.
r
P ROOF. Let gr ≡ gr−1 − ϕ(gr−1 )sr−1 mod p2 . Then g ≡ gr mod pl , and it is suf-
ficient to show the invariants
i i
gi ≡ g0 mod p, ϕ(gi ) ≡ 0 mod p2 , si ≡ ϕ′ (gi )−1 mod p2 if i < r
9.4. Solving polynomial equations via Newton iteration 269
T HEOREM 9.25.
When R = D[x] for a ring D (commutative, with 1), p = x, g0 ∈ D, l ∈ N is a
power of 2, and ϕ ∈ R[y] with degy ϕ = n and degx ϕ < l , then Algorithm 9.22
takes (3n + 3/2)M(l) + O(nl) operations in D.
270 9. Newton iteration
i
P ROOF. Reducing modulo x2 where possible, we may assume that the degrees of
si and gi are less than 2i for all i. At first, we compute ϕ′ , taking nl = n2r operations
i
in D. In step 2, we compute ϕ(gi−1 ) and ϕ′ (gi ) modulo x2 using Horner’s rule, at
i
a total cost of 2n − 1 multiplications and the same number of additions modulo x2 ,
or (2n − 1)(M(2i ) + 2i ) operations in D. Computing gi from gi−1 , si−1 , and ϕ(gi−1 )
can be done using at most M(2i−1 ) + 2i−1 ≤ 12 M(2i ) + 2i−1 operations in D: since
the lower part of ϕ(gi−1 ) is zero, we only need to multiply its upper part by si−1 and
take the negative of the lower part of the result as the upper part of gi . Similarly,
computing si from si−1 and ϕ′ (gi ) takes M(2i ) + M(2i−1 ) + 2i−1 ≤ 32 M(2i ) + 2i−1
operations, as in the proof of Theorem 9.4. Thus the cost for the ith iteration of
step 2 is at most (2n + 1)M(2i ) + 2n · 2i operations in D, and similarly we have
(n + 1/2)(M(2r ) + 2r ) operations in step 3. Now
i i r r
∑ (2n + 1)M(2 ) + 2n · 2 ≤ (2n + 1)M(2 ) + 2n · 2 ∑ 2i−r
1≤i<r 1≤i<r
≤ (2n + 1)M(2r ) + 2n · 2r ,
T HEOREM 9.26.
When R = Z, 0 ≤ g0 < p, and ϕ has degree n and coefficients absolutely less
than pl , then Algorithm 9.22 takes O(n M(l log p)) word operations.
When calculating by hand, one may perform all computations in Algorithm 9.22
in the p-adic representation, since then reductions modulo powers of p are for free.
One question that did not come up with the Newton iteration algorithm for in-
version is that of uniqueness of the solution. Inverses modulo pl are unique, but
solutions of an arbitrary polynomial equation ϕ(y) = 0 modulo pl generally are
not, because there may already be several solutions modulo p. The following the-
orem implies that for any l ∈ N>0 , every starting solution gives rise to exactly one
solution modulo pl , so that there are as many solutions modulo pl as there are
modulo p (with nonvanishing ϕ′ ).
Now
By Corollary 9.13, there exist some s,t ∈ R such that s · (ϕ′ (h) + c · (h∗ − h)) =
1 + t pl , and (6) implies that
The left hand side of this equation vanishes modulo pl , and the claim follows. ✷
The conclusion of Theorem 9.27 need no longer be true if g violates the second
condition for a starting solution, namely if ϕ′ (g) is not invertible modulo p. For
example, the equation y4 = 0 has only one solution g ≡ 0 modulo 5, but five so-
lutions h ≡ 0, 5, 10, 15, 20 modulo 25 that are all congruent to 0 modulo 5. Here
ϕ = y4 and ϕ′ (0) ≡ 0 mod 5, so that 0 is not a proper starting solution.
We will meet Newton iteration again in Chapter 15, under the name of Hensel
lifting, which is used for (approximate) factorizations of polynomials.
and g0 = 1 is a valid starting solution for the 2-adic Newton iteration to solve
ϕ(y) = yn − a = 0, as in Algorithm 9.22, since ϕ′ (1) = n · 1n−1 ≡ 1 6≡ 0 mod 2.
We choose k ∈ N minimal such that 2nk > a, and after r = ⌈log k⌉ steps Algorithm
9.22 has computed g ∈ N with ϕ(g) = gn − a ≡ 0 mod 2k . If now gn = a in Z,
√
then g = n a. Otherwise, we claim that a is not an nth power in Z. To see why,
we assume that we have b ∈ N with bn = a. Then b is odd, b ≡ g0 ≡ g mod 2,
0 ≤ b < 2k , and
ϕ(b) = bn − a = 0 ≡ gn − a = ϕ(g) mod 2k .
Now the uniqueness of Newton iteration (Theorem 9.27) yields b ≡ g mod 2k , and
since both sides are nonnegative and less than 2k , they are equal.
In order to save computing time, we set t0 = 1 in step 1 and additionally compute
i+1
ti = gin−1 rem 22 in step 2. In the ith iteration of step 2 in Algorithm 9.22, we
then calculate
i
gi ≡ gi−1 − ϕ(gi−1 )si−1 ≡ gi−1 − (gi−1ti−1 − a)si−1 mod 22
i
with two multiplications and two additions modulo 22 . Then we compute ti and
i
si ≡ 2si−1 − ϕ′ (gi )s2i−1 ≡ 2si−1 − nti s2i−1 mod 22 ,
i
taking three multiplications and two additions modulo 22 . For the computation
of ti , we use repeated squaring (Section 4.3), at a cost of at most 2 log n mul-
i+1
tiplications modulo 22 . Thus the total cost for the ith iteration of step 2 is
O(M(2i ) log n) word operations. In the 264 -ary representation, reduction modulo
i
22 is essentially free.
T HEOREM 9.28.
Let a, n ∈ N be odd, a < 2l , and 3 ≤ n < l . Then the above algorithm either
√
computes the unique positive integer n a ∈ N, or certifies that a is not an nth power
in Z, using O(M(l)) word operations.
P ROOF. Correctness is clear from the above discussion. Let c ∈ R>0 such that the
cost for the ith iteration of step 2 of the Newton iteration algorithm 9.22 is at most
c M(2i ) log n word operations and the cost for step 3 is at most c M(k) log n. With
r = ⌈log k⌉ as above, the total cost is no more than
i i
c log n M(k) + ∑ M(2 ) ≤ c log n M(k) + M ∑ 2
1≤i<r 1≤i<r
√
E XAMPLE 9.29. Let us compute 3 2197. We may choose k = 4, since 23·4 =
212 = 4 096 > 2197. Now g0 = s0 = t0 = 1 and
In Exercise 9.44, we use this to test whether a ∈ N>1 is a perfect power, so that
a = cn for integers c, n > 1. In Sections 14.4 and 15.6, we discuss algorithms for
computing integer roots of arbitrary polynomials.
The following are some commonly used valuations on integers and polynomials.
A ring may, of course, have more than one valuation.
E XAMPLE 9.31. (i) Let R = Z, and v(a) = |a|, the absolute value.
(ii) With R = Z and p prime, let
0, if a = 0,
v p (a) =
p−n , if pn | a and pn+1 ∤ a.
This is the x-adic valuation. Similarly, if p ∈ F[x] is irreducible, we get the p-adic
valuation if x is replaced by p in (7).
(iv) With R = F[x], F a field, let
0, if a = 0,
v(a) =
2deg(a) , if a 6= 0.
1 1
E XAMPLE 9.32. v3 (54) = 3−3 = , v3 (55) = 1, v3 (54 000 000) = .✸
27 27
The p-adic valuation for integers is non-Archimedean, while the absolute value
for integers is Archimedean. The Newton iteration of Algorithm 9.22 for solving
polynomial equations approximately can be carried over to any non-Archimedean
valuation. Lemma 9.21 reads as follows in this generality.
P ROOF. We only show the first two bounds, using the Taylor expansion (Lem-
ma 9.20) of ϕ around g:
ϕ(g) ϕ(g) ϕ(g) ϕ(g)
v(h − g) = v h − g + ′ − ≤ max v h − g + ′ ,v ′
ϕ (g) ϕ′ (g) ϕ (g) ϕ (g)
= max {ε2 , ε} = ε,
v(ϕ(h)) = v(ϕ(g) + ϕ′ (g)(h − g) + ψ (h − g) · (h − g)2 )
ϕ(g) ϕ(g)
= v ϕ(g) − ϕ′ (g) ′ + ϕ′ (g) h − g + ′ + ψ (h − g) · (h − g)2
ϕ (g) ϕ (g)
ϕ(g)
≤ max v(ϕ′ (g)) · v h − g + ′ , v(ψ (h − g)) · v(h − g)2
ϕ (g)
≤ max {1 · ε2 , 1 · ε2 } = ε2 . ✷
The division by ϕ′ (g) in the above formulas leads, in principle, out of the ring R.
There are three ways of dealing with this problem: we can replace ϕ′ (g)−1 by a
sufficiently good approximation in R, as computed by Algorithm 9.10, or we can
extend v to the field of fractions of R, by setting v(a/b) = v(a)/v(b) if b 6= 0, or
we can multiply by ϕ′ (g), where necessary, and conclude from v(ϕ′ (g)) = 1 that
the valuations do not change.
Newton iteration in R = Q for solving y2 −2 = 0 and starting √ with g0 = 2 leads to
better and better rational approximations to the root. But 2 itself is not a rational
number; in order to capture such an exact root, the domain has to be enlarged, say
to R.
A similar phenomenon happens with the p-adic valuations on Z or F[x]. One
can enlarge these rings to their completions, namely to the ring Z(p) of p-adic
integers or the ring F[[x]] of formal power series (for the x-adic valuation), and
in these larger rings Newton iteration converges to an exact root. We do not go
into details, since these quantities cannot be represented in a finite manner, and
these rings are mainly of conceptual interest to computer algebra. One can finitely
represent initial segments of them, say a mod pl for a ∈ Z(p) , but that is essentially
the same as some integer modulo pl .
Newton iteration for inversion tells us what the units are in these rings. An
element a = a0 + a1 p + a2 p2 + · · · ∈ Z(p) , with a0 , a1 , a2 , . . . ∈ {0, . . . , p − 1}, is a
unit if and only if a0 mod p is a unit in Z p , that is, if and only if a0 6= 0. The
power series a = a0 + a1 x + a2 x2 + · · · ∈ F[[x]], with a0 , a1 , a2 , . . . ∈ F is a unit in
F[[x]] if and only if a0 6= 0. As an example, 1 − x ∈ F[[x]] is a unit, with inverse
1 + x + x2 + · · ·.
In the real or complex numbers, the behavior of Newton iteration is quite intri-
cate, as seen in the simple case of finding the three roots 1, e2πi/3 , e4πi/3 in C of
ϕ = y3 − 1.
276 9. Newton iteration
In Figure 9.2, the three roots are marked by white circles, and the colored areas
indicate convergence to one of them via the Newton iteration. Brightness corre-
sponds to the “convergence speed”: the brighter the color of a point, the earlier
does Newton iteration starting at that point approach its final limit. The intricacy
of the picture illustrates the difficulty of finding a simple rule for telling where
a point will go. We have big bright areas where the limit point is clear, but also
other areas where a small change of the initial value will lead to a different desti-
nation. The points on the real line have nowhere to go but to 1. But the real root
of 16x9 + 51x6 + 21x3 + 2 near −1.43 first crashes into 0 and then explodes . . .
This problem is part of a larger question: given an iteration function gi+1 =
ψ (gi ), determine the behavior for any starting value g0 . For example, for which g0
does this converge at all? The set of all these g0 is called the Julia set of ψ , after
the French mathematician Gaston Julia who first studied it. Such sets are highly
complicated and provide stunning pictures. Their study is mainly a part of dy-
namical systems theory . The beautiful mathematical theory of chaos and fractals
9.6. Newton iteration, Julia sets, and fractals 277
32 = 2 3
33 = 6 0 1
34 = 4 35 = 5
F IGURE 9.4: Convergence of Newton iteration to solve y3 = 1 over the 7-adic integers.
278 9. Newton iteration
is described and richly illustrated in Mandelbrot (1977) and Peitgen, Jürgens &
Saupe (1992).
In Figure 9.4, we see the analog of Figure 9.2 over Z(7) , the set of 7-adic integers.
The seven elements of Z7 are arranged as in Figure 9.3, and Z(7) can be represented
by the fractal composed of infinitely many recursive compositions of this centered
hexagon. The boundary is a Koch snowflake. The derivative ϕ′ = 3y2 of ϕ =
y3 − 1 vanishes modulo 7 on the white points in the center, and Newton iteration
does not work. All other points converge to the root of f of their color, and brighter
color means faster convergence. The three roots of ϕ in Z(7) , whose sum equals 0,
are 1, 2 + 4 · 7 + 6 · 72 + 3 · 73 + · · ·, and 4 + 2 · 7 + 0 · 72 + 3 · 73 + · · ·. In Z×
7 , at most
one iteration leads to a root modulo 7 and then to convergence modulo higher
powers of 7. However, for large p, it seems to be as tricky as in the complex
situation to determine which elements of Z×p lead to a root modulo p, except that
we have only a finite number of starting points to try. Once a root is reached,
convergence is quick.
Many of our algorithms are (hopefully) of long-lasting interest, but the computer
timings reported now will be out of date before the book goes to press.
The first lesson in implementing a software package for fast integer or polyno-
mial arithmetic is that a large variety of algorithms have to be coded and tested to
determine the crossover points. These are the input sizes at which one algorithm
beats another one. A typical experience is that, say for multiplication, the classical
method is best for small inputs, Karatsuba’s algorithm takes over for intermediate
sizes, and a fast, for example, an FFT-based method, excels for large problems.
The second lesson is that just casting the algorithms “from the book” into soft-
ware will not work well. One has to understand the algorithmic ideas in depth and
use a multitude of tricks and special relations to make things go at lightning speed.
Only a few of these methods can be explained here; fortunately, there is no limit
to the ingenuity of the programmer (except for having to complete the project in
some reasonable time frame).
Several factors determine whether a software package for (integer or polyno-
mial) arithmetic is fast in practice. Besides choosing the algorithms and deter-
mining the crossover points between various methods, one has to design suitable
data types, exploit fast hardware arithmetic whenever possible, and customize for
specific types and sizes of problems.
Currently, there are—besides implementations in any general purpose computer
algebra system—several libraries available for arbitrary precision integer arithme-
tic and univariate polynomial arithmetic over finite fields, Z, Q, algebraic number
fields, R, and C (among others GNU MP, PARI, L IDIA), but only few that imple-
ment the fast algorithms presented in Chapters 8 through 11. Among them are L IP
by Arjen Lenstra and Paul Leyland, the package of Schönhage, Grotefeld & Vetter
(1994) (see also Reischert 1995), N TL by Shoup (an early version is described in
Shoup 1995), and B I P OL A R (Binary Polynomial Arithmetic) by von zur Gathen
& Gerhard (1996). The last two of these will be described below.
The C++ library B I P OL A R was designed and optimized for univariate polyno-
mial factorization over F2 . This is a very narrow focus, but we use it to explain
some general principles. The first question when writing the package was the
choice of data types. When programming on top of an existing package, one may
not have much choice. Experience has shown that for high performance code, one
should represent algebraic data as compactly as possible, since all linear operations
like addition or copying take time proportional to the length of the representation
(that is, the number of machine words it occupies in memory). Thus, on a ma-
chine with a word size of 32 bit, we represent polynomials over F2 as arrays of 32
bit words; each word contains 32 consecutive coefficients. In this representation,
all linear-time operations are straightforward to implement, and the next task is to
tackle the nontrivial arithmetic operations, starting with multiplication.
We have five methods at our disposal:
280 9. Newton iteration
◦ table lookup,
◦ classical multiplication,
◦ Karatsuba’s algorithm,
◦ an algorithm by Cantor (1989),
◦ FFT-based algorithms.
We did not experiment with the last one. As explained above, each method typ-
ically has its range of input sizes where it beats the other methods. One has to
implement many variations of these approaches and test them to determine the
best one for each range, starting with the small ranges. A typical outcome then
is a hybrid algorithm where one performs, say, first a few Karatsuba steps and
then classical multiplication on small arguments. As an example, for single pre-
cision polynomials of degree less than 32 we found the following to work best:
two stages of Karatsuba’s algorithm plus table lookup for the 9 resulting multi-
plications at degrees less than 8; the size of the table is 28 · 28 · 16 bits or 128
kilobytes. (Unfortunately, there is no hardware support for multiplication in F2 [x]
on general purpose microprocessors—there is no possibility to sever the “carry”
line—and one has to implement the single precision multiplication in software.)
On top of this, both the classical algorithm 2.3 and Karatsuba’s algorithm 8.1 are
implemented at machine word level, that is, with base x32 instead of x; the block
sizes are multiples of 32 and recursion in the latter algorithm stops as soon as the
polynomials are of degree less than 32.
We also implemented an algorithm by Cantor (1989) for multiplication in F2 [x],
which uses evaluation and interpolation at linear subspaces of F2m for some m ∈ N
and is similar to the FFT based methods from Chapter 8. Its running time is
O(n(log n)1.59 ) arithmetic operations in F2 . For practical purposes, we may take
m = 32, so that one element of F2m fits precisely into a machine word. Here the
single precision operations are multiplications in F216 and F232 . Again, we might
have implemented these by doing one polynomial multiplication in the way de-
scribed above and one subsequent division with remainder, but we have chosen
a different approach using tables based on the multiplicative structure of finite
fields, as in Pollard (1971) and Montgomery (1991). We take a fixed generator
g of the multiplicative group F× 216
, and compute two tables for the exponentiation
map {0, . . . , 216 − 2} −→ F× 216
, with a 7−→ ga , and its inverse. Two nonzero el-
ements c, d ∈ F216 are multiplied by determining a, b ∈ {0, . . . , 216 − 2} such that
c = ga and d = gb , and computing cd = ga+b . This amounts to essentially one addi-
tion modulo 216 − 1 and three table lookups; the size of each table is 216 · 16 bits or
128 KB. Inversion in F× 216
is done similarly. One multiplication in F232 is reduced
to three multiplications in F216 à la Karatsuba; this requires a change of basis.
After determining the best (that is, the fastest) routines for single precision arith-
metic, we implemented the three multiplication algorithms mentioned above for
9.7. Implementations of fast arithmetic 281
0.5
classical
Karatsuba
0.4 Cantor
CPU seconds
0.3
0.2
0.1
0
8192 16384 24576 32768 40960 49152 57344 65536
n
the degrees of the input polynomials to the two crossover degrees and then decides
which of the three algorithms to use. Its performance can be seen in Table 9.6.
n CPU seconds
512 0.0004
1024 0.0006
2048 0.0014
4096 0.0038
8192 0.0110
16 384 0.0329
32 768 0.0971
65 536 0.2135
131 072 0.4666
262 144 1.0218
524 288 2.2330
1 048 576 4.9560
We have to stress that here (and in all our implementation discussions) the tim-
ings and crossover points depend on our efforts and on our computing environ-
ment. We expect our software to perform quite well on other similar processors,
but for example to use the power of true 64 bit machines one would have to start
all over again—at least for the single precision arithmetic. The one universal truth
is that a well-done implementation is very labor-intensive and requires close fa-
miliarity with the algorithmics.
For division with remainder in F2 [x], we first wrote single precision routines for
both the classical algorithm and Newton inversion, working at the bit level. On top
of these, we implemented multiprecision versions working at machine word level
(Algorithm 2.5 with base x32 instead of x, and Algorithm 9.3 followed by essen-
tially two polynomial multiplications). The asymptotically fast division algorithm
uses the hybrid multiplication algorithm as a subroutine. Figure 9.7 shows some
experiments; the crossover point between the two algorithms (the top two curves)
is near degree 10 000.
In some applications, in particular in modular arithmetic and polynomial fac-
torization, many remainder computations modulo a fixed divisor f ∈ F2 [x] have to
be performed. In that case, rev( f )−1 mod xdeg f can be precomputed using Algo-
rithm 9.3 and stored, and then one remainder computation amounts to essentially
two polynomial multiplications of degree about deg f . When counting only the
latter, the crossover point drops to about 4000 (Figure 9.7). Further optimization
is possible when deg f is above the crossover degree for Cantor multiplication,
which reduces the time for one remainder computation modulo f to essentially the
time for a polynomial multiplication of the same size. Similar optimizations are
9.7. Implementations of fast arithmetic 283
0.5
0.4
CPU seconds
0.3
0.2
0.1 classical
Newton
Newton with precomputation
0
8192 16384 24576 32768 40960 49152 57344 65536
n
possible when many modular multiplications gh rem f with both f and h fixed are
performed.
B I P OL A R also implements the Extended Euclidean Algorithm and polynomial
factorization routines for F2 [x]; the latter will be discussed in Section 15.7.
The integer arithmetic of Shoup’s N TL is highly optimized. On a processor
with a word length of 32 bits, arbitrary precision integers are represented as arrays
of machine words, where—depending on the underlying hardware—between 26
and 30 consecutive bits of the binary representation are packed into one machine
word. Multiplication and division of such single precision integers is done by
cleverly employing the hardware floating point arithmetic, which in most currently
available microprocessors is considerably faster than hardware integer arithmetic.
N TL uses classical integer multiplication for integers of size up to about 500
bits, and Karatsuba’s algorithm for larger integers. Other arithmetic operations
like division with remainder and the Extended Euclidean Algorithm are all done
in the classical way.
We have implemented the classical algorithm 2.4, Karatsuba’s algorithm 8.1,
the three primes FFT algorithm 8.25, and the algorithm of Schönhage & Strassen
(1971) for integer multiplication using low-level routines of N TL version 1.5. Fig-
ure 9.8 gives running times for our implementations and the built-in routine of
N TL. We have not invested much effort into optimizing our routines, and the tim-
ings of our Karatsuba implementation are at most twice as large as those of N TL’s
routine. The graphs for the algorithms which are not FFT-based are quite smooth,
284 9. Newton iteration
3
classical
Karatsuba
2.5 NTL builtin
three primes FFT
Schönhage & Strassen FFT
2
CPU seconds
1.5
0.5
0
50000 100000 150000 200000
k
20
classical
Karatsuba
modular FFT
15 Fermat number FFT
CPU seconds
10
0
128 256 384 512 640 768 896 1024
n
20
classical
Karatsuba
modular FFT
15 Fermat number FFT
CPU seconds
10
0
4096 8192 12288 16384 20480 24576 28672 32768
n
20
classical
Karatsuba
modular FFT
15 Fermat number FFT
CPU seconds
10
0
1024 2048 3072 4096 5120 6144 7168 8192
k
while we have large steps near powers of 2 for the three primes FFT and Schön-
hage & Strassen’s algorithm. These steps may be smoothed with some additional
effort, but we have not tried this.
For multiplying polynomials over Z and Zm with m ∈ Z, N TL implements the
classical algorithm for small degrees and coefficient sizes, Karatsuba’s algorithm
for polynomials of medium degree, and the FFT-based modular approach de-
scribed in Section 8.4 and a variant of Algorithm 8.20 using FFT modulo Fermat
numbers (Exercise 8.36) for larger polynomials. Figures 9.9 through 9.11 show
running times for various degrees and coefficient sizes in N TL. For division with
remainder, N TL uses the classical algorithm for polynomials of small degree, and
Newton inversion (Algorithm 9.3) for higher degree polynomials.
Besides basic arithmetic for multiprecision integers, floating point numbers, fi-
nite fields, and univariate polynomials and matrices over these domains, the recent
version 3.1 of N TL includes routines for primality testing (Chapter 18), Chinese
remaindering (Chapters 5 and 10), computing greatest common divisors (Chap-
ters 3 and 6), factorization of univariate polynomials (Part III), computing reduced
bases in lattices over Z (Chapter 16), and much more. The polynomial factoriza-
tion routines will be discussed in Section 15.7. N TL is a C++ library and can be
downloaded from Victor Shoup’s homepage http://www.shoup.net. We rec-
ommend this package to anybody who is not ready to reinvent the wheel.
Notes. 9.1. Cook (1966) devised a division algorithm for integers that costs the same
number of word operations as a multiplication, up to a constant factor. Sieveking (1972),
Strassen (1973a), Kung (1974), and Borodin & Moenck (1974) gave analogous algorithms
for polynomials. For the details of the division method for integers, see Knuth (1998),
Algorithm 4.3.3 R, and Aho, Hopcroft & Ullman (1974), §8.2. In the nonscalar model,
Schönhage has shown how to divide a polynomial of degree at most 2n by one of degree n
with 5.875n multiplications and divisions (see Kalorkoti 1993 and Bürgisser, Clausen &
Shokrollahi 1997, Corollary 2.26 and Notes 2.8). Karp & Markstein (1997) state a mod-
ification of Algorithm 9.5 taking only 27 M(m) + M(n) + O(n) ring operations. Burnikel
& Ziegler (1998) give a divide-and-conquer algorithm for division with remainder taking
time about 2M(n) when Karatsuba multiplication is used; see also Jebelean (1997).
9.2. Algorithm 9.14 is from von zur Gathen (1990a). In fact, the Taylor expansion can be
computed with M(n) + O(n) or O(M(n)) ring operations (Aho, Steiglitz & Ullman 1975,
see also Schönhage, Grotefeld & Vetter 1994, page 284, and Exercise 9.49).
9.3. The Taylor expansion goes back to Taylor (1715) and Maclaurin (1742), and is already
in Newton (1710) for ϕ = yn .
9.4 and 9.5. The formulas of Newton’s iteration for square and cube roots were known by
the Babylonians, and appear in the 6th century Indian text Āryabhat.ı̄ya. Muh.ammad al-
Khwārizmı̄ described the Newton iteration for square roots around 830 (see Folkerts 1997).
Jamshı̄d Al-Kāshı̄, who lived in Samarkand in the early 15th century, had used a single
Newton step for root finding. Both one- and two-dimensional Newton iteration is explicitly
described in Waring (1770). The history of Newton’s method is traced in Goldstine (1977),
§2.4. Cauchy (1847) describes the arithmetic Newton iteration for finding, from a root of
Exercises 287
an integer polynomial modulo m, roots modulo m2 , m3 , . . . . Bach & Sorenson (1993) and
Bernstein (1998b) present efficient tests whether an integer is a perfect power.
9.6. Von Koch (1904) designed a continuous curve which is nowhere differentiable. Three
joint copies of it—called a Koch snowflake or a Koch island—form the boundary of the
fractal in Figure 9.4. Each of the six white areas around the center “subflake” has again a
Koch flake as boundary, and so on forever (or at least up to the resolution).
The total length of the edges grows exponentially fast. At each iteration, the (linear)
size of the hexagon shrinks to 1/3. If we draw the edges of the hexagon, as in Figure 9.3,
around the smallest hexagons only, then the total length 6 · l, say, where l is the length of
one edge, is replaced by 7 · 6 · l/3 = 14l. Starting with length 6 cm, as in Figure 9.4, we
get a length of (14/6)3 · 6 cm ≈ 76 cm after three iterations (which is approximated by the
little hexagons in the figure). After 83 iterations, the length is more than (current estimates
of) the diameter of the universe.
We thank Rob Corless for pointing out the relation of our picture of Z(7) to von Koch’s
snowflake.
9.7. The development of B IPOLAR has been discontinued and the system is not available
anymore. Von zur Gathen & Gerhard (1996) describe an extension of Cantor’s (1989)
algorithm. Montgomery (1992) discusses algorithms and implementation results for fast
integer arithmetic, in the context of factoring with the elliptic curve method.
Exercises.
9.1 Use Newton iteration to compute f −1 mod x8 for f = x2 − 2x + 1 ∈ Q[x].
9.2 Compute 94−1 mod 6561 using Newton iteration.
9.3 Let a = x7 + 2x4 − 1 and b = x3 + 2x2 − 3x − 1 in Q[x]. Compute the quotient and remainder
of the division of a by b. Trace by hand the “fast” algorithm for division with remainder on this
example.
9.4−→ Let a = 30x7 + 31x6 + 32x5 + 33x4 + 34x3 + 35x2 + 36x + 37 and b = 17x3 + 18x2 + 19x + 20
in F101 [x], and f ∈ F101 [x] the reversal of b.
(i) Compute f −1 mod x4 .
(ii) Use (i) to find q, r ∈ F101 [x] with a = qb + r and deg r < 3.
(iii) Use the Extended Euclidean Algorithm to find a−1 mod b, that is, a polynomial c ∈ F101 [x] of
degree less than 3 with ac ≡ 1 mod b.
(iv) Use Newton iteration to find a−1 mod b4 .
9.5 Let D be a ring (commutative, with 1) and f , g ∈ D[x] monic of degree n > 0.
(i) Prove that rev( f g)−1 rem x2n can be computed from rev( f )−1 rem xn , rev(g)−1 rem xn , and
f g using 2M(n) + M(2n) + O(n) arithmetic operations in D.
(ii) Prove that rev( f )−1 rem xn can be computed from rev( f g)−1 rem x2n using M(n) + O(n) op-
erations in D.
9.6∗ Consider the following variant of the Newton inversion algorithm 9.3. Instead of computing
i r r−1
f −1 mod x2 for i = 1, 2, . . ., compute the inverse modulo x⌈l/2 ⌉ , x⌈l/2 ⌉ , . . ., x⌈l/2⌉ , xl . Show that
− j
the cost of this algorithm is at most l + ∑1≤ j≤r (M(⌈l2 ⌉)+M(⌈l2 − j−1 ⌉)). Use ⌈l2− j ⌉ ≤ ⌊l2− j ⌋+1
for all j and Exercise 8.34 to conclude that the overall cost is at most 3M(l) + O(l).
9.7 Let D be a ring (commutative, with 1), R = D[x], p ∈ R monic nonconstant, r ∈ N, and f ∈ R of
degree less than n = 2r deg p.
288 9. Newton iteration
r
(i) Show that p2 , p4 , . . ., p2 can be computed with M(n) + O(n) ring operations in D.
(ii) Prove that given the polynomials from (i), rev(p)−1 rem xdeg p , rev(p2 )−1 rem x2 deg p , . . .,
r
rev(p2 )−1 rem xn can be computed using at most 4M(n) + O(n) operations in D. Hint: Exercise 9.5.
r−1 r−2
(iii) Given the data from (i) and (ii), show that f rem p2 , f rem p2 , . . ., f rem p2, f rem p can
be computed with 2M(n) + O(n) operations in D.
r
(iv) Show that when R = Z and f , p ∈ N with f < 2r p, you can compute p2 , p4 , . . ., p2 and
r−1 r−2
f rem p2 , f rem p2 , . . ., f rem p2 , f rem p using O(M(2r log p)) word operations.
9.8 (i) Prove that the Newton inversion algorithm 9.3 works correctly as specified.
(ii) Use Exercise 9.7 to show that the algorithm takes 14M(l deg p) + O(l deg p) ring operations in
D if R = D[x] for a (commutative) ring D, p is monic, l is a power of 2, and deg f < l deg p, and
O(M(l log p)) word operations if R = Z and | f | < pl .
9.9 We consider the linear variant of the Newton inversion algorithm 9.3, where the inverse is com-
puted successively modulo x2 , x3 , x4 , . . ., xl . If gi is the inverse modulo xi , give an explicit formula
for the coefficient of xi in gi+1 in terms of the coefficients of gi and the first i + 1 coefficients of f .
Show that this algorithm takes O(l 2 ) ring operations.
9.10 Show that the cost of the Newton inversion algorithm 9.3 drops to at most 2M(l)+2l arithmetic
operations if char D = 2.
9.11∗ Let D be a (commutative) ring, k ∈ N>0 , and f , g ∈ D[x] with f (0) = 1 and f g ≡ 1 mod xk .
(i) Let d ∈ N, e = 1 − f g, and h = g · (ed−1 + ed−2 + · · · + e + 1). Prove that f h ≡ 1 mod xdk .
(ii) Letting d = 2 gives precisely Algorithm 9.3. State an algorithm for Newton inversion modulo
xl with cubic convergence (that is, d = 3), and analyze its cost when l is a power of 3.
9.12∗ This exercise discusses an alternative to the fast division algorithm 9.5 for computing in
residue class rings. It is an adaption of Montgomery’s (1985) integer algorithm to polynomials.
We let F be a field and f , r ∈ F[x] such that f is nonconstant, deg r < deg f = n, and f and r are
coprime. For a ∈ F[x], we represent the residue class a mod f ∈ R = F[x]/h f i by the polynomial
a∗ = ra rem f ∈ F[x]. This is particularly useful when performing a long computation in R, for
example, a modular exponentiation.
(i) Show that (a + b)∗ = a∗ + b∗ and (ab)∗ ≡ r−1 a∗ b∗ mod f for all a, b ∈ F[x].
(ii) Let s ∈ F[x] of degree less than n be the inverse of f modulo r, so that s f ≡ 1 mod r. Consider
the following algorithm for computing (ab)∗ from a∗ and b∗ .
A LGORITHM 9.35 Montgomery multiplication.
Input: a∗ , b∗ ∈ F[x] of degrees less than n.
Output: (ab)∗ ∈ F[x].
1. u ←− a∗ b∗ , v ←− u rem r
2. w ←− vs rem r, c∗ ←− (u − w f )/r
3. return c∗
Prove that r divides u −w f in step 2. Conclude that the algorithm works correctly, so that deg c∗ <
n and c∗ ≡ r−1 a∗ b∗ mod f , if deg r = n − 1.
(iii) Now let r = xn−1 and show that the algorithm can be executed with 3M(n) +n operations in F.
You may ignore the cost for computing s. Compare this to using Newton iteration with precomputa-
tion.
(iv) Let a ∈ F[x] of degree less than n and r as in (iii). Employ the above algorithm to show that a
can be computed from a∗ using 2M(n) + n operations in F, and that conversely a∗ can be computed
from a using 3M(n) + n operations if r∗ is precomputed.
Exercises 289
9.13 Let F be a field of characteristic different from 2, and M(n), I(n), D(n), S(n) be the computing
times for multiplying two polynomials of degree less than n, computing the inverse of a polynomial
modulo xn , division of a polynomial of degree less than 2n by a polynomial of degree n, and squaring
a polynomial of degree less than n, respectively. Theorems 9.4 and 9.6 show that I ∈ O(M) and
D ∈ O(M). The purpose of this exercise is to show that all four functions are of the same order of
magnitude.
−1
(i) Prove the identity y2 = y−1 − (y + 1)−1 − y, and conclude that S ∈ O(I).
(ii) Show that M ∈ O(S), using the identity f g = (( f + g)2 − f 2 − g2 )/2.
(iii) For a polynomial b ∈ R[x] of degree n, relate revn (b)−1 mod xn to the quotient of x2n−1 on
division by b, and conclude that I ∈ O(D). Conclude that O(M) = O(I) = O(D) = O(S).
9.14∗ Let a, b, q ∈ Z[x] such that a = qb, deg a = n, and ||a||∞ ≤ A. Use Mignotte’s bound 6.33 and
a big prime modular approach to show that q can be computed from a and b using O∼ (n(n + log A))
word operations. You may ignore the cost for finding a big prime. Use Corollary 11.13 for modular
arithmetic. See also Exercises 6.26 and 10.21; the latter discusses the small primes variant.
9.15∗ Let a, b ∈ Z[x] such that n = deg a = m+deg b, with n, m ∈ N, b is monic, and ||a||∞ , ||b||∞ < 2l .
(i) Let f = revdeg b (b) ∈ Z[x]. Prove that ||gi ||∞ < 22(i−1)+l ||gi−1 ||2∞ for 1 ≤ i ≤ r in the Newton
inversion algorithm 9.3.
(ii) Prove that ∑0≤ j<i j2− j ≤ 2 for all i ∈ N. Hint: Consider the formal derivative of the polyno-
mial ∑0≤ j<i x j = (1 − xi )/(1 − x) ∈ Z[x].
(iii) Let S(i) = log ||gi ||∞ for 0 ≤ i ≤ r. Conclude from (i) and (ii) that S(i) ≤ (2 + l)2i ∈ O(nl) for
all i.
(iv) Perform a similar analysis when a, b ∈ R[y][x] are bivariate polynomials over a (commutative)
ring R and b is monic with respect to x.
9.16 This exercise discusses division with remainder when the degrees of the divisor and the quo-
tient differ significantly. Let k, m ∈ N be positive. We consider univariate polynomials over an
arbitrary ring (commutative, with 1, as usual).
(i) Prove that division with remainder of a polynomial a of degree less than km by a monic poly-
nomial b of degree m can be done in time (2k + 1)M(m) + O(km). Hint: Partition the dividend a into
blocks of size m, and compute revm (b)−1 mod xm only once.
(ii) Prove that dividing a polynomial of degree n < km by a monic polynomial of degree n − m
takes at most (k + 3)M(m) + O(km) ring operations. Hint: Exercise 8.35.
Determine a small value for the constant in the “O” in both cases.
9.17 Trace the generalized Taylor expansion algorithm 9.14 on computing the (x2 + 1)-adic expan-
sion of x15 in Q[x].
9.18 Use the integer variant of Algorithm 9.14 to convert the decimal integer 64 180 into hexadeci-
mal.
9.19 This exercise discusses a divide-and-conquer variant of Horner’s rule for computing Taylor
expansions. Let R be a ring (commutative, with 1), u ∈ R, n = 2k ∈ N a power of 2, and a ∈ R[x]
of degree less than n. By writing a = a1 xn/2 + a0 with a0 , a1 ∈ R[x] of degree less than n/2, devise
a recursive algorithm which computes a(x + u) and (x + u)n and takes at most (cM(n) + O(n)) log n
ring operations for some constant c. (The coefficients of a(x + u) are the coefficients in the Taylor
expansion of a around u, by Section 5.6.) Determine a small value for c, and compare your result to
Corollary 9.16.
9.20 Let R be a ring (commutative, with 1) and a, p ∈ R[x] with deg p = m and deg a < km for some
k, m ∈ N. Prove that the coefficients of a can be computed from its p-adic expansion (4) using at
most ( 12 M(km) + O(km))(1 + logk) ring operations when k is a power of 2.
290 9. Newton iteration
Let y be another indeterminate. Show that f has the Taylor expansion f (x) = ∑0≤i≤n f [i] (y) · (x − y)i
around y.
9.27 Let R be a ring (commutative, with 1), f1 , . . ., fr ∈ R[x] and e1 , . . ., er , n ∈ N≥1 . You are to
prove three generalizations of the Leibniz rule.
n
(i) (n−i)
(i) ( f1 f2 )(n) = ∑ f1 f2 , where (i) denotes the ith derivative,
0≤i≤n i
(ii) ( f1 · · · fr )′ = ∑ fi′ ∏ f j ,
1≤i≤r j6=i
e
(iii) ( f1e1 · · · frer )′ = ∑ ei fi′ fiei −1 ∏ f j j .
1≤i≤r j6=i
(iv) Conclude from (ii) that
f′ f′ f′
= 1 +···+ r
f f1 fr
is the partial fraction decomposition of f ′ / f , for f = f1 · · · fr .
9.28 Compute the first 16 decimal digits of the real root of y3 − 2y − 5 using Newton iteration and
y0 = 2 as your starting value. Compare your results with Newton’s (page 219). What are the other
two roots?
9.29 Under which condition does the Newton iteration algorithm 9.22 work for a rational function
ϕ ∈ R(y)? The Newton formula for ϕ = 1/y − f ∈ R(y) gives exactly the inversion procedure from
Theorem 9.2. Why does the polynomial ϕ = f y − 1 ∈ R[y] not work directly?
9.30 Let ϕ = x4 + 25x3 + 129x2 + 60x + 108 ∈ Z[x] and p = 5.
(i) Determine all roots of ϕ mod p in F p .
(ii) Find an a priori bound B such that every root a ∈ Z of ϕ has |a| ≤ B.
(iii) Choose l ∈ N such that 2B < pl , and apply p-adic Newton iteration to all modular roots of ϕ
from (i).
(iv) Use the results from (iii) to find all roots of ϕ in Z.
9.31∗ Let R = D[x] for a (commutative) ring D, and ϕ, p, l, g0 be inputs to the p-adic Newton iter-
ation 9.22 with p monic nonconstant, deg g0 < deg p, degx ϕ < l deg p, and degy ϕ = n. Show that
Algorithm 9.22 takes O(n M(l deg p)) operations in D. Hint: Exercise 9.7.
Exercises 291
Prove that ϕ(h) ≡ 0 mod pk+1 , h ≡ g mod pk , and sϕ′ (h) ≡ 1 mod p. Derive a linearly conver-
gent analog of Algorithm 9.22 from this, and show that when R = D[x] for a ring D and p = x, it
takes O(nl 2 ) operations in D. This is slower than the quadratically convergent variant, but has the
advantage that the inverse of the derivative need not be updated.
9.34 Derive the formula
1 a
gi+1 = gi +
2 gi
for i ≥ 0, which was already known to the Babylonians, and is the Newton iteration for approximat-
ing the square root of a. Using this formula, compute a square root of 2 modulo 38 . What is the
corresponding formula for computing an nth root of a?
√
9.35 Find the Newton formula for approximating 1/ a. What is the remarkable difference to the
√
Newton formula for a?
9.36 Compute a square root g ∈ Q[x] of f = 1 + 4x ∈ Q[x] modulo x8 such that g(0) = 1, using
Newton iteration.
9.37 Compute a cube root of 2 modulo 625, that is, g ∈ {0, . . ., 624} such that g3 ≡ 2 mod 625.
How many such g are there?
9.38 Consider
√ the three prime numbers p = 5, 7, and 17. We want to calculate p-adic approxima-
tions to 2.
(i) For which of the three p does 2 have a square root modulo arbitrary powers of p?
(ii) For those p where possible, compute all square roots of 2 modulo p6 .
9.39 Let a ∈ N>0 be of word length l, such that a < 264l . For n ∈ N, we denote by T (n) the number
of word operations to compute an using repeated squaring. Prove that T (n) ≤ T (⌊n/2⌋) + O(M(nl))
if n > 1, and conclude that T (n) ∈ O(M(nl)). What is the corresponding result when a is a univariate
polynomial over a (commutative) ring R?
9.40−→ For n ∈ N≥2 and a ∈ Z let Sn (a) be the number of solutions g ∈ {0, . . ., n − 1} of the
quadratic congruence g2 ≡ a mod n.
(i) Which values for S p (a) are possible when p is prime? Distinguish the three cases p = 2, p | a
and 2 6= p ∤ a.
(ii) Let p 6= 2 be prime and e ∈ N>0 . Show that S pe (a) = S p (a) if p ∤ a, and give a counterexample
when p | a.
(iii) Now let n be an odd integer and n = pe11 · . . . · per r its prime factorization, with distinct primes
p1 , . . ., pr ∈ N and positive integers e1 , . . ., er . Find a formula expressing Sn (a) in terms of S p1(a), . . .,
S pr (a) in the case where a and n are coprime. Hint: Chinese Remainder Theorem. Conclude that
Sn (1) = 2r .
(iv) Which of the numbers 10 001, 42 814, 31 027, 17 329 have square roots modulo 50 625?
(v) Compute all square roots of 91 modulo 2025 and of 1 modulo 50 625.
9.41∗ For n ∈ N≥2 and a ∈ Z let Cn (a) be the number of solutions g ∈ {0, . . ., n − 1} of the cubic
congruence g3 ≡ a mod n.
(i) Show that the following hold for an odd prime p:
292 9. Newton iteration
◦ C p (a) ≤ 3,
◦ C p (a) = 1 if p | a or p = 3,
◦ C p (a) 6= 2, and for any value C ∈ {0, 1, 3} there is an odd prime p and an integer a such that
3 6= p ∤ a and C p (a) = C.
(ii) Let p > 3 be a prime and e ∈ N>0 . Show that C pe (a) = C p (a) if p ∤ a, and give a counterexample
when p | a.
(iii) Now let n ∈ N such that gcd(n, 6) = 1, and let n = pe11 · . . . · per r be its prime factorization, with
distinct primes p1 , . . ., pr ∈ N and positive integers e1 , . . ., er . Find a formula expressing Cn (a) in
terms of C p1 (a), . . .,C pr (a) in the case where a and n are coprime.
(iv) Compute all cube roots of 11 modulo 225 625.
9.42 Let n ∈ N>0 . How many cube roots g ∈ F7 [x] modulo xn of degree less than n does f =
−x3 + x2 − x + 1 ∈ F7 [x] have, and how can they be computed? Compute one for n = 4.
9.43∗ Modify the algorithm for computing nth roots in Z so as to work when n is a power of 2, by
using a 3-adic Newton iteration. Prove that your algorithm is correct, and√show that is uses O(M(l))
word operations on inputs of length l. Apply your algorithm to compute 4 2 313 441.
9.44∗ Design a test whether a ∈ N is a perfect power. Your test should output b, d, e, r ∈ N such that
a = 2d 3e br , gcd(b, 6) = 1, and r is maximal, using O(log a · M(log a)) word operations.
9.45 Let R be a ring (commutative, with 1) with a valuation v, with the special property that v(a) ≤ 1
for all a ∈ R. Show that if a ∈ R is a unit, then v(a) = 1.
9.46 Let R be an integral domain with a valuation v, and K the field of fractions of R. Show that
w(a/b) = v(a)/v(b) defines a valuation w on K.
9.47 Conclude the proof of Lemma 9.34.
9.48∗ Let F be a field, and v: F[[x]] −→ R be the x-adic valuation on the ring F[[x]] of formal power
series.
(i) For n ∈ N, let fn = 1 + x + · · ·+ x2n − x2n+1 ∈ F[[x]]. Show that f0 , f1 , · · · is a Cauchy sequence,
so that
∀ε > 0 ∃N ∈ N ∀n, m > N v( fn − fm ) ≤ ε.
(ii) Prove that the sequence has a limit in F[[x]], so that there exists f ∈ F[[x]] with
∀ε > 0 ∃N ∈ N ∀n > N v( f − fn ) ≤ ε.
(iii) Prove that every Cauchy sequence in F[[x]] has a limit in F[[x]], so that F[[x]] is complete.
Show that F[x] with the x-adic valuation does not have this property. (In fact, F[[x]] can be obtained
from F[x] by the same process of “completion” by which one obtains R from Q with respect to the
absolute value.)
(iv) Let f = a0 + a1 x + · · · ∈ F[[x]], and a0 = 0. Prove that f does not have an inverse in F[[x]].
(v) Let f = a0 + a1 x + · · · ∈ F[[x]], and a0 6= 0. Use Newton iteration to prove that f has an inverse
in F[[x]].
9.49 (Aho, Steiglitz & Ullman 1975; see also Schönhage, Grotefeld & Vetter 1994, page 284)
In this exercise, you are to improve the cost estimate of Corollary 9.16 by a factor of log n. Let
n ∈ N, R a ring such that (n − 1)! is a unit in R, u ∈ R, and a = ∑0≤i<n ∈ R[x]. Moreover, let
f = ∑0≤i<n i! ai xn−1−i and g = ∑0≤ j<n u j x j / j!. Show that the coefficient of xk in the polynomial
a(x + u) is equal to 1/k! times the coefficient of xn−1−k in the product polynomial f g, for 0 ≤ k < n.
Conclude that the coefficients of a(x + u), or equivalently, the coefficients of the Taylor expansion of
a around u, by Section 5.6, can be computed using M(n) + 5n arithmetic operations in R.
The second concept is the asymptotic behavior of the number of
operations. This was not significant for small N so the importance of
early forms of the FFT algorithms was not noticed even where they
would have been very useful.
James William Cooley (1987)
1 There is an astonishing imagination in mathematics. [. . . ] There was far more imagination in the head of
Archimedes than in that of Homer.
2 Leibniz believed he saw the image of creation in his binary arithmetic in which he employed only the two
characters, zero and unity. He imagined that unity can represent God, and zero nothing; and that the Supreme
Being might have drawn all beings from nothing, just as unity with zero expresses in this binary arithmetic all
numbers.
10
Fast polynomial evaluation and interpolation
In the preceding chapters, we have seen extremely fast algorithms for multiplica-
tion and division with remainder. We now tackle the next set of problems: eval-
uation of a polynomial at many points, its inverse problem, namely interpolation,
and a substantial generalization, the Chinese Remainder Algorithm.
χ: R[x]/hmi −→ Rn
f 7−→ ( f (u0 ), . . . , f (un−1 ))
is a ring homomorphism. If R is a field, then R[x] and Rn are vector spaces over R,
thus R-algebras, and χ is in fact an isomorphism of R-algebras if u0 , . . . , un−1 are
distinct. This is a special case of the Chinese Remainder Theorem 5.3.
In this and the next section, we want to solve the following two problems. We
simplify our exposition by assuming that the number n of points is a power of 2.
For general n, we have the two options of either adding some “phantom” points
or splitting points into two roughly equal halves in the recursive calls. This is
discussed after Theorems 8.3 and 9.15.
295
296 10. Fast polynomial evaluation and interpolation
We have already discussed these problems for a field R and presented algorithms
taking time O(n2 ) in Chapter 5. The methods of this chapter are only of interest
in connection with subquadratic multiplication routines, as those from Chapter 8.
There we have seen that the evaluation and interpolation problems can be solved
with O(n log n) operations in R if R supports the FFT and ui = ω i , where ω is a
primitive nth root of unity. Our goal now is a similar bound for the general case.
For arbitrary points u0 , . . . , un−1 , multipoint evaluation can be done with O(n2 )
operations in R by using Horner’s rule n times. In fact, it can be proved that one
evaluation requires at least n multiplications. One might be tempted to think that
then n evaluations require at least n2 multiplications. This is false, and our goal
in this section is to see that mass-production of evaluations can be done much
cheaper. In the next section, we show the same bound for interpolation.
The idea of the evaluation algorithm is to split the point set {u0 , . . . , un−1 } into
two halves of equal cardinality and to proceed recursively with each of the two
halves. This leads to a binary tree of depth log n with root {u0 , . . . , un−1 } and the
singletons {ui } for 0 ≤ i < n at the leaves (see Figure 10.1), where log is the binary
logarithm.
i=k u0 , . . . , un−1
Mk,0
i = k−1 u0 , . . . , un/2−1 un/2 , . . . , un−1
.. Mk−1,0 Mk−1,1
. .. .. .. ..
. . . .
for 0 ≤ i ≤ k = log n and 0 ≤ j < 2k−i . Thus each Mi, j is a subproduct with 2i
10.1. Fast multipoint evaluation 297
factors of m = ∏0≤l<n ml = Mk,0 and satisfies for each i, j the recursive equations
If R is an integral domain and u0 , . . . , un−1 are distinct, then Mi, j is the monic
squarefree polynomial whose zero set is the jth node from the left at level i of the
tree in Figure 10.1.
The following algorithm solves the more general problem of computing the sub-
products Mi, j for arbitrary moduli m0 , . . . , mr−1 . It proceeds from the leaves to the
root of the subproduct tree in Figure 10.1.
1. for j = 0, . . . , r − 1 do M0, j ←− m j
2. for i = 1, . . . , k do
L EMMA 10.4. Algorithm 10.3 correctly computes all subproducts Mi, j ∈ R[x] and
takes at most M(n) log r operations in R, where n = ∑0≤i<r deg mi .
P ROOF. Correctness is clear from (2). Let di, j = deg Mi, j for all i and j. Step 1
uses no arithmetic operations, and the cost for the ith iteration of step 3 is at most
∑ M(di, j ) ≤ M ∑ di, j = M(n)
0≤ j<2k−i 0≤ j<2k−i
operations in R, since ∑0≤ j<2k−i di, j = n. The time estimate follows, since there are
k = log r iterations. ✷
Exercise 10.8 proves an analogous result for integers. If all mi have the same
degree, then Exercise 10.3 proves the better timing estimate ( 12 M(n) + O(n)) log r.
If the degrees of the mi differ considerably from each other, then the tree in Figure
10.1 is quite unbalanced with respect to the degree. In fact, it is possible to prove
a slightly better bound on the arithmetic cost for that case. If p0 , . . . , pr−1 ∈ R are
positive probabilities that sum to 1, then
1. if n = 1 then return f
T HEOREM 10.6.
Algorithm 10.5 works correctly and takes at most D(n) log n operations in R, which
is at most (5M(n) + O(n)) log n or O(M(n) log n).
Let T (n) = T (2k ) denote the cost for the recursive process. Then T (1) = 0 and
for k ≥ 1, so that T (2k ) ≤ 2k · D(2k−1 ) ≤ D(n) log n, by Lemma 8.2, and the claim
follows from Theorem 9.6. ✷
Putting things together, we obtain the following algorithm for fast multipoint
evaluation.
2. call Algorithm 10.5 with input f , the points ui , and the subproducts Mi, j
return its results
C OROLLARY 10.8.
Evaluation of a polynomial in R[x] of degree less than n at n points in R can be
performed using at most ( 11
2 M(n) + O(n)) log n or O(M(n) log n) operations in R.
The time bound follows from Exercise 10.3 and Theorem 10.6. Exercise 10.9
proves the smaller bound (1 + 27 log n)(M(n) + O(n)). Exercise 10.11 shows that
if many evaluations at the same set of points have to be performed, then all data
depending only on the evaluation points may be precomputed and stored, and the
cost drops to essentially (2M(n) + O(n)) log n.
f ∈ F[x] of degree less than n that takes the value vi at the point ui for all i is
f = ∑0≤i<n vi si m/(x − ui ), where m = (x − u0 ) · · · (x − un−1 ), as before, and
1
si = ∏ . (3)
j6=i ui − u j
Over a ring R, this is still valid if we demand that ui −u j is a unit for i 6= j. Theorem
10.13 below shows that this condition is also necessary in the general case.
We first explain an idea to compute the si fast. The formal derivative m is m′ =
∑0≤ j<n m/(x − u j ), and since m/(x − ui ) vanishes at all points u j with j 6= i, we
have
′ m 1
m (ui ) = = . (4)
x − ui x=ui si
Given m, the computation of all the si amounts to one evaluation of m′ at n points,
at a cost of O(M(n) log n) operations in R, plus n inversions.
The following divide-and-conquer algorithm is the core of the fast interpolation
algorithm. It proceeds from the leaves to the root of the tree in Figure 10.1.
1. if n = 1 then return c0
Mk−1,0
2. call the algorithm recursively to compute r0 = ∑ ci
0≤i<n/2
x − ui
Mk−1,1
3. call the algorithm recursively to compute r1 = ∑ ci
n/2≤i<n
x − ui
T HEOREM 10.10.
Algorithm 10.9 takes at most (M(n) + O(n)) log n or O(M(n) log n) arithmetic op-
erations in R to correctly compute the result.
Let T (n) = T (2k ) denote the cost of the algorithm. The cost for the individ-
ual steps is 0 for step 1, T (n/2) for each of the steps 2 and 3, and at most
2M(n/2 + 1) + n ∈ M(n) + O(n) (Exercise 8.34) for step 4. (The “+1” comes
from our convention that M(n) is the time to multiply polynomials of degree less
than n.) Thus T (1) = 0 and T (n) ≤ 2T (n/2) + M(n) + cn for n > 1 and some
constant c ∈ R, and Lemma 8.2 yields the claim. ✷
C OROLLARY 10.12.
Algorithm 10.11 solves the interpolation problem 10.2 over a (commutative) ring
R using at most ( 13
2 M(n) + O(n)) log n or O(M(n) log n) operations in R.
P ROOF. The cost for step 1 is at most ( 12 M(n) + O(n)) log n, by Exercise 10.3.
The cost for step 2 is at most (5M(n) + O(n)) log n operations, by Theorem 10.6,
including the computation of m′ and the final modular inversions. Finally, step 3
takes no more than (M(n) + O(n)) log n operations, by Theorem 10.10. ✷
Exercise 10.11 shows that if many interpolations at the same set of points have
to be performed, then all data depending only on the interpolation points may be
precomputed and stored, and the cost drops to essentially (M(n) + O(n)) log n.
T HEOREM 10.13.
Let r ≥ 1, R be a ring (commutative, with 1, as always), m0 , . . . , mr−1 ∈ R[x] monic
and nonconstant, and m = m0 · · · mr−1 . Then the following are equivalent.
(i) The ring homomorphism χ in (5) is an isomorphism.
(ii) There exist polynomials s0 , . . . , sr−1 ∈ R[x] such that ∑0≤i<r si m/mi = 1.
(iii) For i 6= j there exist polynomials si j ,ti j ∈ R[x] such that si j m j + ti j mi = 1.
(iv) res(mi , m j ) ∈ R× for i 6= j.
T HEOREM 10.15.
Algorithm 10.14 works correctly and takes no more than (10M(n) + O(n)) log r or
O(M(n) log r) operations in R.
P ROOF. The correctness proof is similar to that of Theorem 10.6 and left as Ex-
ercise 10.15. For the cost analysis, we see that the algorithm works from the root
to the leaves along the binary tree formed by the subproducts Mi, j . The cost for a
vertex Mi, j with i ≥ 1 is the cost for dividing a polynomial of smaller degree than
deg Mi, j by Mi−1,2 j and Mi−1,2 j+1 with remainder, using at most 2D(deg Mi, j ) ring
operations. The total cost at level i is then at most 2 ∑0≤ j<2i D(deg Mi, j ) ≤ 2D(n),
as in the proof of Lemma 10.4, and the claim follows from Theorem 9.6 and the
fact that there are log r levels. ✷
C OROLLARY 10.17.
Given monic nonconstant polynomials m0 , . . . , mr−1 ∈ R[x], where r ∈ N is a power
of 2, and f ∈ R[x] of degree less than n = ∑0≤i<r deg mi , Algorithm 10.16 computes
f rem m0 , . . . , f rem mr−1 using at most (11M(n) + O(n)) log r or O(M(n) log r)
operations in R.
Exercise 10.17 gives a better analysis of Algorithm 10.16 when all moduli have
the same degree.
For the fast Chinese Remainder Algorithm, we recall the generalization of La-
grange’s formula from Chapter 5. Given pairwise distinct and nonconstant mod-
uli m0 , . . . , mr−1 ∈ F[x] for a field F and polynomials v0 , . . . , vr−1 ∈ F[x] with
deg vi < deg mi for all i, there is a unique polynomial f ∈ F[x] of degree less
than n = ∑0≤i<r deg mi satisfying f ≡ vi mod mi for all i, and it is given by f =
∑0≤i<r (vi si rem mi )m/mi , where m = m0 · · · mr−1 and si ∈ F[x] is an inverse of
m/mi modulo mi . Theorem 10.13 implies that this is true for arbitrary coefficient
rings R if we require res(mi , m j ) ∈ R× for i 6= j.
As in the case of interpolation, we first address the task of computing the si .
This need be done only once if several computations with the same set of moduli
are to be executed.
304 10. Fast polynomial evaluation and interpolation
4. return s0 , . . . , sr−1
P ROOF. Let R be a field and di = deg mi for 0 ≤ i < r. The cost for step 1 is
O(M(2n) log r) ring operations, including the cost for computing all m2i . Step 2
costs D(di ) ∈ O(M(di )) for mi . In Chapter 11, we will see that step 3 can be done
with O(M(di ) log di ) operations in R for each i. Using
∑ M(di ) ≤ M ∑ di = M(n),
0≤i<r 0≤i<r
we have a cost of O(M(n)) and O(M(n) log n) for steps 2 and 3, respectively, and
the claim follows. ✷
1. if r = 1 then return c0
Mk−1,0
2. call the algorithm recursively to compute r0 = ∑ ci
0≤i<r/2
mi
10.3. Fast Chinese remaindering 305
Mk−1,1
3. call the algorithm recursively to compute r1 = ∑ ci
r/2≤i<r
mi
T HEOREM 10.21.
Algorithm 10.20 works correctly. If ∑0≤i<r deg mi < n, then it takes no more than
(2M(n) + O(n)) log r or O(M(n) log r) arithmetic operations in R.
The correctness proof is analogous to the proof of Theorem 10.10 and the run-
ning time bound can be obtained by considering the same binary tree as in the
proof of Theorem 10.15. The details can be found in Exercise 10.16.
1. call Algorithm 10.3 with input m0 , . . . , mr−1 to compute the polynomials Mi, j
as in (1)
2. call Algorithm 10.18 with input m0 , . . . , mr−1 and m = Mk,0 to compute poly-
m
nomials si ∈ R[x] with si ≡ 1 mod mi and deg si < deg mi for all i
mi
3. call Algorithm 10.20 with input m0 , . . . , mr−1 , v0 s0 rem m0 , . . . , vr−1 sr−1 rem
mr−1 , and the polynomials Mi, j
return its result
C OROLLARY 10.23.
Given m0 , . . . , mr−1 ∈ F[x] monic and pairwise coprime, where F is a field, and
v0 , . . . , vr−1 ∈ F[x] with deg vi < deg mi for all i, we can compute the unique solution
f ∈ F[x] of degree less than n = ∑0≤i<r deg mi of the Chinese Remainder Problem
Exercise 10.17 gives an explicit constant for the leading cost term of Algorithm
10.22 when all moduli have the same degree.
We only state the corresponding results for the integer case. Algorithms 10.14
and 10.20 carry over almost literally; the details are left as an exercise.
306 10. Fast polynomial evaluation and interpolation
T HEOREM 10.24.
Given m0 , . . . , mr−1 ∈ N≥2 and f ∈ N less than m = ∏0≤i<r mi , we can compute
f rem m0 , . . . , f rem mr−1 using O(M(log m) log r) word operations.
T HEOREM 10.25.
Given pairwise coprime integers m0 , . . . , mr−1 ∈ N≥2 and v0 , . . . , vr−1 ∈ N such
that vi < mi for all i, we can compute the unique solution f ∈ N with f < m =
∏0≤i<r mi of the Chinese Remainder Problem f ≡ vi mod mi for 0 ≤ i < r, at a
cost of O(M(log m) loglog m) word operations.
Notes. Pan (1966) proved the optimality of Horner’s rule. The results in Sections 10.1
through 10.3 are based on Lipson (1971), Fiduccia (1972a), Horowitz (1972), Moenck &
Borodin (1972), and Borodin & Moenck (1974). Borodin & Munro (1975) give a compre-
hensive treatment.
Exercises.
10.1 Let f = 8x7 + 7x6 + 6x5 + 5x4 + 4x3 + 3x2 + 2x + 1 ∈ Q[x]. Trace Algorithm 10.7 to evaluate f
at the eight integer points −3, −2, · · ·, 4. In the recursive algorithm 10.5, you need only execute the
last recursive step and may compute its inputs directly.
10.2 Let R be a ring (commutative, with 1), n ∈ N a power of 2, and k ∈ N. Show that you can
evaluate a polynomial of degree less than kn at n points from R using (2k + 1 + 11
2 log n)M(n) +
O((k + log n)n) additions and multiplications in R. Hint: Exercise 9.16.
10.3 Let R be a ring (commutative, with 1), m0 , . . ., mr−1 ∈ R[x] of degree d > 0, and n = rd, where
r is a power of two. Using Exercise 8.34, prove that Algorithm 10.3 takes only (M(n/2) + O(n)) log r
or ( 12 M(n) + O(n)) log r ring operations.
5/12 7/12
1/12 1/6
(i) Prove that the average depth of any stochastic mobile with leaf weights p1 , . . ., pn is at least
H(p1 , . . ., pn ). Hint: Induction on n.
(ii) For given p1 , . . ., pn ∈ R>0 such that ∑1≤i≤n pi = 1, let li = −⌊log pi ⌋ > 0 for 1 ≤ i ≤ n,
l = max{li : 1 ≤ i ≤ n}, and n j be the number of indices i such that li = j, for 1 ≤ j ≤ l. Prove that
∑1≤ j≤l n j 2− j ≤ 1.
(iii) Consider the following algorithm, which uses ideas by Shannon (1948), Fano (1949, 1961),
and Kraft (1949) for constructing a stochastic mobile of small average depth.
A LGORITHM 10.26 Building a mobile.
Input: p1 , . . ., pn ∈ R>0 such that ∑1≤i≤n pi = 1.
Output: A stochastic mobile with leaf weights p1 , . . ., pn .
1. let l1 , . . ., ln , l, n1 , . . ., nl be as in (ii), and create a full binary tree t (that is, a complete binary
tree with 2l leaves of depth l) with all node weights equal to zero
2. for j = 1, . . ., l do
3. assign those weights pi with li = j to the first n j of the nodes of depth j in t and
remove the subtree of each such node with positive weight from t
4. for j = l, l − 1, . . ., 1 remove the leaves of depth j with zero weight in t
5. while the tree t is not complete, so that there exists a node with a single child, identify that
node with its child and remove the edge between them
6. compute the weights of the inner nodes in t, proceeding from the leaves to the root
return t
Use (ii) to show that before the jth pass through step 3, there are precisely 2 j −n1 2 j−1 −n2 2 j−2 −
· · · − n j−1 · 2 ≥ n j nodes of depth j left in t, and conclude that the algorithm works correctly.
(iv) Prove that the average depth of t after step 4 is less than H(p1 , . . ., pn ) + 1, and conclude that
this is true as well for the tree returned in step 6.
(v) Run the algorithm with p1 = p3 = p7 = p8 = 1/17, p2 = 5/17, p4 = p5 = 2/17, and p6 = 4/17.
10.6∗ This exercise discusses Huffman (1952) codes, a tool for data compression. Suppose that we
want to encode a piece of text over a finite alphabet Σ = {σ1 , . . ., σn } in binary using as few bits as
possible. If we know nothing more than the size of Σ, then there seems to be no better way than to
choose some encoding of the elements Σ as bit strings of fixed length ⌈log n⌉. Suppose now that for
each element σi , we know the frequency pi with which it occurs in our text. The idea of the Huffman
code is then to use a variable-length encoding which encodes letters that occur frequently by shorter
bit strings than letters that only rarely occur. Huffman codes are instantaneous codes, so that no
codeword is a prefix of another codeword, and can be represented by binary trees.
Here is an algorithm which dynamically builds a stochastic mobile (Exercise 10.5) with leaf
weights p1 , . . ., pn , the Huffman tree, which has minimal average depth.
A LGORITHM 10.27 Building a Huffman tree.
Input: p1 , . . ., pn ∈ R>0 such that p1 + · · · + pn = 1.
Output: A Huffman tree for p1 , . . ., pn .
308 10. Fast polynomial evaluation and interpolation
10.11 In this exercise, you are to examine the cost for several evaluations and interpolations at
the same set of points. Show that one evaluation can be done with at most (2M(n) + O(n)) log n
operations in R and one interpolation with at most (M(n) + O(n)) logn) operations if the cost for
precomputing data depending only on the points is ignored. Hint: Some preconditioning on the
divisors in the “going down” is possible; see Section 9.1.
10.12∗ Let n = 2k be a power of 2, F a field, u0 , . . ., un−1 ∈ F distinct, and v0 , . . ., vn−1 ∈ F. You
are to design an interpolation algorithm with running time O(M(n) log2 n).
(i) Let m1 , m2 ∈ F[x] of degree n be monic and coprime and v1 , v2 ∈ F[x] of degree less than n.
Using Theorem 11.10, give an algorithm that computes a solution f ∈ F[x] of degree less than 2n of
the congruences f ≡ v1 mod m1 and f ≡ v2 mod m2 , taking O(M(n) log n) operations in F.
(ii) Use (i) to design a divide-and-conquer algorithm computing the interpolating polynomial
f ∈ F[x] of degree less than n such that f (ui ) = vi for all i, and show that it takes O(M(n) log2 n)
operations in F.
(iii) Trace your algorithm on the example from Exercise 10.10.
10.13∗ Prove Theorem 10.13. Hint: Exercise 6.15.
10.14∗ Prove the following generalized version of the Chinese Remainder Theorem. Let R be a ring
(commutative, with 1), I0 , . . ., Ir−1 ideals, and I = I0 ∩ · · · ∩ Ir−1 . If Ii + I j = R for i 6= j, then the map
is an isomorphism.
10.15 Prove that Algorithm 10.14 works correctly.
10.16∗ Prove Theorem 10.21.
10.17∗ (i) Prove that when all moduli have the same degree, then the fast modular reduction
algorithm 10.16 takes only (11M(n/2) + O(n)) log r or ( 11 2 M(n) + O(n)) log r ring operations and
Algorithm 10.20 takes only (M(n) + O(n)) log r operations.
(ii) Show that Algorithm 10.18 takes at most (11 log r + 24 log(n/r) + 5)M(n) + O(n log n) arith-
metic operations if R is a field and all moduli have the same degree, using (i) and Theorem 11.10.
(iii) Conclude that the fast Chinese Remainder Algorithm 10.22 takes at most (24M(n) + O(n)) ·
log n arithmetic operations if R is a field and all moduli have the same degree.
You may find Exercise 10.3 useful.
10.18 Let F be a field, f1 , . . ., fr ∈ F[x] pairwise coprime, e1 , . . ., er ∈ N>0 , f = f1e1 · · · frer , and
g ∈ F[x] of degree less than deg f . Show that the partial fraction decomposition of g/ f with respect to
the given factorization of f (see Section 5.11) can be computed with O(M(n) log n) field operations.
10.19∗ Work out the details for the integer versions of Algorithms 10.14 and 10.20, and prove
Theorems 10.24 and 10.25.
10.20−→ You are to trace the integer analog of Algorithms 10.14 and 10.20. The point is to see
how the algorithm works, not just to compute the final result. Let m0 = 23, m1 = 24, m2 = 25, and
m3 = 29.
(i) Check that the moduli are pairwise coprime.
(ii) Compute the binary tree of products.
(iii) Compute 300 000 mod mi for 0 ≤ i < 3, using Algorithm 10.14.
(iv) Let v0 = 5, v1 = 3, v2 = 1, and v3 = 22. Use the fast Chinese Remainder Algorithm to compute
f ∈ Z such that f ≡ vi mod mi for 0 ≤ i < 4.
310 10. Fast polynomial evaluation and interpolation
10.21∗ Let a, b ∈ Z[x] nonzero such that deg b < deg a = n and ||a||∞ ≤ A. You are to design a small
primes modular algorithm that decides whether b | a, and if so, computes the quotient q = a/b ∈ Z[x].
By Mignotte’s bound 6.33, we have ||b||1 ||q||1 ≤ B = (n + 1)1/2 2n A in the latter case. The algorithm
should choose a collection of distinct primes p1 , . . ., pr < 2r log r not dividing lc(b), with r chosen
appropriately such that their product exceeds 2B, calculate (a mod pi )/(b mod pi ) for all i (if this
is not possible, then certainly b ∤ a), compute a trial quotient q by Chinese remaindering, and fi-
nally check whether ||b||1 ||q||1 ≤ B. Work out the details, prove that this procedure works correctly,
and show that it takes O((M(n) + logloglog B) log B · M(loglog B) + n M(log B loglog B) loglog B) or
O∼ (n2 + n log A) word operations. You may ignore the cost of O(log B(loglog B)2 logloglog B) word
operations for finding the small primes (Theorem 18.10). Use Corollary 11.13 for arithmetic in F pi .
See also Exercises 6.26 and 9.14.
The mathematically sophisticated will know how to skip formulæ.
This skill is easy to practice for others also.
Leslie G. Valiant (1994)
1 Have you [Glaukon] ever noticed that those who have a talent for mathematics are, almost without exception,
talented in all sciences? And that mentally slow people, if they be trained and exercised in this study, become
invariably quicker than they were before, even if they draw no other profit from it?
11
Fast Euclidean Algorithm
The main result of this chapter is a fast algorithm for the quotients in the Euclidean
Algorithm for univariate polynomials over a field, using O(M(n) log n) field oper-
ations for inputs of degree at most n. One can also compute a single remainder ri
together with the corresponding si and ti , at the same cost, but this is not possible
for all remainders together. The final section shows how one can also calculate
subresultants in softly linear time.
In order to make the description and the proofs simpler, the fast Euclidean Algo-
rithm that we present in this section will not make the remainders in intermediate
computations monic, but only at the end, if desired. For that reason, it is most suit-
able for coefficient fields with a fixed size representation for the elements, such as
finite fields. For other coefficient domains, it is best to use a combination of the
modular algorithms described in Chapter 6 with the algorithm in this chapter.
r2 = r0 − q1 r1 , s2 = s0 − q1 s1 , t2 = t0 − q1t1 ,
.. .. ..
. . .
ri+1 = ri−1 − qi ri , si+1 = si−1 − qi si , ti+1 = ti−1 − qiti , (1)
.. .. ..
. . .
0 = rℓ−1 − qℓ rℓ , sℓ+1 = sℓ−1 − qℓ sℓ , tℓ+1 = tℓ−1 − qℓtℓ
313
314 11. Fast Euclidean Algorithm
where
0 1 2×2 si ti
Qi = ∈ F[x] and Ri = Qi · · · Q1 = . (2)
1 −qi si+1 ti+1
Let ni = deg ri for 0 ≤ i ≤ ℓ and mi = deg qi = ni−1 − ni for 1 ≤ i ≤ ℓ. The
sequence (n0 , n1 , . . . , nℓ ) is the degree sequence in the Extended Euclidean Algo-
rithm for r0 , r1 . If F = Fq is a finite field with q elements and r0 , r1 ∈ Fq [x] with
deg r0 = n0 > deg r1 = n1 are uniform random polynomials, then
1
prob(deg r2 < n1 − 1) =
q
(Exercise 4.18), which is rather small for large q. So typically one can expect that
the degree of each quotient is 1, or equivalently, that ni+1 = ni − 1 for 1 ≤ i < ℓ. In
that case, we call the degree sequence (n0 , . . . , nℓ ) normal.
The basic idea leading to a fast gcd algorithm is that the first quotients qi only
depend on the highest coefficients of r0 and r1 . To express this idea formally, we
introduce some notation.
Let f = fn xn + fn−1 xn−1 + · · · + f0 ∈ F[x] with leading coefficient fn 6= 0, and
k ∈ Z. Then we define the truncated polynomial
f ↾ k = f quo xn−k = fn xk + fn−1 xk−1 + · · · + fn−k ,
where we set fi = 0 for i < 0. So for k ≥ 0, f ↾ k is a polynomial of degree k whose
coefficients are the k + 1 highest coefficients of f , and f ↾ k = 0 if k < 0. We also
define f ↾ −∞ = 0, and 0 ↾ k = 0 for all k ∈ Z ∪ {−∞}. For all i ≥ 0 we have that
( f xi ) ↾ k = f ↾ k.
Now let f , g, f ∗ , g∗ ∈ F[x] with f , f ∗ both nonzero, deg f ≥ deg g and deg f ∗ ≥
deg g∗ , and k ∈ Z. Then (f, g) and (f ∗ , g ∗ ) coincide up to k if
f ↾ k = f ∗ ↾ k,
g ↾ (k − (deg f − deg g)) = g∗ ↾ (k − (deg f ∗ − deg g∗ )).
This defines an equivalence relation on F[x] \ {0} × F[x] (Exercise 11.1). If ( f , g)
and ( f ∗ , g∗ ) coincide up to k and k ≥ deg f − deg g, then deg f − deg g = deg f ∗ −
deg g∗ .
We consider one division step in the Euclidean Algorithm.
and
f − f ∗ = q(g − g∗ ) + (q − q∗ )g∗ + (r − r∗ ). (4)
The polynomials f − f ∗ , q(g − g∗ ) and r − r∗ all have degree less than deg g by (3),
hence also deg((q − q∗ )g∗ ) < deg g = deg g∗ , which implies that q = q∗ .
Now we assume that r 6= 0 and k − deg q ≥ deg g − deg r. We have to show that
g ↾ (2(k − deg q)) = g∗ ↾ (2(k − deg q)),
r ↾ (2(k − deg q) − (deg g − deg r)) = r∗ ↾ (2(k − deg q) − (deg g∗ − deg r∗ )).
The first assertion follows from the coincidence up to 2k of ( f , g) and ( f ∗ , g∗ ).
Furthermore we have
deg(r − r∗ ) ≤ max{deg( f − f ∗ ), deg q + deg(g − g∗ )}
< deg q + deg f − 2k = deg g − 2(k − deg q) (5)
= deg r − (2(k − deg q) − (deg g − deg r)),
by (4) and (3), and by the above assumption
deg r ≥ deg q + deg g − k ≥ deg q + deg f − 2k > deg(r − r∗ ),
so that deg r = deg r∗ . Now the second assertion follows from the second inequality
in (5). ✷
Then
q = x + 1, r = 2x6 + x5 + 2x4 + 6x3 + 5x + 6,
q∗ = x + 1, r∗ = 2x6 + x5 + 3x4 .
We see that q = q∗ and r ↾ 1 = r∗ ↾ 1, and since g ↾ 2 = g∗ ↾ 2, we have that (g, r)
and (g∗ , r∗ ) coincide up to 2 = 2(k − deg q). Now r∗ /x4 = ( f ↾ 4) rem (g ↾ 3), and
we find that also (g, r) and (g ↾ 3, ( f ↾ 4) rem (g ↾ 3)) coincide up to 2(k − deg q),
as stated in the lemma. ✸
Lemma 11.1 gives only sufficient conditions for the quotients to be equal. Often
less information is necessary; in the above example, the constant coefficient of f ∗
may be altered without changing the quotient.
Next we consider the Euclidean Algorithm for two pairs r0 , r1 and r0∗ , r1∗ of poly-
nomials with deg r0 > deg r1 and deg r0∗ > deg r1∗ :
of length ℓ and ℓ∗ , respectively, and let mi = deg qi for 1 ≤ i ≤ ℓ and m∗i = deg q∗i
for 1 ≤ i ≤ ℓ∗ . As usual, we let ni = deg ri = n0 − m1 − · · · − mi for 0 ≤ i ≤ ℓ and
nℓ+1 = −∞, and we define n∗i accordingly, for 0 ≤ i ≤ ℓ∗ + 1.
Moreover, we define for any k ∈ N the number η (k) ∈ N by
so that
n0 − nη(k) = ∑ mi ≤ k < ∑ mi = n0 − nη(k)+1 , (6)
1≤i≤η (k) 1≤i≤η (k)+1
where the second inequality only holds if η (k) < ℓ, and η (k) is uniquely determined
by (6). In other words, the number n0 − k is sandwiched between the two con-
secutive remainder degrees deg rη(k) and deg rη(k)+1 in the Euclidean Algorithm.
In particular, η (k) ≤ k since mi ≥ 1 for 1 ≤ i ≤ ℓ. We define η ∗ (k) analogously.
The following lemma says, in a precise way, that the first results in the Euclidean
Algorithm only depend on the top part of the inputs.
L EMMA 11.3. Let k ∈ N, h = η (k), and h∗ = η ∗ (k). If (r0 , r1 ) and (r0∗ , r1∗ ) coincide
up to 2k, then h = h∗ and qi = q∗i for 1 ≤ i ≤ h.
11.1. A fast Euclidean Algorithm for polynomials 317
rd−1 r0
4. ←− R
rd r1
0 1
5. qd ←− rd−1 quo rd , rd+1 ←− rd−1 rem rd , Qd ←−
1 −qd
6. d ∗ ←− ⌊k/2⌋
8. return SQd R
2. d = ⌈5/2⌉ = 3.
r2 r0 2x6 + x5 + 2x4 + 6x3 + 5x + 6
4. =R = .
r3 r1 3x5 + 6x4 + x3 + 5x2 + 5x + 3
6. d ∗ ←− 2.
8. The matrix
1 5x + 4 0 1 1 6x + 6
SQ3 R =
3x x2 + 5x + 1 1 4x + 1 3x 4x2 + 4x + 1
4x3 + 6x + 4 3x3 + 3x3 + 4x + 1 s5 t5
= =
5x4 + 2x2 + x + 1 2x5 + 2x4 + 2x3 + 4x2 + 3x s6 t6
is returned. ✸
T HEOREM 11.5.
In the case of a normal degree sequence, Algorithm 11.4 works correctly. If k ≥
n/2, it uses no more than (12M(k) + O(k)) log k additions and multiplications plus
k inversions, in total O(M(k) log k) operations in F .
P ROOF. Since the empty product is defined to be the multiplicative neutral ele-
ment, in this case the identity matrix, the statements of the theorem are satisfied if
k = 0. Otherwise, we have n > 0, and we see by induction on k and Lemma 11.3
that the results of the recursive call in step 3 are correct. Since the degree sequence
is normal, we have deg rd = n − d ≥ 0 and therefore rd 6= 0 in step 5. Again by
induction and Lemma 11.3, the results of the recursive call in step 7 are correct,
and hence also the final result in step 8.
We may arrange things in such a way that the only inversions in F take place in
step 5, and that lc(r j )−1 is computed only once. During the recursive process, step
5 is executed k times.
Let T (k) denote the number of additions and multiplications that the algorithm
uses on input k. Since d − 1 = ⌈k/2⌉ − 1 ≤ ⌊k/2⌋, assuming monotonicity of T ,
steps 3 and 7 take at most T (⌊k/2⌋) operations each for solving a subproblem
of the same kind. We now analyze the cost for the polynomial multiplications,
divisions, and additions in steps 4, 5 and 8. We note that, by our assumption,
ni = deg ri = n − i for 0 ≤ i ≤ n.
In step 4, the entries of R are sd−1 ,td−1 , sd ,td , by Lemma 3.8 (ii), and their
degrees are n1 − nd−2 , n0 − nd−2 , n1 − nd−1 , n0 − nd−1 , by Lemma 3.10. All four
degrees are at most d − 1 < k/2. We have four multiplications of polynomials of
degree at most k/2 by polynomials of degree at most n ≤ 2k, plus some additions.
Dividing the larger polynomials into blocks of degree at most k/2 (Exercise 8.35),
the cost for step 4 is 16M(k/2) + O(k), or 8M(k) + O(k), by the superlinearity
properties (9) in Section 8.3.
Since nd−1 = nd + 1, the cost for step 5 is O(k). In step 8, we first compute Qd R,
or equivalently, sd+1 = sd−1 − qd sd and td+1 = td−1 − qd td . Since deg qd = 1, this
takes another O(k) operations.
320 11. Fast Euclidean Algorithm
The degrees of sd+1 and td+1 , in the bottom row of Qd R, are at most n0 − nd =
⌈k/2⌉. The entries of S have degrees nd+1 − nk−1 , nd − nk−1 , nd+1 − nk , nd − nk ,
all at most d ∗ ≤ k/2. Thus the computation of S · Qd R takes at most another
8M(k/2) + O(k), or 4M(k) + O(k) operations.
Putting things together, we have a cost of at most 12M(k) + O(k). Thus T satis-
fies the recursive inequalities
for some constant c ∈ R, and hence T (k) is at most (12M(k) + O(k)) log k, by
Lemma 8.2. ✷
◦ Some optimization is possible in step 4. First, since the remainders are going to
be truncated anyway in step 7, it is sufficient to compute only the top 2(d ∗ + 2)
coefficients of rd−1 and rd , which we obtain by applying R to the vector with
the truncated entries r0 ↾ 2k and r1 ↾ 2k − 1. This will also allow us to drop the
restriction k ≥ n/2 for the cost estimate in Theorem 11.5.
In addition, we can make use of the fact that the top d − 1 coefficients in the
matrix-vector product vanish, and truncate at the top as well. This reduces
the cost for step 4 to 6M(k) + O(k) and the constant in Theorem 11.5 from 12
to 10.
◦ Using the strategy discussed in the paragraph before Algorithm 11.4, the im-
proved algorithm also works when the degree sequence is not normal. Instead
of returning Rk , the algorithm returns h = η (k), as defined in (6), and Rh . In par-
ticular, the restriction deg r0 > deg r1 can be relaxed to deg r0 ≥ deg r1 .
◦ In addition to the matrix Rh , the improved algorithm also returns the quotients
q1 , . . . , qh .
2 2
4. j ←− 3, δ ←−
2, r0 ↾ 10= xr0 , r18 ↾ 9 7= x r16,
r̃2 r0 ↾ 10 2x + x + 2x + 6x5 + 6x4 + 5x3 + 6x2
=R = ,
r̃3 r1 ↾ 9 3x7 + 6x6 + 5x5 + 6x4 + 5x3 + 3x2
ñ2 ←− 8, and ñ3 ←− 7.
7. d ∗ ←− 2.
∑ mi = 3 ≤ 5 < 6 = ∑ mi . ✸
1≤i≤3 1≤i≤4
T HEOREM 11.7.
Algorithm 11.6 works correctly and uses no more than (22M(k) + O(k)) log k ad-
ditions and multiplications plus k + 1 inversions, in total O(M(k) log k) opera-
tions in F . The bound on the number of additions and multiplications drops to
(10M(k) + O(k)) log k if the degree sequence is normal.
P ROOF. Let ℓ be the number of division steps in the Euclidean Algorithm for
(r0 , r1 ), ni = deg ri for 0 ≤ i ≤ ℓ, and mi = deg qi for 1 ≤ i ≤ ℓ as usual. If r1 = 0 or
k < n0 − n1 , then η (k) = 0, and the algorithm correctly returns the identity matrix
in step 1 (note that the empty product is defined to be the multiplicative neutral
element). If k = 0 = n0 − n1 , then the first quotient is q1 = lc(r0 )/ lc(r1 ), and the
correct result is returned as well. Otherwise, k ≥ 1, and we see by induction on
k and Lemma 11.3 that the results of the recursive call in step 3 are correct. In
particular, δ = m1 + · · · + m j−1 ≤ d − 1 < k by (6) and the definition of d.
In step 4, we have that (r j−1 , r j ) and (r̃ j−1 , r˜j ) coincide up to 2(k − δ ), unless
r̃ j = 0 or k − δ < ñ j−1 − ñ j , by arguments similar to the ones used in the proof of
Lemma 11.1. In particular, n0 − n j−1 = 2k − ñ j−1 and ñ j−1 − n˜j = m j = n j−1 − n j
11.1. A fast Euclidean Algorithm for polynomials 323
n0 − nh = (n0 − n j ) + (n j − nh ) ≤ (n0 − n j ) + d ∗
< (n0 − n j ) + (n j − nh+1 ) = n0 − nh+1
or else h = ℓ. But this implies h = η (n0 − n j + d ∗ ) = η (k) by (6) and the definition
of d ∗ , and hence the final results in step 9 are correct.
As in the proof of Theorem 11.5, we may arrange things in such a way that the
number of inversions in F performed during the recursive process is at most k + 1.
Let T (k) denote the number of additions and multiplications that the algorithm
uses on input k. Steps 3 and 8 take T (d − 1) and T (d ∗ ) operations, respectively, for
solving a subproblem of the same kind, together at most 2T (⌊k/2⌋) since d − 1 ≤
⌊k/2⌋ and d ∗ = k − (n0 − n j ) < k − (d − 1) = ⌊k/2⌋ + 1, by (6). We now analyze
the cost for the polynomial multiplications, divisions, and additions in steps 1, 4,
6 and 9. The cost for step 1 is O(1).
In step 4, the entries of R are s j−1 ,t j−1 , s j ,t j , by Lemma 3.8 (ii), and their degrees
are n1 − n j−2 , n0 − n j−2 , n1 − n j−1 , n0 − n j−1 , by Lemma 3.10. All four degrees are
at most n0 − n j−1 = δ ≤ d − 1 < k/2. We have four multiplications of polynomials
of degree at most k/2 by polynomials of degree at most 2k, plus some additions,
taking 8M(k) + O(k) operations in F, as in the proof of Theorem 11.5. (As noted
earlier, in the normal case, the bound drops to 6M(k) + O(k).)
In step 6, computing the quotient of degree m j = ñ j−1 − ñ j ≤ k of the division of
r̃ j−1 by r̃ j , of degree ñ j = 2k − (n0 − n j ) = k + d ∗ , takes 4M(k) + O(k) operations,
by Theorem 9.6. By partitioning the divisor r̃ j into two blocks of sizes at most
k/2, as in Exercise 8.35, the remainder can be computed using at most another
2M(k) + O(k) operations, together no more than 6M(k) + O(k).
In step 9, we first compute Q j R, or equivalently, s j+1 = s j−1 − q j s j and t j+1 =
t j−1 − q j t j . This amounts to two multiplications of the quotient q j of degree
n j−1 − n j ≤ k by a polynomial of degree at most n0 − n j−1 < k/2 plus some ad-
ditions, taking at most 2M(k) + O(k).
The degrees of s j+1 and t j+1 , the lower row of Q j R, are at most n0 − n j ≤ k. The
entries of S have degrees n j+1 − nh−1 , n j − nh−1 , n j+1 − nh , n j − nh , respectively,
324 11. Fast Euclidean Algorithm
for some constant c ∈ R, and hence T (k) is at most (22M(k) + O(k)) log k, by
Lemma 8.2. In the normal case, the bound drops to (10M(k) + O(k)) log k. ✷
We have not attempted to determine the smallest possible constant in the place
of 22. In fact, it is possible to prove a slightly better bound on the arithmetic cost
for the “non-normal” case where not all the quotients have small degree. Strassen
(1983) showed that in the nonscalar model of computation, where additions and
multiplications by scalars are not counted and an interpolation algorithm proves
(over an infinite field) that M(n) ∈ O(n), the cost for Algorithm 11.6 when k = n
can be bounded by O(n · H(m1 /m, . . . , mℓ /m)), where m = ∑1≤i≤ℓ mi and H is the
entropy function, as in Section 10.1. This coincides with the bound of Theorem
11.7 in the normal case, since then mi /m = 1/n for 1 ≤ i ≤ ℓ = n.
Strassen also showed that the computation of all quotients of the Euclidean Al-
gorithm in the nonscalar model requires at least about n · H(m1 /m, . . . , mℓ /m) field
operations for almost all pairs of polynomials with quotient degrees m1 , . . . , mℓ .
This lower bound shows that Algorithm 11.6 is uniformly optimal in the nonscalar
model.
The qi as calculated in step 5 of Algorithm 11.6 are exactly the quotients in the
Euclidean Algorithm. Thus, taking M(n) ∈ O(n log n loglog n), Theorem 11.7 for
k = n implies that all the quotients qi in the Euclidean Algorithm can be computed
in time O∼ (n). Can we also compute all the remainders ri together in softly linear
time? The answer is: no. In the normal case, where always deg ri = n − i, the
number of coefficients of r0 , . . . , rℓ is
But this means that the output size is quadratic in the input size 2n, and hence any
algorithm that computes r0 , . . . , rℓ requires at least n2 /2 field operations, since in
some examples all output values are different (if the field is large enough), and
therefore each requires at least one operation.
Algorithm 11.6 computes the product Rη(k) of the Q-matrices in the Euclid-
ean Algorithm such that the sum of the degrees of the corresponding quotients is
roughly k. Given f , g ∈ F[x], it is easy to compute the gcd of f and g and the
11.1. A fast Euclidean Algorithm for polynomials 325
Bézout coefficients s,t from this matrix, by letting k = n. Then η (k) = ℓ, sℓ and tℓ
constitute the first row of the matrix Rℓ , and
rℓ = sℓ f + tℓ g.
1. call Algorithm
11.6 withinput f , g, and k, to compute h = η (k), q1 , . . . , qh ,
sh th
and Rh =
sh+1 rh+1
2. return q1 , . . . , qh , sh ,th , and sh f + th g
By Theorem 11.7, the cost for computing only the quotients and sh ,th in this
algorithm is O(M(k) log k) additions and multiplications in F plus at most k + 1
inversions. The additional cost for computing rh is O(M(n)) additions and mul-
tiplications. Note that it is easy to compute the corresponding row in the monic
Extended Euclidean Algorithm by multiplying rh , sh ,th by lc(rh )−1 , at a cost of
another O(n) field operations.
C OROLLARY 11.9.
For polynomials f , g ∈ F[x] of degree at most n, all of the following can be com-
puted with O(M(n) log n) additions and multiplications plus at most n + 2 inver-
sions, or O∼ (n) operations in F :
◦ rℓ = gcd( f , g),
◦ the Bézout coefficients s,t ∈ F[x] with s f + tg = rℓ ,
326 11. Fast Euclidean Algorithm
◦ the entries rh , sh ,th ∈ F[x] of an arbitrary row in the (traditional or monic) Ex-
tended Euclidean Algorithm for f , g,
◦ the quotients q1 , . . . , qℓ in the traditional Euclidean Algorithm for f , g.
We give explicit constants for the first two statements of the above corollary.
T HEOREM 11.10.
Let f , g ∈ F[x] \ {0} with deg g ≤ deg f ≤ n.
(i) With at most (22M(n) + O(n)) log n additions and multiplications plus n + 2
inversions in F , we can decide whether f and g are coprime, and if so,
compute the Bézout coefficients s,t ∈ F[x] such that s f + tg = 1.
(ii) If the degree sequence is normal, then we can compute the monic gcd( f , g)
and the Bézout coefficients s,t ∈ F[x] such that s f + tg = gcd( f , g) using at
most 10M(n) log n + 2M(n) + O(n log n) additions and multiplications plus
n + 2 inversions.
P ROOF. (i) We see from Lemma 3.10 that the gcd is constant if and only if
deg sℓ+1 = deg g and degtℓ+1 = deg f . If so, then we return s = sℓ /rℓ and t = tℓ /rℓ .
The cost for computing the constant polynomial rℓ = sℓ (0) f (0) + tℓ (0)g(0) and
dividing sℓ ,tℓ by it is one inversion and O(n) multiplications and additions, and the
claim follows from Theorem 11.7 with k = n.
(ii) The degrees of sℓ and tℓ are less than n, by Lemma 3.10, and hence computing
rℓ = sℓ r0 + tℓ r1 amounts to 2M(n) + O(n) arithmetic operations. ✷
C OROLLARY 11.11.
Let f ∈ F[x] of degree n > 0. A product in the residue class ring F[x]/h f i can
be computed with 6M(n) + O(n) arithmetic operations in F , and an inverse with
no more than (22M(n) + O(n)) log n operations. Thus one arithmetic operation in
F[x]/h f i takes O∼ (n) arithmetic operations in F .
Applying Corollaries 10.12, 10.17, 11.9, and 11.11 to the analysis of the modu-
lar Extended Euclidean Algorithms 6.36 and 6.59, we obtain the following result.
C OROLLARY 11.12.
Let F be a field with at least (6n + 3)d elements and f , g ∈ F[y][x] of degree at
most n in x and at most d in y.
(i) With an expected number of O(d M(n) log n + n M(d) log d) or O∼ (nd) arith-
metic operations in F , we can compute the gcd of f and g.
(ii) A single row of the EEA for f , g can be computed with O(n M(nd) log(nd))
or O∼ (n2 d) operations in F .
11.2. Subresultants via Euclid’s algorithm 327
The Euclidean Algorithm for integers. The method also works for integers,
although there are some complications due to the carries. But Corollary 11.9 is
true also for integers when the cost measure is the number of word operations
instead of field operations. Wang & Pan (2003) describe a suitable algorithm; see
also Pan & Wang (2004). The output row i is specified by an integer h and the
condition si ≤ 2h < si+1 . For inputs of at most n words, it uses O(M(n) log h) word
operations.
C OROLLARY 11.13.
For an integer m ∈ N of length n, one arithmetic operation in the residue class
ring Zm can be performed using O∼ (n) word operations. More precisely, the cost
is O(n) for an addition, O(M(n)) for a multiplication, and O(M(n) log n) for an
inversion or a division.
C OROLLARY 11.14.
Let f , g ∈ Z[x] of degree at most n and with max-norm at most A.
word operations.
fn gm
0
fn−1 gm−1 gm ..
.. .. .. .
. . . ..
.. qn−m
.. .. .
. . gm ..
− .. . = .
.. .. . (8)
. g0 .
.. . 0
.. ..
. . . q0 rd
.. . . .. ..
. . . .
f0 g0 r0
| {z }
n−m+1
and the second summand on the left hand side of (8), extended by zeroes or
truncated—as necessary—to length n + m − 2κ, is a linear combination of the
columns in the right part of Sκ ( f , g). Thus the column
(0, . . . , 0, rd , . . . , r2κ−m+1 )T ,
σκ ( f , g) = det Sκ ( f , g)
gm
..
gm−1 . rd
.. ..
..
. gm . .
= (−1) (n−κ)(m−κ)
det .. .. .. .
. . . rd
.. .. .. ..
. . . .
g2κ−n+1 · · · gκ r2κ−m+1 · · · rκ
| {z } | {z }
n−κ m−κ
We recall the degree sequence (n0 , . . . , nℓ ), with ni = deg ri for all i. Using the
above lemma repeatedly, we arrive at the following celebrated theorem.
σm = α1n−m , σni+1 = (−1)(ni −ni+1 )(n−ni+1 +i+1) (αi αi+1 )ni −ni+1 σni .
P ROOF. (i) We know from Theorem 6.48 that σκ vanishes in the second case. So
we may assume that κ = ni for some i ≤ ℓ. This i is unique, so that the expressions
in the claim are well defined.
Induction on h for 0 ≤ h < i, using Lemma 11.15, shows that
n −n j+1
σκ (r0 , r1 ) = σκ (rh , rh+1 ) ∏ (−1)(n j−1 −κ)(n j −κ) α j j−1 .
1≤ j≤h
The claim follows from the case κ = ni and h = i − 1, together with σni (ri−1 , ri ) =
n −n
αi i−1 i .
(ii) follows from (i) by calculating τi+1 − τi modulo 2. ✷
Exercise 11.10 shows that (−1)τi = 1 when the degree sequence is normal.
We illustrate the theorem with an example.
σ2 = σn1 = det(3) = 3 = α1 ,
1 3 0
σ1 = σn2 = det 2 2 3 = 16 = (−1)τ2 α2 α12 ,
3 1 2
1 0 3 0 0
2 1 2 3 0
σ0 = σn3 = det 3 2 1 2 3 = 256 = (−1)τ3 α3 α22 α12 . ✸
4 3 0 1 2
0 4 0 0 1
11.2. Subresultants via Euclid’s algorithm 331
C OROLLARY 11.18.
Let f , g ∈ F[x] \ {0} have degrees n = n0 ≥ n1 , and let 0 ≤ k ≤ n. Then all
subresultants σ j for n1 ≥ j ≥ (n − k) of ( f , g) can be calculated with at most
(22M(k) + O(k)) log k operations in F .
P ROOF. We use Algorithm 11.8 with input f , g and k to compute the quotients
q1 , . . . , qh , where h = η (k). By Theorem 6.53 (b), we can compute the αi =
αi−1 / lc(qi ) from α0 and the leading coefficients of the quotients qi using at most
k multiplications and inversions each. Then we compute the subresultants up to
σn−k along the recursion formula (ii) from Theorem 11.16. This takes at most 2k
additional multiplications, and Theorem 11.7 implies the claim. ✷
Because of its importance, we highlight the case of the resultant, which corre-
sponds to κ = 0 in Theorem 11.16 and to k = n in Corollary 11.18.
C OROLLARY 11.19.
Let f , g ∈ F[x] \ {0}, and let n = n0 ≥ n1 ≥ · · · ≥ nℓ and α0 , . . . , αℓ be the degrees
and the leading coefficients, respectively, of the remainders in the Euclidean Al-
gorithm for ( f , g).
If deg gcd( f , g) = nℓ ≥ 1, then res( f , g) = 0. Otherwise, if nℓ = 0,
n n −n j+1
res( f , g) = (−1)τ αℓ ℓ−1 ∏ α j j−1 ,
1≤ j<ℓ
where τ = ∑1≤ j<ℓ n j−1 n j . This resultant can be calculated using no more than
(22M(n) + O(n)) log n operations in F .
Corollary 11.18 implies that in fact all subresultants can be computed within
the same time bound. This can be used to replace the rational number reconstruc-
tion (or Cauchy interpolation) in the modular EEA algorithms of Section 6.11, as
follows. We multiply the modular images of the ith row ri , si ,ti of the EEA with
the modular image of the subresultant σni , for all “lucky” primes, and reconstruct
σni ri , σni si , σni ti , which have integral (or polynomial) coefficients, by the fast Chi-
nese Remainder Algorithm (or fast interpolation), for all i.
C OROLLARY 11.20.
We can compute all subresultants of two polynomials f , g ∈ Z[x] of degree at most
n and with max-norm at most A using O(M(n) log n · M(n log(nA)) log(n log(nA)))
or O∼ (n2 log A) word operations.
332 11. Fast Euclidean Algorithm
P ROOF. We modify the small primes modular EEA of Section 6.11 so that in ad-
dition it computes all subresultants modulo each small prime, using the leading
coefficients of the quotients from the fast Euclidean Algorithm, as in the proof of
Corollary 11.18, and recover them from their modular images by Chinese remain-
dering. By Corollary 11.18, the additional cost is negligible, and Corollary 11.14
implies the claim. ✷
C OROLLARY 11.21.
We can compute all subresultants of two polynomials f , g ∈ F[y][x] of degree at
most n in x and at most d in y, where F is a field, using O(n M(nd) log(nd)) or
O∼ (n2 d) arithmetic operations in F .
Notes. 11.1. The idea for a fast gcd algorithm is due to Lehmer (1938); later work in-
cludes Knuth (1970), Schönhage (1971), Moenck (1973), Aho, Hopcroft & Ullman (1974),
§8.9, Schwartz (1980), Brent, Gustavson & Yun (1980), and Strassen (1983); the first three
papers actually deal with integers. Brent, Gustavson & Yun apply their algorithm to com-
puting Padé approximants and solving Toeplitz (or Hankel) systems of linear equations,
and show that the two problems are equivalent. They also note that the “HGCD” algorithm
from Aho, Hopcroft & Ullman does not always return the correct result in non-normal
cases where not all quotients have degree 1. The Fast Extended Euclidean Algorithm 11.4
in the 1999 and 2003 editions of this text also contained an error. The concept of and
notation for “coinciding” is from Strassen’s paper. Pan (1997) gives a (sometimes) faster
computation for Padé approximants and the decoding of BCH codes.
11.2. Lemma 11.15 for the resultant is in Gordan (1885), §145, Haskell (1891/92), and
“well-known” to Swan (1962). The last paper also contains implicitly Theorem 11.16.
In the traditional, and in Sturm’s, variant of the Euclidean Algorithm (Exercise 4.32), the
(sub)resultants of consecutive entries are all identical, up to sign. The fundamental theorem
on subresultants is in Collins (1967) and Brown & Traub (1971); for our development, it
takes a back seat compared to the results of Chapter 6. Exercise 11.8 provides a simple
proof of the special case κ = 0 of Lemma 11.15.
Lickteig & Roy (1996, 2001) and Reischert (1997) give non-modular methods for com-
puting resultants of polynomials in Z[x] or F[y, x] and prove running time estimates which
are—up to logarithmic factors—within the bounds from Corollaries 11.20 and 11.21.
Exercises.
11.1 Prove that for a ring R and each k ∈ N, “coinciding up to k” is an equivalence relation on
R[x] \ {0} × R.
Exercises 333
11.2 Let F be a field supporting the FFT. In the text, we have given fast O(n logn) and O(n log2 n)
algorithms, respectively, for the following six problems for polynomials in one variable of degree
less than n over F: multiplication, division with remainder, inverse modulo xn , evaluation at n points,
interpolation at n points, and greatest common divisor. For each of these problems, describe in one
sentence of at most 20 words how the algorithm for it depends on the FFT and the algorithms for the
other problems, and what method is used for the “dependency”.
11.3 Let F be a field, k ∈ N, and f , g, f ∗ , g∗ ∈ F[x] nonzero. Prove or disprove the following
“converse” of Lemma 11.1: If g ↾ k = g∗ ↾ k and f quo g = f ∗ quo g∗ has degree k, then f ↾ 2k =
f ∗ ↾ 2k.
11.4 Let F be a field, f ∈ F[x] of degree n, and m1 , . . ., mr ∈ F[x] such that ∑1≤i≤r deg mi ≤ n.
Prove that gcd( f , m1 ), . . ., gcd( f , mr ) can be computed with O(M(n) log n) operations in F. Hint:
Corollary 10.17.
11.6 In this exercise, you are to show how the Half gcd algorithm 11.6 can be sped up if FFT
multiplication is used. Suppose that F is a field that supports the FFT. We know that the entries
of SQ j R in step 9 are of degree at most n0 − nh ≤ k, and it is sufficient to compute all of them
modulo xκ − 1, where κ ∈ N is the least power of 2 strictly larger than k. Then the product matrix
can be computed by evaluating all entries of S, Q j , R at the primitive κth roots of unity, performing
the matrix products pointwise, and interpolating to obtain the result. Count the number of κ-point
FFTs computed, and compare your result to the number of κ-point FFTs that the usual approach of
separately computing all polynomial products takes.
11.7∗ You are to modify
Algorithm
11.4
(Half gcd for normal degree sequence) so that in addition
rk
the two remainders rk+1 = Rk rr01 are output. You may assume that n0 ≤ 2k. Analyze your
algorithm carefully. The goal is to obtain a cost of at most(10M(k) + O(k)) log k field operations.
r0∗
Hint: In your modified step 4, you only have to compute R r∗ , where r0∗ , r1∗ are the “lower parts”
1
of r0 , r1 , in order to obtain rd−1 and rd , and a similar computation in step 8 gives rk , rk+1 . Trace
your algorithm on the data of Example 11.2. Can you explain why this algorithm outputs more than
Algorithm 11.4 and still uses fewer operations?
11.8 Give an alternative proof of Lemma 11.15 for k = 0 using Exercise 6.12.
11.9 Let F be a field and n, e1 , . . ., ed ∈ N, with e1 > · · · > ed and e1 + · · · + ed ≤ n.
(i) Let f , g ∈ F[x] of degree at most n, and assume that e1 , . . ., ed occur in the degree sequence
of the EEA for f and g. Show that the remainders of degrees e1 , . . ., ed can be computed with
O(M(n) log n) operations in F.
(ii) Let f , g ∈ F[y][x] of degree at most n in x and at most d in y, and assume that #F ≥ (6n+3)d and
e1 , . . ., ed occur in the degree sequence of the EEA for f and g in F(y)[x]. Show that the remainders
of degrees e1 , . . ., ed in x can be computed with O(n M(nd) log(nd)) operations in F.
11.10 Prove that (−1)τi = 1 for all i in Theorem 11.16 in case the degree sequence is normal.
Research problems.
11.11 Determine the smallest possible constant c ≤ 22 such that your favorite fast Euclidean Algo-
rithm works in time (c M(k) + O(k)) logk.
11.12 Can you find an algorithm for computing the resultant of two polynomials f , g ∈ F[x, y] of
degree at most n in x and at most d in y taking O∼ (nd) operations in the field F?
11.13 Implement carefully fast algorithms for large instances of the problems discussed in this
book.
Obweizvestno, qto zadaqa obraweni matric [. . . ]
vlets odno
i iz centralьnyh i trudnyh zadaq teorii
matric. [. . . ] K soжaleni, nesmotr
na obxirnu literaturu, posvwennu зtomu voprosu,
problema vo mnogih eë aspektah trebuet
ixego uglublënnogo issledovani.1
dalьne
Iosif Semenovich Iohvidov (1974)
1 It is commonly known that the problem of the inversion of matrices [. . . ] is one of the central and difficult
problems in matrix theory. [. . . ] Unfortunately, in spite of extensive literature dealing with this question, the
problem requires in many of its aspects a further and profound investigation.
2 When it is not in our power to tell the most correct opinions apart, we ought to follow the most probable ones.
12
Fast linear algebra
The “classical” algorithms for problems in linear algebra, such as matrix multipli-
cation, computing the determinant, or solving systems of linear equations, all take
O(n3 ) arithmetic operations for inputs of size n × n. In this chapter, we discuss
two totally different approaches to improving this. The first is a general method
whose most powerful variant leads to O(n2.3727 ) operations, but whose practical
use may be limited. The second one uses a radically different model of linear
algebra: instead of writing down the matrix (“explicit linear algebra”), we only
use a (fast) mechanism for evaluating the matrix at a vector (“black box linear al-
gebra”). This is only applicable with profit to restricted classes of matrices, but
many problems arising in practice fall into this category: Sylvester, Vandermonde,
and Toeplitz matrices, the Berlekamp matrix in Berlekamp’s polynomial factor-
ization algorithm 14.31, and large sparse matrices over F2 in integer factorization
algorithms (Algorithm 19.12).
335
336 12. Fast linear algebra
P1 = A11 B11 , P5 = S1 T1 ,
P2 = A12 B21 , P6 = S2 T2 ,
P3 = S4 B22 , P7 = S3 T3 .
P4 = A22 T4 ,
5. U1 ←− P1 + P2 , U5 ←− U4 + P3
U2 ←− P1 + P6 , U6 ←− U3 − P4
U3 ←− U2 + P7 , U7 ←− U3 + P5
U4 ←− U2 + P5
U1 U5
6. return
U6 U7
T HEOREM 12.2.
Algorithm 12.1 correctly computes the product matrix and uses at most 6nlog2 7
additions and multiplications in R. For arbitrary n ∈ N, an n × n matrix product
can be computed with 42nlog2 7 ∈ O(nlog2 7 ) ring operations.
P ROOF. The correctness is left as Exercise 12.1. For n = 2k ∈ N, let T (n) denote
the number of arithmetic operations in R that the algorithm performs on inputs
of size n × n. Then T (1) = 1 and T (2k ) = 15 · 22k−2 + 7T (2k−1 ) for k ≥ 1, and
Lemma 8.2 implies the first claim. For arbitrary n, we pad the matrices with zeroes,
thereby at most doubling the dimension. ✷
12.1. Strassen’s matrix multiplication 337
Strassen’s (1969) discovery was the starting signal for the development of fast
algorithms. Although subquadratic integer multiplication algorithms had been
around for a while (Section 8.1), it was the surprise of realizing that the “obvi-
ous” cubic algorithm for matrix multiplication could be improved that kicked this
development into high gear and inspired, within the following five years, the many
new ideas for almost all the fast algorithms discussed in Part II of this book.
On a more technical level, Strassen’s result spawned three lines of research:
◦ faster matrix multiplication,
◦ other problems from linear algebra,
◦ bilinear complexity.
For a field F, a number ω ∈ R is a feasible matrix multiplication exponent
if two n × n matrices over F can be multiplied with O(nω ) operations in F. The
classical algorithm shows that ω = 3 is feasible, and Strassen’s that ω = log2 7 is.
The matrix multiplication exponent µ (for F) is the infimum of all feasible ones.
Thus
2≤µ≤ω
for all feasible ω ’s. This µ is the same for all fields of a fixed characteristic, and
all feasible exponents discovered so far work for all fields.
The fascinating history of the smallest exponents known is in the Notes 12.1;
the current world record is ω < 2.3727. It seems natural to conjecture that µ = 2;
there is currently no method in sight that might prove or disprove this.
How practical are these algorithms? Bailey, Lee & Simon (1990) deplore “an
unfortunate myth [. . . ] regarding the crossover point for Strassen’s algorithm”, and
show that for the Sun–4 “Strassen is faster for matrices as small as 16 × 16. For
Cray systems the crossover point is roughly 128”. They conclude that “it appears
that Strassen’s algorithm can indeed be used to accelerate practical-sized linear
algebra calculations.” Besides a Cray library implementation (SGEMMS) of fast
matrix multiplication, there is also one, the ESSL library, for IBM 3090 machines.
Higham (1990) reports on a set of FORTRAN 77 routines (level 3 BLAS) using
“Strassen’s method for fast matrix multiplication, which is now recognized to be
a practically useful technique once matrix dimensions exceed about 100”. In all
these experiments, the coefficients are floating point numbers of a fixed precision.
A further avenue to explore with Strassen’s algorithm is that its recursive parti-
tion employs data access that is essentially different from classical multiplication.
This may make it attractive for machines with a hierarchical memory structure and
for large matrices stored in secondary memory, possibly reducing data transfer
(paging) time.
Further computational problems in linear algebra include matrix inversion, com-
puting the determinant, the characteristic polynomial, or the LR-decomposition of
a matrix, and, for F = C, the QR-decomposition and unitary transformation to
338 12. Fast linear algebra
upper Hessenberg form. It turns out that all these problems have the same asym-
ptotic complexity as matrix multiplication (up to constant factors), so that a fast
algorithm for one of them immediately gives fast algorithms for all of them.
The exponent η for solving systems of linear equations satisfies η ≤ ω for all
feasible ω . It is not known whether η = µ.
The most fundamental consequence of Strassen’s breakthrough was the devel-
opment of bilinear complexity theory , a deep and rich area that is concerned with
good and optimal algorithms for functions that depend linearly on each of two
sets of variables, just like the entries of the product of two matrices (or polyno-
mials) do. Bürgisser, Clausen & Shokrollahi (1997) give a detailed account of the
achievements in this theory, which is part of algebraic complexity theory .
1. m ←− ⌈n1/2 ⌉
let g = ∑0≤i<m gi xmi , with g0 , . . . , gm−1 ∈ R[x] of degree less than m
3. let A ∈ Rm×n be the matrix whose rows are the coefficients of 1, h rem f ,
h2 rem f , . . ., hm−1 rem f , and B ∈ Rm×m the matrix whose rows are the co-
efficients of g0 , g1 , . . . , gm−1 , and compute BA ∈ Rm×n via ⌈n/m⌉ ≤ m matrix
multiplications of size m × m
4. for i = 0, . . . , m − 1 do
let ri ∈ R[x] be the polynomial whose coefficients form the ith row
of BA, and compute b = ∑0≤i<m ri · (hm )i rem f using Horner’s rule
5. return b
12.2. Application: fast modular composition of polynomials 339
g0 1 r0
g1 h rem f r1
.. · .. = ..
. . .
gm−1 hm−1 rem f rm−1
| {z } | {z }
B A
F IGURE 12.1: The matrix product in the modular composition algorithm 12.3.
T HEOREM 12.4.
Algorithm 12.3 works correctly and uses at most ⌈n1/2 ⌉ matrix multiplications of
size ⌈n1/2 ⌉ × ⌈n1/2 ⌉, plus no more than 6n1/2 (M(n) + O(n)) additions and multi-
plications in R.
P ROOF. Let i < m, and gi = ∑0≤ j<m gi j x j with all gi j ∈ R. Then ri = ∑0≤ j<m gi j ·
(h j rem f ) = gi (h) rem f (see Figure 12.1), and
Taking M(n) ∈ O(n log n loglog n) and ω < 2.3727, we obtain the following.
C OROLLARY 12.5.
The modular composition g(h) rem f for three polynomials f , g, h ∈ R[x] with
deg g, deg h < deg f = n and f 6= 0 monic can be computed using O(n1.687 ) op-
erations in R.
Umans (2008) and Kedlaya & Umans (2009) present major progress, namely a
new algorithm for modular composition that uses only n1+o(1) · O∼ (log q) bit oper-
ations. This corresponds, up to small factors, to only O(n) operations in Fq . One
of the main innovations in their work is that they do not use algebra in Fq , but bit
operations. Namely, they reduce the problem to multipoint evaluation for multi-
variate polynomials. They solve this task in a modular fashion, by considering it
over the integers, solving it modulo various primes, and reconstructing the result
via Chinese remaindering.
340 12. Fast linear algebra
For matrices with “small” evaluation cost we also have “fast” matrix multipli-
cation, in that the product with an arbitrary (explicitly given) n × n matrix can
be calculated with n · c(A) arithmetic operations. The transposition principle (see
Notes 12.3) says that for the evaluation cost, it does not matter whether we mul-
tiply by a vector from the right or the left, or whether we consider a matrix or its
transpose.
12.3. Linearly recurrent sequences 341
Before we can present the algorithm, we need some facts about linearly recur-
rent sequences. Let F be a field and V 6= {0} a vector space over F. Then V N is the
(infinite-dimensional) vector space of infinite sequences (ai )i∈N , with all ai ∈ V .
for all i ∈ N. The polynomial f = ∑0≤ j≤n f j x j ∈ F[x] of degree n is called a char-
acteristic (or annihilating, or generating) polynomial of a.
...
∗ f0 ∗ f1 ∗ fn−2 ∗ fn−1
F IGURE 12.3: Initial state of a linear feedback shift register for the sequence a = (ai )i∈N
with characteristic polynomial f = xn − fn−1 xn−1 − fn−2 xn−2 − · · · − f1 x − f0 .
The constants f ∈ F act on sequences in the usual way, and the indeterminate x
acts as a shift operator:
x • a = (ai+1 )i∈N .
This makes V N , together with •, into an F[x]-module. A module is something
similar to a vector space, with the only difference that the “scalars” may be ele-
ments of an arbitrary (commutative) ring instead of a field. In particular, • has the
following properties:
f • (a + b) = f • a + f • b, (1)
f • 0 = 0, (2)
( f + g) • a = f • a + g • a, (3)
( f g) • a = f • (g • a) = g • ( f • a), (4)
0 • a = 0, (5)
1 • a = a, (6)
for all f , g ∈ F[x] and a, b ∈ V N , where 0 = (0)i∈N is the zero sequence. Their
proof is in Exercise 12.5. For example, every commutative group G is a Z-module
by letting f • a = a f for a ∈ G and f ∈ Z.
We can express the property of being a characteristic polynomial in terms of
the operation •: f ∈ F[x] \ {0} is a characteristic polynomial of a ∈ V N if and
only if f • a = 0. The set of all characteristic polynomials of a sequence a ∈ V N ,
12.3. Linearly recurrent sequences 343
together with the zero polynomial, is an ideal in F[x]: if f , g are both characteristic
polynomials or zero, then so is f + g, and if r ∈ F[x] is arbitrary, then r f is either
zero or a characteristic polynomial, by (2), (3), and (4). This ideal is called the
annihilator of a and denoted by Ann(a). Since any ideal in F[x] is generated by a
single polynomial (Section 25.3), either Ann(a) = {0} or there is a unique monic
polynomial m ∈ Ann(a) of least degree such that hmi = {rm: r ∈ F[x]} = Ann(a).
This polynomial is called the minimal polynomial of a and divides any other
characteristic polynomial of a. We denote it by ma . If a is not linearly recurrent,
then Ann(a) = {0}, and we set ma = 0. The degree of ma is called the recursion
order of a. Summarizing, we have the following equivalences for f ∈ F[x] and
a ∈ V N:
f = 0 or f is a characteristic polynomial of a ⇐⇒ f • a = 0
⇐⇒ f ∈ Ann(a) ⇐⇒ ma | f ,
a ∈ V is linearly recurrent ⇐⇒ ∃ f ∈ F[x] \ {0}
N
f •a = 0
⇐⇒ Ann(a) 6= {0} ⇐⇒ ma 6= 0.
E XAMPLE 12.7 (continued). (i) Any polynomial annihilates the zero sequence,
by (2). Thus Ann(0) = F[x] and m0 = 1.
2
(ii) The minimal polynomial of the Fibonacci sequence is m√ a = x −x−1. This is
because the polynomial is irreducible over Q (its roots (1 ± 5)/2 are irrational),
and hence no proper divisor of ma annihilates a (1 obviously does not).
(iii) The minimal polynomial of the matrix A is also the minimal polynomial of
the sequence (Ai )i∈N .
(iv) ma divides the minimal polynomial of A.
(v) ma divides the minimal polynomial of (Ai b)i∈N .
(vi) Ann(a) ⊆ Ann(ϕ(a)) and mϕ(a) | ma .
(vii) Let V be an algebraic field extension of F, α ∈ V , and a = (αi )i≥0 . Then a
is linearly recurrent, and the minimal polynomial of a is the minimal polynomial
of α over F. ✸
P ROOF. For the proof of (i), see Exercise 12.7. For (ii), we note that deg r ≤ d,
with equality if and only if x ∤ f , and hence d ≥ max{1 + deg g, deg r} in (i).
Now let f = ma , and suppose that d > max{1 + deg g, deg r}. Then x divides f ,
r = rev( f /x), and f /x is a characteristic polynomial of a of degree d − 1, by (i),
contradicting the minimality of ma . Thus d = max{1 + deg g, deg r}.
Let u = gcd(g, r). Then f ∗ = f / rev(u) is a polynomial of degree d − deg u,
r/u = rev( f ∗ ), and (r/u)h = (g/u) is a polynomial of degree less than d − deg u.
Hence f ∗ is a characteristic polynomial of a, again by (i), and the minimality of d
implies that deg u = 0. ✷
since Lemma 12.8 (ii) implies that (s,t) = (g, r) is a solution to (7) (note that x ∤ r,
by the definition of rev). We have seen in Section 5.9 that the solution to (7) is
unique (up to multiplication by constants) and can be computed with the Extended
Euclidean Algorithm, using O(n2 ) arithmetic operations in F. This leads to the
following algorithm.
1. h ←− a2n−1 x2n−1 + · · · + a1 x + a0
call the Extended Euclidean Algorithm to compute s,t ∈ F[x] such that
t(0) = 1 and (7) holds, as described in Section 5.9
T HEOREM 12.10.
Algorithm 12.9 correctly computes the minimal polynomial of a linearly recurrent
sequence (ai )i∈N of recursion order at most n and uses O(n2 ) operations in F .
Using the fast Euclidean Algorithm from Chapter 11, the minimal polynomial
can actually be computed with O(M(n) log n) field operations, but this does not
help in our intended application.
j q j−1 aj tj
6
0 x 0
1 x4 + x2 1
2 2 2
2 x −1 x −x + 1
3 x2 + 1 0 x4
m(A)b = ∑ m j A j b = 0 in F n . (8)
0≤ j≤d
A · (−m−1
0 ) ∑ m j A j−1 b = −m−1
0 ∑ m j A j b = b,
1≤ j≤d 1≤ j≤d
j−1
and y = −m−1 0 ∑1≤ j≤d m j A b ∈ F n is the required solution and can be computed
in a Horner-like fashion (Section 5.2), using d − 1 < n evaluations of A at a vector
plus O(n2 ) field operations for additions of vectors and multiplications by scalars.
We note that y belongs to the Krylov subspace of A and b.
This leads to the following algorithm.
1. if b = 0 then return 1
We have already seen in Example 12.11 that the minimal polynomial of this se-
quence is m = x2 + 2x + 2. In step 5 of Algorithm 12.13, we calculate
0
m(A)b = A2 b + 2Ab + 2b = 2 ,
3
348 12. Fast linear algebra
so that m is not the minimal polynomial of (Ai b)i∈N . We go back to step 3 and
choose u = (1, 2, 0)T this time. Then (uT Ai b)i∈N = (0, 1, 2, 2, 3, 2, . . .), and Algo-
rithm 12.9 yields the minimal polynomial m = x3 + 3x + 1. Since the minimal
polynomial of (Ai b)i∈N is a monic multiple of m of degree at most 3, it equals m.
We check this by calculating
0
3
m(A)b = A b + 3Ab + b = 0 .
0
and in fact Ay = b. ✸
T HEOREM 12.15.
An output returned by Algorithm 12.13 is correct. If it returns after k iterations,
the cost is at most 2n c(A) + O(kn2 ) operations in F .
It remains to prove that the condition in step 5 is true with reasonable probability,
so that we expect to get an output after a small number of iterations. Thus we have
to find a lower bound on the probability that for random u ∈ U n , the polynomial m
computed in step 4 of Algorithm 12.13 is the minimal polynomial of (Ai b)i∈N .
For a nonzero f ∈ F[x] of degree d, we consider the set M f ⊆ F N of all sequences
a ∈ F N that are annihilated by f . For example, Mxd −1 is the set of all periodic
sequences with period d. M f is an F[x]-submodule of F N , since a + b and g • a
are annihilated by f if a and b are and g ∈ F[x] is arbitrary, by (1), (2), and (4).
Since any sequence in M f is completely determined by its d initial values, M f is
12.4. Wiedemann’s algorithm and black box linear algebra 349
of the impulse response sequence c = (ci )i∈N for f , whose d initial values are
0, 0, . . . , 0, 1, and whose remaining values are determined by the recurrence relation
f • c = 0. Hence M f is the cyclic F[x]-module F[x] • c generated by c: if a =
∑0≤ j<d g j (x j • c) ∈ M f is arbitrary and g = ∑0≤ j<d g j x j ∈ F[x], then a = g • c.
A cyclic module M = R • c over a ring R is isomorphic to R/Ann(c). This
follows from the fact that λ: R −→ M with λ(g) = g • c is a surjective homomor-
phism of R-modules with kernel Ann(c), and by the homomorphism theorem for
R-modules, the map ϕ: R/Ann(c) −→ M given by ϕ(g mod Ann(c)) = g • c is an
isomorphism (see the latest edition of van der Waerden 1931, §86). This may be
familiar to the reader in the case of commutative groups, where R = Z, M is a finite
cyclic group of order n ∈ N, and the module operation is g • a = ag for g ∈ Z and
a ∈ M. Then, for any generator c of M, we have M = Z • c, Ann(c) = nZ, and in
fact ϕ: Z/nZ −→ M with ϕ(g mod n) = cg is an isomorphism of Z-modules.
In our situation, Ann(c) = h f i. This is because clearly f annihilates c, and
on the other hand no nonzero g ∈ F[x] of degree k < d satisfies g • c = 0, since
the (d − 1 − k)th coefficient of g • c is the leading coefficient of g. Thus M f and
F[x]/h f i are isomorphic as F[x]-modules, where the module operation on F[x]/h f i
is defined by g • (h mod f ) = (g mod f )(h mod f ) = gh mod f , and
is an isomorphism.
L EMMA 12.16. Let A ∈ F n×n , b ∈ F n \ {0}, and f ∈ F[x] be the minimal poly-
nomial of the sequence (Ai b)i∈N ∈ (F n )N . There is a surjective F –linear map
ψ : F n −→ F[x]/h f i such that for all u ∈ F n we have
both are annihilated by f . This shows that we can regard ψ ∗ as a surjective map
from F n onto M f . We now set ψ = ϕ−1 ◦ ψ ∗ , where ϕ: F[x]/h f i −→ M f is the
isomorphism (9) of cyclic F[x]-modules. Then ψ is surjective,
with h1 , . . . , hn ∈ F[x] of degree less than d and ψ (e j ) = h j mod f for all j. Let
y1 , . . . , yn be new indeterminates over F[x] and r = resx (y1 h1 + · · · + yn hn , f ) ∈
F[y1 , . . . , yn ]. Then the total degree of r is at most d, and by Lemma 6.25
Lemma 12.17 gives a good lower bound on the success probability of Algorithm
12.13 for fields of sufficiently large cardinality, say at least 2n.
T HEOREM 12.18.
The expected cost of Algorithms 12.12 and 12.13 is at most 2n c(A) + O(n2 ) field
operations if F has at least 2n elements.
12.4. Wiedemann’s algorithm and black box linear algebra 351
P ROOF. From Lemmas 12.16 and 12.17, we conclude that the expected number of
iterations of Algorithm 12.13 is at most 2 if we take any subset U ⊆ F of cardinality
at least 2n. We may assume that the vectors Ab, A2 b, . . . , A2n−1 b computed in step 3
of Algorithm 12.13 are stored, and then the cost for step 2 of Algorithm 12.12 is
only another O(n2 ) field operations for vector additions and scalar multiplications.
The claim now follows from Theorem 12.15. ✷
For “small” finite fields Fq , we might make a suitable field extension (Ex-
ercise 12.16), which would add a factor of O(M(logq n)) to the timings from
Theorem 12.18. Wiedemann (1986) shows that this factor can be replaced by 2
(Exercise 12.18), by computing the least common multiple of the minimal polyno-
mials of (uT Ai b)i∈N for several independently chosen uniformly random u ∈ F n .
Wiedemann (1986) also addresses the singular and nonsquare case. A different
variant in the singular case is from Kaltofen & Saunders (1991). They prove the
following theorem.
T HEOREM 12.19.
Let F be a field, n ∈ N>0 , A ∈ F n×n of rank r ≤ n with leading principal r × r
submatrix nonsingular, and b ∈ F n such that the linear system Ay = b is solvable.
Then for any vector v ∈ F n there is a unique v∗ ∈ F n such that A · (v∗ − v) = b and
the lower n − r coordinates of v∗ are zero. Moreover, v∗ − v is a uniform random
vector in the solution space {y ∈ F n : Ay = b} if v is a uniform random vector in F n .
Thus given A, b as in the theorem, we choose a random vector v and apply Wie-
demann’s algorithm 12.12 to the linear system Ar yr = br , where Ar ∈ F r×r is the
leading principal submatrix of A, the vector br ∈ F r consists of the upper r coor-
dinates of b + Av, and yr ∈ F r is to be computed. If we let v∗ ∈ F n be the vector
whose upper part is yr and whose lower part is zero, then the theorem implies that
y = v∗ − v is a uniform random solution of the linear system Ay = b. (This works,
in particular, for b = 0.) Since we may apply Ar to a vector vr ∈ F r by applying A
to the vector whose upper r coordinates are those of vr and whose lower n − r ones
are zero and taking the upper r coordinates of the result, the cost for the method
described above is O(n(c(A) + n)) operations in F.
Kaltofen & Saunders also give a probabilistic algorithm which transforms an ar-
bitrary matrix C ∈ F n×n into the form required in Theorem 12.19, thereby preserv-
ing the black box property, and determines its rank. If the field has at least 3(n2 +n)
elements, then their algorithm uses O(n(c(C)+M(n))) field operations and returns
the correct result with probability at least 1/2. To find a solution of the linear sys-
tem with coefficient matrix C, the above method is applied to the transformed
matrix, and a uniform random solution of the original linear system can be com-
puted within the same time bound. The cost for one application of the transformed
352 12. Fast linear algebra
matrix to a vector is c(C) + 2M(n), and the overall cost is O(n(c(C) + M(n)))
operations.
An important aspect of Wiedemann’s algorithm is that the only use of the ma-
trix A is to evaluate it at vectors. Thus instead of storing an array of n2 entries,
all we need is a “black box” for the evaluation of A, that is, a subroutine which
on input v ∈ F n returns Av ∈ F n . This leads to a new way of doing linear algebra,
black box linear algebra (or implicit linear algebra), in contrast to the traditional
explicit linear algebra, where all entries of A are explicitly stored. A somewhat
intermediate concept is sparse linear algebra, where A is stored in a sparse for-
mat, listing only those (i, j, ai j ) with ai j 6= 0; this is appropriate for Wiedemann’s
original application to integer factorization (Chapter 19).
As an example, let ω ∈ F be a primitive nth root of unity and suppose that A =
VDM(1, ω , ω 2 , . . . , ω n−1 ) is the matrix of the Discrete Fourier Transform DFTω
(Section 8.2). Thus solving Av = b for v corresponds to interpolating at the powers
of ω with values determined by b, and evaluation of A at v corresponds to comput-
ing the Discrete Fourier Transform of the polynomial corresponding to v, which
can be done at a cost of O(n log n) arithmetic operations. Actually, this does not
yield improved algorithms here, since DFT−1 ω can be computed with O(n log n) op-
erations, while the black box linear algebra approach takes O(n2 log n), but it does
when applied to the Berlekamp matrix for factoring polynomials (Section 14.8).
Notes. 12.1. Algorithm 12.1 is due to Winograd (1971), and the current world record
ω < 2.3727 is from Williams (2011), after the result of Coppersmith & Winograd (1990)
had stood for a quarter century. The entries of the following table indicate the approximate
date of discovery of new feasible matrix multiplication exponents in history; publication
was often years later.
The details of these algorithms are beyond the scope of this text. The most comprehensive
treatment is in Bürgisser, Clausen & Shokrollahi (1997); we also refer to the books by Pan
(1984) and de Groote (1987), and the survey articles of Strassen (1984, 1990) and von zur
Gathen (1988) for details and references. Also for the rest of this section, we refer the
reader to those texts.
Fast algorithms (or reductions) for the problems at the end of the section are in van der
Waerden (1938), Strassen (1969, 1973a), Bunch & Hopcroft (1974), Baur & Strassen
(1983), and Keller-Gehrig (1985). Chou, Deng, Li & Wang (1995) report on a success-
ful parallel implementation of Strassen’s matrix multiplication.
Various normal forms of matrices are important tools in linear algebra, say over a Eu-
clidean domain R. The Hermite normal form (Notes 4.5) is particularly useful for solving
Exercises 353
linear equations over R. Algorithm 16.26 computes the Hermite normal form over Z of a
nonsingular square matrix, and faster algorithms are in Storjohann (2000). Giesbrecht,
Storjohann & Villard (2003) is a survey of this active area by three of the main contribu-
tors.
12.2. Algorithm 12.3 is from Brent & Kung (1978). It can be slightly speeded up by using
faster algorithms for rectangular matrix multiplication . The direct approach for multiply-
ing an n × n matrix by an n × n2 matrix using ω < 2.373 takes O(n3.373 ) ring operations.
Huang & Pan (1998) have improved the exponent for this particular rectangular problem
to less than 3.334, and then the n1.687 in Corollary 12.5 drops to n1.667 . In the special
case f = xn , Brent & Kung give a O(M(n)(n log n)1/2 ) solution (Exercise 12.4). Bernstein
(1998a) presents a faster algorithm for rings of small characteristic.
12.3. Linearly recurrent sequences were already studied by de Moivre, and the equivalence
between finding recurrence relations and computing Padé approximants (Lemma 12.8) was
known to Kronecker (1881a), page 566. The problem is also intimately connected to solv-
ing Toeplitz (or Hankel) systems of equations. Krylov (1931) invented his method in the
context of solving differential equations for oscillation problems. The transposition prin-
ciple says that for a given square matrix A, the cost of computing Av or wA, for input
vectors v and w, are essentially the same (Fiduccia 1972b, 1973, Kaminski, Kirkpatrick &
Bshouty 1988). Kaltofen (2000) proposes as an open problem the task to relate these two
costs more precisely. The connection between these two problems is well-studied in digital
filter design; see Antoniou (1979), §4.7.
12.4. The block Wiedemann method, proposed by Coppersmith (1994) and analyzed and
improved by Kaltofen (1995b) and Villard (1997), reduces the number of evaluations of A
from 2n to (1 + ε)n for any ε > 0. It is particularly well suited for F = F2 and also leads
to efficient parallel algorithms over arbitrary fields.
A different black box method, based on inner products, for solving linear systems is due
to Lanczos (1952). LaMacchia & Odlyzko (1990) introduced the algorithm into computer
algebra by employing it for integer factorization. Block variants were given by Copper-
smith (1993) and Montgomery (1995), and Eberly & Kaltofen (1997) analyze randomized
Lanczos algorithms. Giesbrecht, Lobo & Saunders (1998) solve the problem of certify-
ing inconsistency of a system of linear equations over a field or over the integers by the
Wiedemann method.
Exercises.
12.1 Prove that Algorithm 12.1 works correctly.
12.2 Let g = h = x3 + 2x2 + 3x + 4 and f = x4 − 1 in F5 [x]. Trace Algorithm 12.3 on computing
g(h) rem f .
12.3 Let R be a ring (commutative, with 1), f , g, h ∈ R[x] with deg f = n, deg g < d, and deg h < m,
such that f is monic and d is a power of 2. Devise a divide-and-conquer algorithm for computing
g(h) rem f by splitting g into two blocks of size d/2. Prove that your algorithm takes O(M(n) log n)
operations in R if dm ≤ n, and O((dm/n)M(n) logn) in general.
12.4∗ Let n, m ∈ N, R be a (commutative) ring such that n! is a unit in R, and g, h ∈ R[x] of degrees
less than n. We let k = ⌈n/m⌉ and write h = h1 + h0 , with h0 , h1 ∈ R[x] such that deg h0 < m and xm
divides h1 .
(i) Prove that the following Taylor expansion holds:
g(k) (h0 ) k
g(h) ≡ g(h0 ) + g′ (h0 )h1 + · · · + h1 mod xn .
k!
354 12. Fast linear algebra
(ii) The chain rule implies that g(i+1) (h0 ) · h′0 = (g(i) (h0 ))′ for all i ∈ N. Assuming that h′0 (0)
is nonzero, show that g(i+1) (h0 ) rem xn+k−i−1 can be computed from g(i) (h0 ) rem xn+k−i using
O(M(n)) operations in R, for 0 ≤ i < k.
(iii) Consider Brent & Kung’s (1978) algorithm for computing g(h) mod xn .
A LGORITHM 12.20 Composition modulo powers of x.
Input: n ∈ N and g, h ∈ R[x] of degrees less than n such that h′ (0) 6= 0.
Output: g(h) rem xn ∈ R[x].
1. write h = h1 + h0 as above
for i = 2, . . ., k compute hi1 /i! rem xn
2. call the algorithm from Exercise 12.3 to compute g(h0 ) rem xn+k
3. for i = 1, . . ., k compute g(i) (h0 ) rem xn+k−i
hi1
4. return ∑ g(i) (h0 ) rem xn
0≤i≤k i!
Its correctness follows from (i). Use (ii) to prove that the algorithm takes O((k + m logn)M(n))
operations in R.
(iv) Which choice of m minimizes the running time?
(v) Can you remove the restriction that h′ (0) be nonzero, using essentially the same time bound?
12.5 Prove properties (1) through (6) of a module operation •.
12.6 Let V be a vector space over a field F.
(i) What is the minimal polynomial of the sequence (ai )i∈N ∈ F N defined by ai = 1 for 0 ≤ i < n
and ai = 0 otherwise?
(ii) How are ma and mxn •a for a ∈ V N and n ∈ N related?
12.7 Prove Lemma 12.8 (i).
12.8 Determine a recurrence relation and sufficiently many initial values of the sequence (ai )i∈N ∈
Q N if h = ∑i≥0 ai xi ∈ Q[[x]] is
x2 + x x2 − x x4 + x
(i) h = , (ii) h = , (iii) h = .
x3 − x − 1 x4 − x2 − x x3 − x − 1
12.9 Compute the minimal polynomial of the sequence 1, 3, 4, 7, 11, 18, 29, 47, . . . of rational num-
bers using Algorithm 12.9. You may assume that the recursion order is at most four. Give the next
12 elements of the sequence.
12.10∗ Let F be a field, f ∈ F[x] an irreducible polynomial of degree n, E = F[x]/h f i, α = x
mod f ∈ E, and β = g(α) ∈ E for some nonzero polynomial g ∈ F[x] of degree less than n.
(i) Prove that the minimal polynomial m ∈ F[x] of β over F is equal to the minimal polynomial of
the sequence (β i )i∈N ⊆ E N over F.
(ii) Let τ : E −→ F be the F-linear map with τ (∑0≤i<n ci αi ) = c0 for all c0 , . . ., cn−1 ∈ F. Prove
that m is the minimal polynomial of the sequence (τ (β i ))i∈N ⊆ F N . Hint: m is irreducible.
(iii) Show that m can be computed using O(n M(n)) operations in F.
(iv) Compute the minimal polynomial of 22/3 + 21/3 + 1 over Q.
(Shoup (1999) employs Algorithm 12.3 to compute minimal polynomials over a finite field F with
O(n1/2 M(n) + n2 ) arithmetic operations.)
12.11 Let F be a field, A ∈ F n×n , u, b ∈ F n , and define sequences a = (Ai )i∈N and a∗ = (Ai b)i∈N .
(i) Prove that f ∈ F[x] is a characteristic polynomial of a if and only if f (A) = 0 in F n×n .
(ii) Prove that f ∈ F[x] is a characteristic polynomial of a∗ if and only if f (A)b = 0 in F n .
Exercises 355
12.12∗ This continues Exercise 12.11. Let a∗∗ = (uT Ai b)i∈N . Find a situation where uT f (A)b = 0,
but f is not a characteristic polynomial of a∗∗ . Can you determine a stronger condition such that
a similar equivalence as in Exercise 12.11 holds? Hint: Consider the condition that uT f (A) be
orthogonal to the Krylov subspace hAi b: i ∈ Ni of F n generated by b.
12.13−→ Let
1 2 3 0
A= 4 0 1 ∈ F53×3 , b = 1 ∈ F53 ,
1 3 1 2
and compute A−1 b using Wiedemann’s algorithm 12.12.
12.14∗ Let F be a field, n ∈ N, A ∈ F n×n , and ei ∈ F n be the ith unit vector, that is, the column
vector with 1 in coordinate i and 0 everywhere else, for 1 ≤ i ≤ n. Prove that if f , f1 , . . ., fn ∈ F[x]
are the minimal polynomials of A, (Ai e1 )i∈N , . . ., (Ai en )i∈N , respectively, then f = lcm{ f1 , . . ., fn }.
Generalize this to arbitrary bases e1 , . . ., en of F n .
12.15∗ Let F be a field.
(i) Design an algorithm that, given a matrix A ∈ F n×n , computes its minimal polynomial by ran-
domly choosing u, b ∈ F n , computing the minimal polynomial of (uT Ai b)i∈N , and checking whether
it is actually the minimal polynomial of A. Prove that your algorithm is correct if it halts.
(ii) Let f ∈ F[x] be the minimal polynomial of A. Show that there is a surjective bilinear map
ψ: F n × F n −→ F[x]/h f i (bilinear means that ψ is linear with respect to both arguments) such that
(iii) Let uk ∈ F[x] be the value of u chosen in the kth iteration and gk ∈ F[x] the minimal polynomial
of the sequence a(k) = (uTk Ai b∗ )i∈N , where b∗ ∈ F n is the initial value of b. Prove that the invariant
m = gk / gcd(g, gk ) holds after the kth pass through step 3, and conclude that g = lcm(g1 , . . ., gk )
holds before the kth pass through step 2.
(iv) Let U = F = Fq be a finite field with q elements and f ∈ F[x]. Prove that for k polyno-
mials h1 , . . ., hk ∈ F[x] of degree less than deg f chosen uniformly at random and independently, the
probability that gcd(h1 , . . ., hk , f ) = 1 is pk = ∏1≤ j≤r (1 − q−k deg f j ), where f1 , . . ., fr ∈ F[x] are the
distinct monic irreducible factors of f .
(v) Now let f be the minimal polynomial of (Ai b∗ )i∈N . Prove the following generalization of
Lemma 12.16 (with b replaced by b∗ ): If ψ(u) = h mod f with h ∈ F[x], then mψ∗ (u) = f / gcd( f , h).
Conclude that pk from (iv) is the probability that the above algorithm terminates after at most k
iterations.
(vi) Let ni = #{1 ≤ j ≤ r: deg f j = i} for all i. Prove that
Use that ni ≤ qi /i, by Lemma 14.38, to show that pk ≥ 1 −2q1−k if k ≥ 2. Conclude that the expected
number ∑k≥0 (1 − pk ) of iterations of the algorithm is at most 4.
Research problem.
12.19 Can you improve the cost for modular composition of polynomials of degrees at most n to,
say, O∼ (n1.5 ) or better?
Völker, hört die Signale!1
Emil Luckhardt (c. 1890)
In this chapter, we discuss the background of the Fourier Transform from electri-
cal engineering and signal processing. Its fundamental property of transforming a
(discrete or continuous) signal from its description in the time domain to an equiv-
alent characterization in the frequency domain is used to describe and analyze the
contributions of different frequencies to a signal. Furthermore, we present an ap-
plication of the Fourier Transform in image processing.
f : D −→ R n , where D ⊆ R m and m, n ∈ N.
f : D −→ R n , where D ⊆ Z m and m, n ∈ N.
Sound is a continuous signal that varies over time and has range loudness. It is
an example of a signal f : R −→ R. In the case of gray-scale pixels on a screen, the
signal associates to each point an intensity value, so that f : D ⊆ Z 2 −→ R. When
color is represented by the constituent amounts of three basic colors (RGB) or four
basic colors (CMYK), we have a signal mapping into R 3 or R 4 , respectively.
A discrete signal is often obtained by sampling a continuous signal at discrete
intervals. This is illustrated in Figure 13.1, where a continuous signal is sampled
at regularly spaced points.
Discrete signals find applications in areas such as biomedical engineering, seis-
mology, acoustics, sonar and radar imaging, speech communication, data com-
munication, television satellite communication, satellite images, and many more.
Speech and telephone signals are examples of signals with only one dimensional
359
360 13. Fourier Transform and image compression
1.5
0.5
-0.5
-1
-1.5
0 20 40 60 80 100
t
F IGURE 13.1: The analog signal f (t) = sin(t/10) + t 2 sin(t/2)/40 000 (red curve), and
the corresponding discrete signal (blue dots).
domains, while radar imaging, satellite images, and lunar images are processed
with two dimensional domains. When modeling complicated problems, such as
those that appear in seismology, the domain can have many dimensions.
It is important to perform certain operations on signals to extract relevant infor-
mation from them, or to transform the signal to make it easier to use. For instance
one may wish to extract some important parameters from the data such as danger
alerts from an electrocardiogram or electroencephalogram. One may want to com-
press the data contained in a telephone signal or recognize the words associated
with speech signals. A common problem is to extract relevant information from
masses of data associated with such things as television transmission or satellite
images. Another application of signal processing in signal transmission is to try
to remove signal interference contributed by transmission noise, fading or channel
distortion.
Of particular importance are the sine signal f : R −→ R with f (t) = sint, and
2 ∼ it
its
√ complex variant f : R −→ R = C with f (t) = e = cost + i sint, where i=
−1. More generally, we have the signal f : R −→ C with f (t) = a · eikt , with
amplitude a, corresponding to the intensity of the signal (for example, loudness
of an audio signal or luminance of a video signal), and frequency k (corresponding
to pitch or color, respectively). All those signals are examples of periodic signals:
there exists a period T ∈ R>0 such that f (t + T ) = f (t) for all t ∈ R. Applying
the transformation t 7−→ 2πt/T , we may assume that T = 2π . For the sinusoidal
signal f (t) = a · eikt , the smallest such period T is the wavelength and related to
13.1. The Continuous and the Discrete Fourier Transform 361
2
sin(t) + sin(10t)/10
1.5 sin(t)
sin(10t)/10
1
0.5
-0.5
-1
-1.5
-2
-10 -5 0 5 10
t
The following inversion formula expresses the function f in terms of its Fourier
Transform:
1
f (t) = ∑ fb(k)eikt .
2π k∈Z
(1)
k ∈ Z are the Fourier coefficients of f . The inversion formula says that the func-
tion f is uniquely determined by the sequence of its Fourier coefficients (βk )k∈Z .
The special functions eikt , for k ∈ Z, are a “basis” for the complex vector space
of all 2π -periodic functions; however, there are in general infinitely many nonzero
coefficients.
While the original signal f is described in the time domain by assigning to each
time t ∈ [0, 2π ] the value f (t) of the signal at that time, the Fourier Transform fb
is an equivalent characterization of f in the frequency domain. It associates to
each frequency k ∈ Z the contribution fb(k) of that frequency, namely of the signal
exp(ikt)/2π , to f , as given by the inversion formula (1). It compresses the “con-
tinuously” many values f (t) into the countably many values fb(k). For k ∈ N>0 ,
the signal ( fb(k) exp(ikt) + fb(−k) exp(−ikt))/2π is called the kth harmonic of f .
and fb(k) = 0 for k 6= ±1, ±10. Thus the first harmonic of f is ( fb(1) exp(it) +
fb(−1) exp(−it))/2π = sin(t), the 10th harmonic is sin(10t)/10, and all other har-
monics are zero. ✸
The Discrete Fourier Transform is the analog of the Continuous Fourier Trans-
form for discrete periodic signals. If f : Z −→ C is a discrete signal with period
n ∈ N>0 , its Discrete Fourier Transform fb: Z −→ C is defined by
1 π k(2 j + 1)
DCT( f )(k) = √ c(k) ∑ f ( j) cos for 0 ≤ k < n,
n 0≤ j<n 2n
1 π k(2 j + 1)
IDCT( f )( j) = √ ∑ c(k) f (k) cos for 0 ≤ j < n,
n 0≤k<n 2n
√
where c(k) = 1 if k = 0 and c(k) = 2 otherwise, then DCT and IDCT are inverse
operators mapping real-valued signals of finite duration n to signals of the same
364 13. Fourier Transform and image compression
1 1
0 k=0 0
k=1
-1 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
1 1
k=3
0 k=2 0
-1 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
1 1
0 0
k=4 k=5
-1 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
1 1
k=6 k=7
0 0
-1 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
kind (Exercise 13.6). DCT( f ) is the Discrete Cosine Transform (DCT) of f . Ex-
ercise 13.6 also shows that computing this transform or its inverse can be reduced
to computing a Discrete Fourier Transform, which can be done efficiently via the
FFT if n is a power of 2, using O(n log n) operations in R.
The inversion formula
1 π k(2 j + 1)
f ( j) = (IDCT ◦ DCT)( f )( j) = √ ∑ c(k)DCT( f )(k) cos
n 0≤k<n 2n
for 0 ≤ j < n shows that the Discrete Cosine Transform leads to a representation of
the original signal f as a linear combination of periodic signals γk , where γk ( j) =
√
cos(π k(2 j + 1)/2n), with coefficients c(k)DCT( f )(k)/ n. Figure 13.3 depicts
the signals γk on the interval 0, . . . , n − 1 for n = 8. Larger values of k correspond
to a more rapid variation of γk .
A possible image data compression algorithm works as follows. For each row
f : {0, . . . , n − 1} −→ R of the image, where f ( j) is the luminance of the jth pixel
in that row, compute DCT( f )(k) for 0 ≤ k < n (if the image is a color image, then,
for example, apply this separately for the intensities of each of the three colors
red, green, and blue). Then choose a quantizing parameter q ∈ R≥1 , divide all val-
ues of DCT( f ) by q, and round to the nearest integer. The effect of quantization
13.2. Audio and video compression 365
F IGURE 13.4: A grayscale image of Schloß Neuhaus at Paderborn, and the absolute values
of its row-wise Discrete Cosine Transform. The color white corresponds to zero, and
frequency increases from left to right.
is that those values of DCT( f )(k) that are close to zero in absolute value (which
in general will be the case for the high frequency parts, that is, for large k) van-
ish completely. Thus large values of q correspond to high compression rates but
also to worse image quality. Finally a combination of lossless data compression
techniques, such as run length encoding and Huffman encoding, is applied to the
quantized values. Run length encoding compresses each consecutive sequence
(= run) of zeroes to two integers: a zero marking the position of the run, followed
by the length of the run. For example, the sequence
1, 2, 3, 0, 0, 0, 0, 4, 0, 5, −6, 0, 0, 0, 1, 2
is compressed to
1, 2, 3, 0, 4, 4, 0, 1, 5, −6, 0, 3, 1, 2
thereby decreasing the length by two. We note that “runs” of zeroes of length 1
actually increase the size, like the single zero between 4 and 5 in the above exam-
ple. In order to reconstruct the image, we proceed in the opposite direction: after
decoding the compressed values, we multiply them by q and apply the Discrete
Cosine Transform row by row.
366 13. Fourier Transform and image compression
Figure 13.4 shows at left a grayscale image with 1088 rows, 728 columns, and
luminance values between 0 (= black) and 255 (= white). Hence the size of the im-
age is 1088 · 728 = 792 064 bytes in a dense encoding, where the luminance value
of each pixel is stored in one byte. At right, we see the absolute values of the row-
wise Discrete Cosine Transforms of that image. The luminance of the kth pixel
from the left in row fl corresponds to the absolute value of DCT( fl )(k) (for better
visibility, white represents 0 in this image and all values are multiplied by 10), and
one can observe that the DCT coefficients get smaller as the frequency increases.
Finally, Figure 13.5 shows the same image after quantizing and dequantizing with
parameter q (that is, rounding the DCT coefficients to integral multiples of q) and
row-wise application of IDCT, for q = 10 and q = 100. The image at right in
Figure 13.4 illustrates why these compression methods are successful. Light gray
areas are “rounded down” to 0, and the darker values are similarly simplified. The
larger q is, the more rounding occurs.
F IGURE 13.5: The image from Figure 13.4 after quantizing with q = 10 and q = 100,
using a row-wise Discrete Cosine Transform.
Table 13.6 lists the compression rates—the size ratio of the compressed and the
original image—for the image from Figure 13.4 with various quantizing parame-
ters q and different lossless data compression techniques. For example, the size
of the file after quantizing with q = 10 and using both run length and Huffman
encoding is 107 646 bytes, which is about 13.59% of the original size, and this
13.2. Audio and video compression 367
q 1 2 5 10 20 50 100
Huffman 55.89 44.00 29.37 22.60 18.24 14.89 13.62
Run length 91.81 75.01 43.26 28.52 18.49 8.99 4.64
Run length + 52.83 39.89 22.26 13.59 8.21 3.85 1.94
Huffman
TABLE 13.6: Compression rates in % for the image from Figure 13.4 with the row-wise
Discrete Cosine Transform and different encoding schemes.
q 1 2 5 10 20 50 100
Huffman 40.95 29.62 20.38 17.13 15.43 14.18 13.52
Run length 78.14 54.35 23.39 12.57 8.08 5.34 4.21
Run length + 35.14 23.98 11.24 6.14 3.68 2.07 1.33
Huffman
TABLE 13.7: Compression rates in % for the image from Figure 13.4 with the Discrete
Cosine Transform for 8 × 8 squares and different encoding schemes.
F IGURE 13.8: The image from Figure 13.4 after quantizing with q = 10 and q = 100,
using the Discrete Cosine Transform for 8 × 8 squares.
368 13. Fourier Transform and image compression
compression rate is the entry in the last row of the column with head 10 in Ta-
ble 13.6. For comparison, Huffman encoding applied to the image itself (instead
of its Discrete Cosine Transform) yields a compression rate of 75.62%, and the
GIF graphics format achieves a lossless compression to 54.08% of the original
size.
The method described above has the disadvantage that quantization leads to
perturbations in the whole row, as can be seen in Figure 13.5 for q = 100. Thus
the local structure of an image (for example, slow variation of the luminance in
the sky parts of Figure 13.4) cannot be exploited. This can be circumvented by
dividing the image into smaller parts of a fixed size (instead of complete rows) and
applying the above compression technique to each part separately.
In the JPEG still image compression standard, for example, the original image
is divided into squares of 8 × 8 pixels, and the two-dimensional Discrete Cosine
Transform of each square (which is a combination of a row-wise and a column-
wise one-dimensional Discrete Cosine Transform) is computed. Then the DCT
coefficients of all squares are quantized, run length encoded and finally Huffman
encoded. While the one-dimensional row-wise Discrete Cosine Transform takes
only horizontal dependencies into account, its two-dimensional variant covers hor-
izontal and vertical dependencies simultaneously. This together with the improved
adaptivity to the local structure of an image leads to significantly higher compres-
sion rates than the above row-wise approach (Table 13.7).
Figure 13.8 shows the image from Figure 13.4 after compression and decom-
pression with the Discrete Cosine Transform for 8 × 8 squares and quantization
factors q = 10 and q = 100. For q = 10, for example, one hardly notices any dif-
ferences between the images in Figures 13.5 and 13.8, but the compression rate of
the former is about 13.59%, while the latter compresses down to 6.14%.
Notes. 13.1. Good references for (digital) signal processing are Oppenheim & Schafer
(1975) and Oppenheim, Willsky & Young (1983).
13.2. For a description of the Huffman code, see Huffman (1952), §16.3 in Cormen, Leiser-
son, Rivest & Stein (2009), and Exercise 10.6. The JPEG standard is described in Wallace
(1991) and Pennebaker & Mitchell (1993).
Exercises.
13.1 Show that for any discrete periodic signal f : Z −→ C there is a least period (called the funda-
mental period) n ∈ N>0 such that any other period of f is an integral multiple of n.
13.2 Let f , g: R −→ C be two 2π-periodic signals. If f and g are sufficiently smooth, then the
convolution Z 2π
( f ∗ g)(t) = f (s)g(t − s)ds
0
exists for all t ∈ R. Prove that f ∗ g is again 2π-periodic, and that the convolution property fd
∗ g = fb· gb
holds, so that
( fd
∗ g)(k) = fb(k) · gb(k) for all k ∈ Z.
Exercises 369
(Thus the Fourier Transform converts convolution into pointwise multiplication.) You may assume
that all occurring integrals exist.
13.3 Let f (t) = sin(t) + sin(10t)/10. Compute fb(k) for k ∈ Z.
√
13.4−→ (i) Compute the Fourier coefficients of f (t) = eint for a fixed n ∈ Z, where i = −1.
(ii) Compute the Fourier coefficients of the 2π-periodic square wave which has f (t) = −1 for
−π ≤ t < 0 and f (t) = 1 for 0 ≤ t < π.
1
0.5
0
t
-0.5 -10 -5 0 5 10
-1
(iii) Compute the Fourier coefficients of the 2π-periodic triangular wave which has f (t) = t/π for
−π ≤ t < π.
1
0.5
0
t
-0.5 -10 -5 0 5 10
-1
13.5 Let f : Z −→ C be a discrete signal of period n ∈ N>0 . Show that ℜ fb(k) = 0 for all k if f is
odd, so that f ( j) = − f (− j) for all j, and that ℑ fb(k) = 0 for all k if f is even, so that f ( j) = f (− j)
for all j.
13.6∗ Let f : {0, . . ., n − 1} −→ R be a discrete signal of finite duration n. We associate to f a signal
g: Z −→ R of period 4n, by letting
and periodically extending g to a function that is defined for all integers. This corresponds to gluing
f and a reflected copy of f together and interleaving the result with zeroes. Obviously g is even and
g( j) vanishes if j is even.
(i) Prove that the Discrete Fourier Transform gb is real-valued of period 4n and has the symmetry
properties
gb(k) = gb(4n − k) = −b
g(2n + k) = −bg(2n − k) for k ∈ Z.
(ii) Show that the inversion formula
!
1 gb(0) πk(2 j + 1)
f ( j) = g(2 j + 1) = + ∑ gb(k) cos
n 2 1≤k<n 2n
372
14 and 15). This material was published posthumously from his handwritten
notes (Gauß 1863b).
Gauß married Johanna Osthoff, younger by three years, in 1805. They had
three children, but Johanna died after the last birth. Less than a year later, Gauß
married her friend Minna Waldeck, eleven years younger, and they also had three
children.
Gauß’ influence permeates many parts of this book. His study of roots of unity
and their subdivision according to subgroups of the relevant Galois group, the
Gauß periods , can be seen as a precursor of the Fast Fourier Transform in
Section 8.2. (These periods are also instrumental for modern fast algorithms for
exponentiation in finite fields.) He proved the basic facts about factoring
polynomials and the relation between factoring over Z and over Q (Section 6.2),
found (but did not publish) the distinct-degree factorization method over finite
fields (Section 14.2) and Hensel lifting (Section 15.4), guessed the prime number
theorem (but did not prove it; see Notes 18.4), and studied hypergeometric series
(Section 23.4). His Gaussian elimination is a staple of linear algebra
(Sections 5.5 and 14.8).
Perhaps as important as his monumental contributions to so many fields is the
fact that he championed the idea of mathematical rigor and watertight proof. This
was often absent in 18th century mathematics, which lacked a precise
understanding of things like limits and infinite sums. (Later, people such as
Cauchy, Weierstraß, and Hilbert perfected Gauß’ approach.)
According to himself,
Gauß’ work was only
motivated by his inner urge
for mathematical discoveries,
and not his desire to publish
or impress others. This
manifested itself in markedly
weak public relations. He did
not educate a school of eager
young disciples to spread his gospel, but he had a few brilliant students: Bernhard
Riemann was his only pupil in the usual sense; Ferdinand Eisenstein and Richard
Dedekind were his students in a wider sense. Many of Gauß’ discoveries were not
published during his lifetime: his insights on the arithmetic–geometric mean,
elliptic functions and their double periodicity (with which Abel and Jacobi
struggled later), the fundamental theorem on analytic functions (vanishing of
closed curve integrals, rediscovered by Cauchy), quaternions (found by William
Hamilton on 16 October 1843, when Gauß’ notes had already slumbered in his
drawers for thirty years), and his 1816 discovery of non-Euclidean geometry
373
(given to the world by Nikolas Lobachevsky in 1829, and the son Johann Bolyai
de Bolya of Gauß’ friend Wolfgang Bolyai in 1832).
His appointment at the university of Göttingen in 1807 was as professor of
astronomy. On 1 January 1801, Guiseppe Piazzi had discovered the asteroid
Ceres—and it vanished in February. The astronomers could not find it again.
Gauß used his newly devised computational methods in astronomy to calculate
the orbit, and thanks to this, Ceres was rediscovered in December. This brought
world-wide fame to him instantly. During his 48 years as professor, he gave 181
courses and seminars; of these, 128 were on astronomy, and only one on number
theory.
One highly unusual aspect of Gauß’ work is his uncanny mixture of theory and
practice, with either profiting from the other. (Archimedes had a similar talent,
while Newton’s theoretical determination of improved ship hull cross-sections
failed in practice.) This gave his scientific achievements a much wider audience
than usual, and, after the low ebb of natural science (as opposed to literature,
music, and philosophy) in Germany during the 18th century, he helped create an
atmosphere in which bright young men were attracted to mathematics and science
in the 19th century.
Gauß led, over many years, a geodetical survey of the Kingdom of Hannover.
A private goal was to determine, in view of his discovery of non-Euclidean
geometry, whether physical triangles really have an angle sum of 180 degrees—
a question that astronomers still work on today with high-precision instruments.
This work stimulated his research in differential geometry, leading to the
important concept of Gaussian curvature and the Gauß–Bonnet theorem. He
constructed, with Wilhelm Weber, an electric telegraph in 1833, with a 2-km-long
wire, destroyed by lightning in 1845. He worked, also with Weber, on earth
magnetism, and the unit of the magnetic force is called a gauß. At the Senate’s
request, he reorganized the University Widow’s Fund, and on the way created the
basis for modern life insurance calculations.
Gauß died in 1855, at age 77, and was buried in St. Albani’s cemetery in
Göttingen; today this is a pleasant park.
374
Polynomial factorization is perhaps one of the
most striking successes of symbolic computation.
Zhuojun Liu and Paul S. Wang (1994)
1 The question of factorization, which G AUSS rightly considered as fundamental, is treated in our work with an
abundance of details that one does not find usually in a textbook, and some notions are developed there for the
first time. [. . . ] It is not appropriate for us to make statements about the scientific value of our exposition, but we
have the conviction that we have spared neither effort nor time in order to elucidate this important question.
2 Most often, however, it will be easy to find by trial an irreducible polynomial [modulo a prime number] of a
given degree ν.
3 In most sciences one generation tears down what another has built and what one has established another undoes.
In mathematics alone each generation builds a new storey on top of the old structure.
14
Factoring polynomials over finite fields
377
378 14. Factoring polynomials over finite fields
Fq [x]
Q(α)[x] Q[x1 , . . . , xn ]
Q(α)[x1 , . . . , xn ]
The dependencies between some of these are shown in Figure 14.1. It turns out
that factoring univariate polynomials over finite fields is a basic task used in many
other factoring algorithms. Factoring in Q[x] is the topic of Chapters 15 and 16.
Some algorithms for finite fields proceed in three stages:
14.1. Factorization of polynomials 379
squarefree factorization
F IGURE 14.2: The stages of univariate polynomial factorization over finite fields.
1. squarefree factorization,
2. distinct-degree factorization,
3. equal-degree factorization.
Squarefree factorization gets rid of multiple factors, distinct-degree factorization
splits irreducible factors according to their degrees, and equal-degree factorization
solves the remaining problem, where all irreducible factors are distinct and of the
same degree. In Figure 14.2, we see how the three stages work. The width of a
box represents the degree of the corresponding polynomial; different colors stand
for different irreducible factors. In the example, the original polynomial consists
of four factors of degree 2 (two of them equal), one factor of degree 4, and one of
degree 6.
The first stage is quite easy, both in theory and in practice. When the input is a
large random polynomial, then the third stage is likely to be needed only for very
small polynomials, and the second stage consumes the bulk of the computing time
(more than 99% in our experiments described in Section 15.7).
In the next three sections we present in detail a conceptually simple complete
factorization algorithm; see Figure 14.7. The determination of repeated factors in
Figure 14.2 is actually delayed until the end.
A fundamental tool for our algorithms is the following theorem (see Section
25.4 for a proof), which generalizes Theorem 4.9.
The reader must be thoroughly familiar with the material of Section 25.4 on
finite fields, of which we make substantial use. The notation Fq and Fermat’s
little theorem in Fq are used over and over again. We will also use the fact that if
f ∈ Fq [x] is irreducible of degree n, then Fqn = Fq [x]/h f i is a field with qn elements
(Section 4.2), and Fermat’s little theorem implies that Fq = {a ∈ Fqn : aq = a} .
The possible sizes of finite fields are precisely the prime powers, and in the
following, q always denotes a prime power. The reader may think of q as being a
prime number. However, most statements or proofs do not become simpler for this
special case, so that we may as well work in full generality.
T HEOREM 14.2.
d
For any d ≥ 1, xq − x ∈ Fq [x] is the product of all monic irreducible polynomials
in Fq [x] whose degree divides d .
d
P ROOF. By Fermat’s little theorem 14.1, applied to Fqd , h = xq − x is the product
of all x − a with a ∈ Fqd . If g2 divides h (over Fq ) with g ∈ Fq [x] \ Fq , then some
x−a divides g and (x−a)2 divides h. Since this is impossible, no such g exists, and
d
xq − x is squarefree. It is sufficient to show for any monic irreducible polynomial
f ∈ Fq [x] of degree n that
d
f divides xq − x ⇐⇒ n divides d.
d
We consider the field extension Fq ⊆ Fqd . If f divides xq − x, then from Theo-
rem 14.1, applied to Fqd , we get a set A ⊆ Fqd with f = ∏a∈A (x − a). We choose
some a ∈ A, and let Fq [x]/h f i ∼
= Fq (a) ⊆ Fqd , where Fq (a) is the smallest subfield
of Fqd containing a (Section 25.3). This is a field with qn elements, and Fqd is an
extension of Fq (a), so that qd = (qn )e for some integer e ≥ 1. Hence n divides d.
Now suppose that n divides d, let Fqn = Fq [x]/h f i, and a = (x mod f ) ∈ Fqn be a
n
root of f . Theorem 14.1 says that aq = a. Since qn − 1 divides qd − 1 = (qn − 1) · e
n
with e = qd−n + qd−2n + · · · + 1, also xq −1 − 1 divides
d n n
xq −1
− 1 = (xq −1 − 1)(x(q −1)(e−1) + · · · + 1).
n d
Multiplying by x, we find that xq − x divides xq − x, and hence
n d
(x − a) | (xq − x) | (xq − x),
14.2. Distinct-degree factorization 381
d
so that x − a divides gcd( f , xq − x) in Fqn [x]. But the gcd of two polynomials
with coefficients in Fq also has coefficients in Fq (Example 6.19), and since it is
d
nonconstant and f is irreducible, gcd( f , xq − x) = f , or, equivalently, f divides
d
xq − x. ✷
T HEOREM 14.4.
The distinct-degree factorization algorithm works correctly as specified. It takes
O(s M(n) log(nq)) or O∼ (n2 log q) operations in Fq , where s is the largest degree
of an irreducible factor of f .
The first two claims are clear for i = 0. For i ≥ 1, we have hi ≡ hqi−1 ≡ (xq )q =
i−1
i i
xq mod f , so that hi − x ≡ xq − x mod f and
i
gi = gcd(hi − x, fi−1 ) = gcd(xq − x, fi−1 ).
By Theorem 14.2, gi is the product of all monic irreducible polynomials in Fq [x]
of degree dividing i that divide fi−1 = Gi · · · Gn , hence gi = Gi . Furthermore, fi =
Gi · · · Gn /gi = Gi+1 · · · Gn . This finishes the inductive step and also shows that s = t.
The cost for computing hi in step 2 is O(log q) multiplications modulo f in
step 2, or O(M(n) log q) operations in Fq , by Corollary 11.11. Similarly, the cost
for computing gi and fi is O(M(n) log n) operations. ✷
Algorithm 14.3 may be stopped as soon as deg fi < 2(i + 1), since all irreduc-
ible factors of fi have degree at least i + 1, and hence fi is irreducible in that
case. This is called early abort and guarantees that the algorithm stops after
i = max{m1 /2, m2 } ≤ n/2, where m1 and m2 are the degrees of the largest and
the second largest irreducible factor of f , respectively. In step 2, hi is actually only
needed modulo fi−1 .
E XAMPLE 14.5. We let q = 3 and trace Algorithm 14.3 on the squarefree poly-
nomial f = x8 + x7 − x6 + x5 − x3 − x2 − x ∈ F3 [x]. Then
h1 = h30 rem f = x3 rem f = x3 ,
g1 = gcd(h1 − x, f0 ) = gcd(x3 − x, f ) = x,
f0 f
f1 = = = x7 + x6 − x5 + x4 − x2 − x − 1,
g1 x
h2 = h31 rem f = x9 rem f = −x7 + x6 + x5 + x4 − x,
g2 = gcd(h2 − x, f1 ) = gcd(−x7 + x6 + x5 + x4 + x, f1 ) = x4 + x3 + x − 1,
f1 x7 + x6 − x5 + x4 − x2 − x − 1
f2 = = = x3 − x + 1.
g2 x4 + x3 + x − 1
At this point, Algorithm 14.3 would perform one further iteration, but the early
abort condition deg f2 < 2(2 + 1) = 6 says that this is not necessary since f2 is
already irreducible. Thus f has one linear factor, two distinct irreducible quadratic
factors (which we do not know yet), and one irreducible cubic factor. The trace is
illustrated in Figure 14.3. ✸
f0 = f
g1 f1
g2 f2
3
9
5 14
12 1 13
8 5
8
F×
13 12
2 F×
17 16 1
4 3 6
11 2
11
6 4
10 9 7
7 15
10
2
We first collect some facts about the squaring map σ : F×
q −→ Fq , with σ (a) = a .
×
× ×
As an example, the effect of σ on the elements of F13 and of F17 is given in Fig-
ure 14.4. An arrow from a number i to a number j indicates that j = σ (i). Each
element has either two or zero arrows pointing to it; the first ones are the squares,
the second ones the nonsquares. Both sets contain exactly half of the elements.
Lemma 14.7 below, which is the special case k = 2 of the following lemma, says
that this is always the case.
× k
ker σk = {a ∈ F×
q : σk (a) = 1} = {a ∈ Fq : a = 1}, (1)
384 14. Factoring polynomials over finite fields
the set of kth roots of unity. Since Fq is a field, the polynomial xk − 1 ∈ Fq [x] has
at most k roots in Fq [x] (Lemma 25.4), and hence # ker σk ≤ k.
Since (bk )(q−1)/k = bq−1 = 1 for all b ∈ F× q , by Fermat’s little theorem 14.1,
we have S ⊆ ker σ(q−1)/k . By the same reasoning as above, this implies that #S ≤
(q − 1)/k. Now
q − 1 = #F×
q = # ker σk · # im σk = # ker σk · #S ≤ k · (q − 1)/k = q − 1,
by the homomorphism theorem for groups, and this implies that # ker σk = k, #S =
(q − 1)/k, and S = ker σ(q−1)/k . ✷
(i) S ⊆ F×
q is a (multiplicative) subgroup of order (q − 1)/2,
(ii) S = {a ∈ F×
q :a
(q−1)/2
= 1},
Now we want to factor a monic polynomial f ∈ Fq [x] with deg f = n, and have
a divisor d ∈ N of n so that each irreducible factor of f has degree d. There are
r = n/d such factors, and we can write f = f1 · · · fr with distinct monic irreduc-
ible f1 , . . . , fr ∈ Fq [x]. We may assume that r ≥ 2; otherwise, we know that f is
irreducible. Since gcd( fi , f j ) = 1 for i 6= j, we have the ring isomorphism of the
Chinese Remainder Theorem 5.3:
F qd ∼
= Ri = Fq [x]/h fi i ⊇ Fq .
We use the convention that for a ∈ Fq [x], we have a mod f ∈ R and χ(a mod f ) =
(a mod f1 , . . . , a mod fr ) = (χ1 (a), . . . , χr (a)), where χi (a) = a mod fi ∈ Ri . For
a ∈ Fq [x] and i ≤ r, we have that fi divides a if and only if χi (a) = 0. If we obtain
an a ∈ Fq [x] with some χi (a) equal to zero and others nonzero, then gcd(a, f ) is a
nontrivial divisor of f . We now describe a probabilistic procedure to find such a
splitting polynomial a.
14.3. Equal-degree factorization: Cantor and Zassenhaus’ algorithm 385
2. g1 ←− gcd(a, f )
if g1 6= 1 then return g1
4. g2 ←− gcd(b − 1, f )
if g2 6= 1 and g2 6= f then return g2 else return “failure”
T HEOREM 14.9.
Algorithm 14.8 works correctly as specified. It returns “failure” with probability
less than 21−r ≤ 1/2, where r = n/d ≥ 2, and takes O((d log q + log n)M(n)) or
O∼ (n2 log q) operations in Fq .
P ROOF. The failure probability has been given above as 21−r if gcd(a, f ) = 1. For
general a, where step 2 might find a factor, the failure probability is less than 21−r .
The cost for the gcds in steps 2 and 4 is O(M(n) log n), and computing b in step 3
takes at most 2 log2 (qd ) ∈ O(d log q) multiplications modulo f or O(M(n)d log q)
operations in Fq . ✷
The usual trick of running the algorithm k times makes the failure probability
less than 2(1−r)k ≤ 2−k .
386 14. Factoring polynomials over finite fields
g1 = gcd(a, f ) = gcd(x + 1, x4 + x3 + x − 1) = 1,
b = a4 rem f = (x + 1)4 rem x4 + x3 + x − 1 = −1,
g2 = gcd(b − 1, f ) = gcd(1, f ) = 1,
and this choice is unlucky. Our next random choice might be a = x. Then
g1 = gcd(a, f ) = gcd(x, x4 + x3 + x − 1) = 1,
b = a4 rem f = x4 rem x4 + x3 + x − 1 = −x3 − x + 1,
g2 = gcd(b − 1, f ) = gcd(−x3 − x, x4 + x3 + x2 − 1) = x2 + 1.
The latter is one irreducible factor of f , and the other one is f /(x2 +1) = x2 +x−1.
1
2
1
2
1
2
x+
x+
x+
x+
+
+
+
+
2x
2x
2x
2x
F IGURE 14.5: The lucky and unlucky choices for factoring x4 + x3 + x − 1 ∈ F3 [x].
Figure 14.5 illustrates the situation. On the left hand side, we have R = F[x]/h f i,
consisting of the 81 polynomials a3 x3 + a2 x2 + a1 x + a0 mod f , with all ai ∈ F3 .
The possible values for a1 x + a0 are along the horizontal axis, and similarly a3 x3 +
a2 x2 along the vertical axis. Our two choices are marked by a •.
We have R ∼ = F3 [x]/hx2 + 1i × F3 [x]/hx2 + x − 1i ∼ = F9 × F9 on the right hand
side, with the nine elements of the first factor on the horizontal axis, and the sec-
ond factor on the vertical axis. We have arranged our two copies of F9 in an
isomorphic way; in particular, mapping x mod x2 + 1 to x + 2 mod x2 + x − 1 gives
an isomorphism, since (x + 2)2 + 1 ≡ 0 mod x2 + x − 1. On both axes, we first
have 0, then the four nonzero squares, and then the four nonsquares.
The lucky choices of a are colored, the unlucky ones white. At right, it is
clear what happens: the 16 blue elements with exactly one coordinate 0 give a
14.3. Equal-degree factorization: Cantor and Zassenhaus’ algorithm 387
Algorithm 14.8 gives a factorization into two factors. If we need just one irre-
ducible factor, we can apply the algorithm recursively to the smaller factor (Exer-
cise 14.15). However, we will usually want all r factors, and this can be done by
running the algorithm recursively on each factor.
T HEOREM 14.11.
A squarefree polynomial of degree n = rd with r irreducible factors of degree d can
be completely factored with an expected number of O((d log q + log n)M(n) log r)
or O∼ (n2 log q) operations in Fq .
We now show that the expected depth of the tree is O(log r), which together
with r ≤ n implies the claims. Let 1 ≤ i < j ≤ r be fixed. Then in Algorithm 14.8,
the probability that a mod gi and a mod g j are neither both squares nor both non-
squares is at least 1/2, by the Chinese Remainder Theorem. Thus for each level
of the tree, the probability that a call to Algorithm 14.8 separates gi and g j at that
level is at least 1/2 (if they were not already separated before). Hence the prob-
ability that gi and g j are not yet separated at depth k is at most 2−k . This is true
for any pair of irreducible factors of f , and since there are (r2 − r)/2 ≤ r2 such
pairs, the probability pk that not all irreducible factors are separated at depth k is at
most r2 2−k . This is the probability that the depth of the tree is greater than k, and
pk−1 − pk is the probability that the depth is exactly k. Let s = ⌈2 log2 r⌉. Then the
expected depth of the tree is
∑ k(pk−1 − pk ) = ∑ pk = ∑ pk + ∑ pk ≤ ∑ 1 + ∑ r2 2−k
k≥1 k≥0 0≤k<s k≥s 0≤k<s k≥s
2 −s −k
= s+r 2 ∑2 ≤ s + 2 ∈ O(log r). ✷
k≥0
E XAMPLE 14.12. Suppose that we want to find all the irreducible factors fi of
f = f0 · · · f9 ∈ Fq [x], where the fi are monic, irreducible, pairwise distinct, and
have the same degree d.
0 (0123456789)
1 (0347) (125689)
5 (59)
6 (5) (9)
F IGURE 14.6: The workings of the equal-degree factorization algorithm 14.10 in Exam-
ple 14.12.
14.4. A complete factoring algorithm 389
When q is large enough, there is a way to replace almost all powerings with
exponent (qd − 1)/2 in step 3 of Algorithm 14.8 by cheaper powerings with expo-
nent (q − 1)/2, leading to an expected time of O(d M(n) log q + M(n) log(qn) log r)
operations in Fq for a variant of Algorithm 14.10 (Exercise 14.17).
f
1. h0 ←− x, v0 ←− , i ←− 0, U ←− Ø
lc( f )
repeat
2. i ←− i + 1
{ one distinct-degree factorization step }
call the repeated squaring algorithm 4.8 in R = Fq [x]/h f i to compute
hi = hqi−1 rem f
g ←− gcd(hi − x, vi−1 )
3. if g 6= 1 then
{ equal-degree factorization }
call Algorithm 14.10 with input g and i to compute the monic
irreducible factors g1 , . . . , gs ∈ Fq [x] of g
390 14. Factoring polynomials over finite fields
4. vi ←− vi−1
{ determine multiplicities }
for j = 1, . . . , s do
e ←− 0
vi
while g j | vi do vi ←− , e ←− e + 1
gj
U ←− U ∪ {(g j , e)}
5. until vi = 1
6. return U
T HEOREM 14.14.
Algorithm 14.13 correctly computes the irreducible factorization of f . If deg f = n,
then it takes an expected number of O(n M(n) log(qn)) or O∼ (n2 log q) arithmetic
operations in Fq .
P ROOF. Let f = lc( f ) ∏1≤i≤r fiei be the irreducible factorization of f , with distinct
monic irreducible polynomials f1 , . . . , fr ∈ Fq [x] and positive integers e1 , . . . , er .
We prove that the invariants
i
hi ≡ xq mod f , vi = lc( f ) ∏ fkek
deg fk >i
hold each time before the algorithm passes through step 2. The first invariant is
shown as in the proof of Theorem 14.4. The second one is clear for i = 0, and we
i
may assume that i ≥ 1. By Theorem 14.2, xq −x is the product of all distinct monic
irreducible polynomials in Fq [x] of degree dividing i, and hence in particular it is
squarefree. Thus, since vi−1 | f and by the induction hypothesis, the polynomial
i
g = gcd(hi − x, vi−1 ) = gcd(xq − x, vi−1 ) = ∏ fk
deg fk =i
of the algorithm, takes an expected number of O((i log q + log mi )M(mi ) log(mi /i))
operations, by Theorem 14.11. Now
log(mi /i)
i log(mi /i) = mi ≤ mi ,
mi /i
∑(i log q + log mi )M(mi ) log(mi /i) ≤ ∑(mi log q + log2 mi )M(n)
i i
∈ O(n M(n) log q),
where we have used ∑i mi ≤ n and log is the binary logarithm. If e j denotes the
multiplicity of g j in f , then one execution of the body of the for loop in step 4
takes O(e j M(n)) operations in Fq , and the overall cost for step 4 is O(n M(n))
operations, since the sum of the multiplicities of all irreducible factors of f is at
most n. The timing estimate for step 2 is dominant, and the claim follows. ✷
We note that this is the same time bound as for the distinct-degree factorization
algorithm 14.3 with a squarefree input.
i = 0: v0 = f
i = 1: g v1
i = 2: g
v2
g1 g2
We now have the central result of this chapter: a complete factorization algo-
rithm over finite fields in polynomial time. In the next sections, we study the
problem in greater depth, discussing different (and faster) algorithms and various
applications.
C OROLLARY 14.16.
Given f ∈ Fq [x] of degree n, we can find all roots of f in Fq using an expected
number of O(M(n) log n log(nq)) or O∼ (n log q) operations in Fq .
Algorithm 14.15 can be used to find all integral roots of a polynomial f ∈ Z[x]
in a modular fashion, as follows.
1. B ←− 2n(A2 + A)
let p ∈ N be an odd prime between B + 1 and 2B
2. call Algorithm 14.15 to find all distinct roots {u1 mod p, . . . , ur mod p} in
F p of f mod p, with ui ∈ Z and |ui | < p/2 for all i
T HEOREM 14.18.
Algorithm 14.17 correctly computes all integral roots of f . The cost for step 2 is
or O∼ (n log2 A) word operations, and the cost for step 3 per ui is O(n M(log(nA)))
or O∼ (n log A) word operations.
The cost for finding p is discussed in Section 18.4. In Section 15.6, we will
discuss a faster algorithm for computing integer roots.
1. u ←− gcd( f , f ′ )
f
2. return v = .
u
T HEOREM 14.20.
Algorithm 14.19 works correctly as specified and takes O(M(n) log n) operations
in F .
P ROOF. For the correctness, we note that each ei fi′ is nonzero, and by the above
u= ∏ fiei −1 , v= ∏ fi .
1≤i≤r 1≤i≤r
The running time estimate follows from Theorems 9.6 and 11.7. ✷
14.6. Squarefree factorization 395
Now g j divides each summand with i 6= j, and gcd(g j , g′j ) = gcd(g j , g/g j ) = 1
since F has characteristic zero and g j and g are squarefree. Thus the claim follows
from g
gcd(g j , h − cg′ ) = gcd g j , (c j − c)g′j = gcd(g j , c j − c). ✷
gj
T HEOREM 14.23.
The algorithm uses O(M(n) log n) operations in F and it computes correctly the
squarefree decomposition of f .
for 0 ≤ i ≤ m. This is clear for v1 , and the claim for w1 follows from
f v1
f′ = ∑ · jg′j = u ∑ j g′j .
1≤ j≤m g j 1≤ j≤m g j
For i ≥ 1, Lemma 14.22 gives hi = gi . Then vi+1 = ∏i< j≤m g j is clear, and
′ vi ′ vi
wi+1 = ∑ ( j − (i − 1))g j g j − ∑ g j g j /gi
i≤ j≤m i≤ j≤m
v i vi+1
= ∑ ( j − i)g′j = ∑ ( j − i)g′j .
i< j≤m g j gi i< j≤m gj
For the cost estimate, let d j = deg g j for 1 ≤ j ≤ m. Step 1 takes O(M(n) log n)
arithmetic operations. Moreover, deg vi = ∑i≤ j≤m d j , deg wi = (deg vi ) − 1, the gcd
computation in the ith loop takes O(M(deg vi ) log n), and the two division steps
O(M(deg vi )) operations in F. Using the superlinearity of M (Section 8.3), we find
∑ M(deg vi ) ≤ M ∑ deg vi = M ∑ j d
1≤i≤m 1≤i≤m 1≤i≤ j≤m
=M ∑ idi = M(n). ✷
1≤i≤m
E XAMPLE 14.24. Suppose that f = abc2 d 4 for monic distinct irreducible poly-
nomials a, b, c, d ∈ F[x]. Then Algorithm 14.21 computes u = gcd( f , f ′ ) = cd 3 ,
An interesting possibility may occur if char F = p for a prime p, which does not
happen if char F = 0: f = ∑0≤i≤n ai xi 6∈ F and f ′ = 0. This happens if and only if
each i with ai 6= 0 is divisible by p; then the summand i ai xi−1 is zero in F[x]. If
F = F p , then we can write
p
ip i
f= ∑ aip x = ∑ aip x , (3)
0≤i≤n/p 0≤i≤n/p
p
since (g + h) p = g p + h p for all g, h ∈ F p [x] and aip = aip for all aip ∈ F p (Sec-
tion 25.4). For example, (x4 + x2 + 1)′ = 0 in F2 [x], and x4 + x2 + 1 = (x2 + x + 1)2 .
Similarly, if F = Fq for a prime power q = ps and s ≥ 1, then Fermat’s little
s−1
theorem 14.1 says that aq = a for all a ∈ Fq , and hence a p = aq/p is a pth root
q/p
of a. Then for g = ∑0≤i≤n/p aip xi, we have f = g p, in analogy to (3). On the other
hand, if f = g p , then f ′ = pg p−1 g′ = 0, and thus
C OROLLARY 14.25.
Let F be a finite field or a field of characteristic zero and f ∈ F[x] nonconstant.
Then f is squarefree if and only if gcd( f , f ′ ) = 1.
Exercises 14.27 and 14.30 discuss squarefree factorization over finite fields.
398 14. Factoring polynomials over finite fields
1. γ0 ←− ξ , γ1 ←− ξ q , l ←− ⌈log2 d⌉
2. for i = 1, . . . , l do
call the fast multipoint evaluation algorithm 10.7 over R to compute
γ2i−1 + j = γ̌2i−1 (γ j ) for 1 ≤ j ≤ 2i−1
3. call the fast multipoint evaluation algorithm 10.7 over R to compute δk =
α̌(γk ) for 0 ≤ k ≤ d
4. return δ0 , . . . , δd
We note that the input ξ q is not required for the correctness of the algorithm, but
we need it for the running time bound.
T HEOREM 14.27.
Algorithm 14.26 works correctly as specified and uses O(M(n)2 log n log d) or
O∼ (n2 ) operations in Fq .
k
P ROOF. For the correctness, we prove the invariant γk = ξ q for 0 ≤ k ≤ 2i by
induction on i. The case i = 0 is clear from step 1. For the inductive step, it is
sufficient to prove the claim for k > 2i−1 . For 1 ≤ j ≤ 2i−1 , we have that
j
2i−1 q j 2i−1 + j
γ2i−1 + j = γ̌2i−1 (γ j ) = γ̌2i−1 (ξ q ) = (γ̌2i−1 (ξ ))q = γ2qi−1 = ξ q
j j
= ξq ,
by step 2, (5), (6), and the induction hypothesis. Finally, in step 3 we correctly
compute
k k k
δk = α̌(γk ) = α̌(ξ q ) = α̌(ξ )q = αq
for 0 ≤ k ≤ d.
By Corollary 10.8, the polynomials γ̌2i−1 and α̌ in R[x] of degree less than n can
be evaluated at no more than n ring elements using at most ( 11
2 M(n) + O(n)) log2 n
multiplications and additions in R. In steps 2 and 3 of Algorithm 14.26, we
solve l + 1 ∈ O(log d) such multipoint evaluation problems, at a total cost of
O(M(n) log n log d) operations in R, or O(M(n)2 log n log d) operations in Fq . ✷
operations in Fq are sufficient, but since this saves only factors log n when d = n,
we omit the proof.
The process of the iterated Frobenius algorithm can be illustrated as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ξq ...
|{z} | {z } | {z } | {z }
i=1 i=2 i=3 i=4
The ith brace encloses those powers of ξ that are newly computed in the ith iter-
ation of step 2. The advantage of the iterated Frobenius algorithm over the naïve
k
successive computation of the ξ q might be compared to the advantage of repeated
squaring for the computation of one power an over repeated multiplication.
Algorithm 14.26 can be used for distinct-degree factorization as well as for
equal-degree factorization. Remember that in Algorithm 14.3, we had to compute
i i
xq − x mod f = ξ q − ξ = γi − ξ
for 1 ≤ i ≤ n. This can be done by first computing ξ q using repeated squaring and
then applying steps 1 and 2 of the iterated Frobenius algorithm with d = n. The cost
for the other steps in the distinct-degree factorization algorithm is dominated by
the cost for the iterated Frobenius, and using (7), we have the following corollary.
C OROLLARY 14.28.
The distinct-degree decomposition of a squarefree polynomial f ∈ Fq [x] of degree
n can be computed using O(M(n2 ) log n + M(n) log q) or O∼ (n2 + n log q) opera-
tions in Fq .
d
In the equal-degree factorization of Algorithm 14.8, we compute α(q −1)/2 for a
uniform random element α ∈ R = Fq [x]/h f i, where d is the degree of any of the
irreducible factors of f . The exponent can be written as
qd − 1 q−1
= (qd−1 + qd−2 + · · · + q + 1) ,
2 2
and hence
d d−1
α(q −1)/2
= (α q · · · αq · α)(q−1)/2 = (δd−1 · · · δ1 · δ0 )(q−1)/2 ,
which can be computed using the iterated Frobenius algorithm, and repeated squar-
ing for the computation of the initial power ξ q and the final q−1
2 th power. Again
using (7), we have the following result.
C OROLLARY 14.29.
The complete factorization of a squarefree polynomial f ∈ Fq [x] of degree n = rd
with r irreducible factors of degree d can be computed using an expected number
of O((M(nd)r log d + M(n) log q) log r) or O∼ (n2 + n log q) operations in Fq .
14.8. Algorithms based on linear algebra 401
Similarly as for the equal-degree factoring algorithm 14.10, one finds a slightly
better estimate of O(M(nd)r log d + M(n) log r log q) arithmetic operations in Fq
(Exercise 14.17), or even O(M(nd)r + M(n) log q) for finding only one irreducible
factor. By replacing steps 2 and 3 in Algorithm 14.13 with the two algorithms
for distinct-degree and equal-degree factorization presented above, we obtain the
following result.
C OROLLARY 14.30.
A polynomial f ∈ Fq [x] of degree n can be completely factored with an expected
number of O(M(n2 ) log n + M(n) log n log q) or O∼ (n2 + n log q) operations in Fq .
R∼
= Fq [x]/h f1 i × · · · × Fq [x]/h fr i. (8)
As in Section 14.3, each Fq [x]/h fi i is a finite field with qdeg fi elements and contains
Fq as a subfield (the constant polynomials modulo fi ). Now for a ∈ Fq [x], we have
Fq [x]/h f2 i
Fq [x]/h f3 i
Fq [x]/h f1 i
Fq [x]/h fr i
Fq Fq Fq ... Fq B
Fq [x]/h f i
The matrix Q ∈ Fqn×n representing the Frobenius map σ with respect to the
polynomials basis xn−1 mod f , . . . , x mod f , 1 mod f of R was first used in Petr
(1937) for distinct-degree factorization, and has been a staple of computer algebra
since Berlekamp’s work. We will call it the Petr-Berlekamp matrix of f . Now
Berlekamp’s algorithm first determines a basis b1 mod f , . . . , br mod f of B using
Gaussian elimination on Q − I. We note that
Now we assume for simplicity that q is odd (see Exercise 14.16 for character-
istic 2), and let b = c1 b1 + · · · + cr br be a uniformly random linear combination
of basis elements, with c1 , . . . , cr ∈ Fq chosen independently, so that b mod f is
a uniform random element of B . We now employ the same (q − 1)/2 trick as
in the equal-degree factorization. The b mod fi are uniformly and independently
distributed random elements of Fq for 1 ≤ i ≤ r. Hence, if no fi divides b, then
b(q−1)/2 ≡ ±1 mod fi , and both possibilities occur with probability 1/2 and inde-
pendently for all i, by Lemma 14.7. This yields the following Las Vegas algorithm.
14.8. Algorithms based on linear algebra 403
5. g1 ←− gcd(a, f )
if g1 6= 1 and g1 6= f then return g1
7. g2 ←− gcd(b − 1, f )
if g2 6= 1 and g2 6= f then return g2 else return “failure”
T HEOREM 14.32.
Algorithm 14.31 works correctly as specified and returns “failure” with probability
at most 1/2. It uses O(nω + M(n) log q) operations in Fq if ω > 2.
P ROOF. Correctness is clear from the discussion preceding the algorithm. In order
to analyze the failure probability, we note that a is a uniformly random element
of B , so that ui ≡ a mod fi for 1 ≤ i ≤ r are independent random elements of Fq
(via its embedding in Fq [x]/h f i). If some ui is zero and some u j nonzero, a factor is
returned in step 5. With probability q−r , all ui ’s are zero. All ui ’s are nonzero with
(q−1)/2
probability (1 − q−1 )r , and then each vi = ui is 1 or −1 with probability 2−1
for either case, and all vi ’s are equal with probability 2 · 2−r . Thus failure occurs
404 14. Factoring polynomials over finite fields
in step 7 with probability t = q−r + (1 − q−1 )r · 2−r+1 < 2−1 , since r ≥ 2, the last
inequality holds for r = 2, and t is monotonically decreasing in r.
The cost for step 1 is O(M(n) log q) field operations. Step 2 uses n − 2 multi-
plications modulo f , or O(n M(n)) operations in Fq . The cost for step 3 is O(nω ),
by Section 12.1. This dominates the cost for step 2, the O(nr) field operations for
step 4, and the O(M(n) log n) for the gcds in steps 5 and 7. Finally, step 6 uses
another O(M(n) log q) field operations. ✷
4. g1 ←− gcd(a, f )
if g1 6= 1 and g1 6= f then return g1
5. call the repeated squaring algorithm 4.8 in R = Fq [x]/h f i to compute b =
a(q−1)/2 rem f
6. g2 ←− gcd(b − 1, f )
if g2 6= 1 and g2 6= f then return g2 else return “failure”
The analyses in Kaltofen & Lobo (1994) and Kaltofen & Shoup (1998) imply
the following.
T HEOREM 14.34.
Algorithm 14.33 works correctly as specified, returns “failure” with probability at
most 1/2 if q ≥ 4n, and takes O(M(n2 ) log n + M(n) log q) operations in Fq . If the
algorithm is used recursively to factor f completely, then the expected recursion
depth is O(log p n · log r), where p = char Fq and r is the number of irreducible
factors of f .
Figure 14.9 illustrates how the asymptotic running times of four factorization
algorithms depend on the relation between the two independent parameters n, the
degree of the input polynomial, and log2 q. The unit of time is log2 q bit opera-
tions, which is the cost of one operation in Fq . We ignore factors no(1) . The figure,
based on a similar one in Kaltofen & Shoup (1998), abstracts a three-dimensional
picture of the running time as a function of n and log2 q into a two-dimensional
figure with two logarithmic axes x and y, where log2 q and the time are about nx
and ny , respectively. The figure pictures Berlekamp’s classical algorithm 14.31, the
method of Cantor & Zassenhaus (Algorithms 14.3 and 14.10), the iterated Frobe-
nius algorithm of von zur Gathen & Shoup (Corollary 14.30), and the subquadratic
algorithm of Kaltofen & Shoup (1998), incorporating Huang & Pan’s (1998) fast
rectangular matrix multiplication. A derivation of the (rounded) numerical value
in Figure 14.9 for the latter is given in Notes 14.8. Huang & Pan (1998) present an-
other algorithm whose running time, corresponding to x+1.80535, beats the others
for x ≤ 0.00173; its graph is virtually indistinguishable for these small values from
the lower left segment. Finally, Kedlaya & Umans (2009) have applied their fast
modular composition algorithm, mentioned at the end of Section 12.2, to obtain
a factoring algorithm using an expected number of O(n1.5+o(1) log q + n log2 q) of
bit operations. They achieve this by moving out of the algebraic model of us-
ing only operations in Fq . Their operations count amounts to about n1.5 + n log q
Fq -equivalent operations. Each of these six algorithms is asymptotically faster
than previously known methods for some choices of n and q.
Computationally, (fast) polynomial factorization over a finite field is a much
more advanced task than, for example, multiplication or even gcd computation.
406 14. Factoring polynomials over finite fields
y Berlekamp (1970)
Cantor & Zassenhaus (1981)
time ∈ O∼ (ny ) von zur Gathen & Shoup (1992)
Kaltofen & Shoup (1998)
Kedlaya & Umans (2009)
2.6
2.4 y = 2.376
2
x+
y=
2.2
6 y=2
1.80
1
2.0
x+
6x +
0.41
y=
y=
1.8
y = 1.5 log2 q = nx
1.5
x
0.0 0.5 1.0 1.376
C OROLLARY 14.35.
A polynomial f ∈ Fq [x] of degree n ≥ 1 is irreducible if and only if
n
(i) f divides xq − x, and
n/t
(ii) gcd(xq − x, f ) = 1 for all prime divisors t of n.
14.9. Testing irreducibility and constructing irreducible polynomials 407
multiplication
explicit
linear algebra
division with remainder
miminal polynomial
black box
linear algebra iterated
Cantor & Frobenius
Zassenhaus
Niederreiter Berlekamp
P ROOF. It follows immediately from Theorem 14.2 that f satisfies the two condi-
tions if it is irreducible. Conversely, if (i) holds, then Theorem 14.2 implies that
the degree of any irreducible factor of f divides n. Let g be such an irreducible
factor, and suppose that d = deg g < n. Then d divides n/t for some prime factor t
n/t
of n, and hence g | xq − x. This contradicts (ii), and we conclude that d = n and
f is irreducible. ✷
4. return “irreducible”
408 14. Factoring polynomials over finite fields
T HEOREM 14.37.
Algorithm 14.36 correctly decides whether the input polynomial is irreducible. It
can be implemented so as to use O(M(n) log q + (n(ω+1)/2 + n1/2 M(n))δ (n) log n)
or O∼ (n(ω+1)/2 + n log q) operations in Fq .
P ROOF. Correctness follows from Corollary 14.35. The cost for computing xq rem
m
f in step 1 is O(M(n) log q) field operations. To compute sm = xq rem f for some
m ∈ N, we employ the polynomial representation (6) of the Frobenius map, noting
that
i+ j
i q j j j
xq mod f = ξ q = si (ξ )q = si (ξ q ) = si (s j (ξ )) = si (s j ) mod f
m
for all i, j. Thus xq rem f can be computed from xq rem f in a “repeated squaring”
fashion along the binary representation of m, taking O(log m) modular composition
steps of the form si (s j ) rem f . By Theorem 12.4, this can be done at a total cost of
O((n(ω+1)/2 + n1/2 M(n)) log m) operations in Fq , dominating the cost for the gcd
in step 3. The total number of times we have to compute some sm is 1 + δ (n), and
the claim follows since m ≤ n in all those cases. ✷
With the current world record ω < 2.373 (Section 12.1), we have (ω + 1)/2 <
1.687. The iterated Frobenius algorithm for distinct-degree factorization can be
used for testing irreducibility and takes O∼ (n2 + n log q) operations in Fq (Corol-
lary 14.28). A third irreducibility test (for a squarefree polynomial) is given by (9);
it is sufficient to compute the rank of Q − I, taking O(nω + M(n) log q) field oper-
ations.
Comparing the three tests and using classical matrix arithmetic, where ω = 3, the
first two give the same soft-Oh estimate n2 + n log q, but the Oh-bound shows that
the test 14.36 is faster: n2 δ (n) log n versus M(n2 ) log n, for small q. The n3 estimate
for the third method is in a different league. When we take ω < 3, say ω = 2.373
(Section 12.1), then the estimate for Algorithm 14.36 shrinks to only O∼ (n1.687 +
n log q). The run time of a method by Kedlaya & Umans (2009) corresponds, as
explained at the end of the previous section, to only n1.5+o(1) + O∼ (n log q) opera-
tions in Fq .
Now that we know how to test a polynomial for irreducibility, it is natural to
ask how to find irreducible polynomials. This is used to construct finite extension
fields of finite fields and in modular algorithms. The following result tells us how
frequently irreducible polynomials occur among arbitrary polynomials.
14.9. Testing irreducibility and constructing irreducible polynomials 409
L EMMA 14.38. Let q be a prime power and n ∈ N≥1 . Then the number I(n, q) of
monic irreducible polynomials of degree n in Fq [x] satisfies
qn − 2qn/2 qn
≤ I(n, q) ≤ .
n n
In particular, if qn ≥ 16, then the probability pn for a uniformly random monic
polynomial of degree n to be irreducible satisfies
1 1 2 1
≤ 1 − n/2 ≤ pn ≤ .
2n n q n
qn/2+1 − 1
∑ deg fd ≤ ∑ deg fd ≤ ∑ qd < ≤ 2qn/2 ,
d|n, d<n 1≤d≤n/2 1≤d≤n/2
q−1
1 I(n, q) 1 1
≥ ≥ (1 − 2q−n/2 ) ≥
n qn n 2n
In fact, the probability is close to 1/n when qn is not too small. The precise
formula n
n · I(n, q) = ∑ µ qd
d|n
d
410 14. Factoring polynomials over finite fields
can be found by using a well-known number theoretic tool called Möbius inver-
sion (Exercise 14.46). Here
1 if n = 1,
µ(n) = (−1)k if n is the product of k distinct primes, (11)
0 if n is not squarefree,
is the Möbius function, defined for positive integers n. The first few values of
µ are listed in Section 17.4. Table 14.11 tabulates the values of I(n, q) for some
small values of n and q.
n q=2 q=3 q=4 q=5 q=7 q=8 q=9
2 1 3 6 10 21 28 36
3 2 8 20 40 112 168 240
4 3 18 60 150 588 1008 1620
5 6 48 204 624 3360 6552 11 808
6 9 116 670 2580 19 544 43 596 88 440
7 18 312 2340 11 160 117 648 299 592 683 280
8 30 810 8160 48 750 720 300 2 096 640 5 380 020
9 56 2184 29 120 217 000 4 483 696 14 913 024 43 046 640
10 99 5880 104 754 976 248 28 245 840 107 370 900 348 672 528
C OROLLARY 14.39.
For a prime power q and n ∈ N>0 , one can find a uniformly random irreducible
polynomial of degree n in Fq [x] using an expected number of
O(n M(n) log q + (n(ω+3)/2 + n3/2 M(n))δ (n) log n) or O∼ (n(ω+3)/2 + n2 log q)
operations in Fq .
The exponent (ω + 3)/2 is less than 2.688 for the smallest currently known ω .
The following alternative method is somewhat faster.
2. for i = 1, . . . , ⌊n/2⌋ do
i
gi ←− gcd(xq − x, f ), if gi 6= 1 then goto 1
3. return f
By Theorem 14.4, step 2 can be performed with O∼ (n2 log q) field operations,
and Lemma 14.38 would imply a total cost of O∼ (n3 log q), but the following anal-
ysis shows that the actual cost is lower by about one order of magnitude. We state
the following property without proof.
L EMMA 14.41. Let q be a prime power and n ∈ N>0 . The expected value of
the degree of the smallest irreducible factor of a uniformly random polynomial of
degree n in Fq [x] is O(log n).
T HEOREM 14.42.
Ben-Or’s algorithm 14.40 works correctly as specified and takes an expected num-
ber of O(n M(n) log n log(nq)) or O∼ (n2 log q) operations in Fq .
C OROLLARY 14.43.
For a prime power q and n ∈ N, we can construct the extension field Fqn of Fq
using an expected number of O(n M(n) log n log(nq)) or O∼ (n2 log q) operations
in Fq .
For the big prime modular gcd algorithm 6.28 in Fq [x, y], we have to find an
irreducible polynomial which does not divide some unknown resultant r ∈ Fq [y],
on which only a degree bound deg r ≤ m is known.
412 14. Factoring polynomials over finite fields
C OROLLARY 14.44.
Let n ∈ N, q be a prime power, and r ∈ Fq [y] nonzero of degree at most m. Then
we can compute a uniformly random irreducible polynomial f ∈ Fq [y] of degree n
taking O(n M(n) log n log(nq)) or O∼ (n2 log q) operations in Fq , and f does not
divide r with probability at least 1/2 if qn ≥ 2m.
P ROOF. The cost estimate is from Theorem 14.42. There are I(n, q) irreducible
polynomials of degree n, and at most ⌊m/n⌋ of them divide r. Thus the probability
that f does not divide r is
jmk
I(n, q) −
n ≥ 1− m · n = 1− m ,
I(n, q) n qn qn
Φn = ∏ (x − ω ) = ∏ (x − e2πik/n ) ∈ C[x]
ω ∈C primitive 1≤k<n
nth root of unity gcd(k,n)=1
Lemma 14.47 below implies that Φn has coefficients in Z. Table 14.12 lists the
first 20 cyclotomic polynomials. We have deg Φn = ϕ(n), where ϕ is Euler’s totient
function (Section 4.2).
xn − 1 = ∏ Φd . (12)
d|n
P ROOF. Let ω ∈ C be a zero of xn −1, that is, an nth root of unity. Then ord(ω ) = d
for some divisor d of n, by Lagrange’s theorem (Section 25.1). But this means that
14.10. Cyclotomic polynomials and constructing BCH codes 413
n Φn n Φn
1 x−1 11 x10 + x9 + · · · + x + 1
2 x+1 12 x4 − x2 + 1
3 x2 + x + 1 13 x12 + x11 + · · · + x + 1
4 x2 + 1 14 x6 − x5 + x4 − x3 + x2 − x + 1
5 x4 + x3 + x2 + x + 1 15 x8 − x7 + x5 − x4 + x3 − x + 1
6 x2 − x + 1 16 x8 + 1
7 x6 + x5 + x4 + x3 + x2 + x + 1 17 x16 + x15 + · · · + x + 1
8 x4 + 1 18 x6 − x3 + 1
9 x6 + x3 + 1 19 x18 + x17 + · · · + x + 1
10 x4 − x3 + x2 − x + 1 20 x8 − x6 + x4 − x2 + 1
As examples, we have
Φn = ∏(xd − 1)µ(n/d)
d|n
(x6 − 1)(x − 1)
Φ6 = x2 − x + 1 = .
(x3 − 1)(x2 − 1)
1. f0 ←− x − 1
fi−1 (x pi )
2. for i = 1, . . . , r do fi ←−
fi−1
T HEOREM 14.49.
Algorithm 14.48 uses O(M(n) log n) arithmetic operations in Z and correctly com-
putes the nth cyclotomic polynomial.
Φn = ∏ (x − ω )
ω ∈E primitive
nth root of unity
holds over any extension E of F containing a primitive nth root of unity, and that
Φn is irreducible over Q (so that (12) is the irreducible factorization of xn − 1
over Q). The following lemma says that the latter is not true over finite fields.
14.10. Cyclotomic polynomials and constructing BCH codes 415
P ROOF. First we note that d | ϕ(n) = #Z× n , by Lagrange’s theorem. Now n divides
qd − 1 = #F×
qd
, and hence F q d contains a primitive nth root of unity ω (Lemma 8.8).
We choose such an ω , and let f ∈ Fq [x] be the unique irreducible factor of Φn
i
that has ω as a root. Since f (xq ) = f (x)q , the element ω q is a root of f for all
i ∈ N. Now 1, q, q2 , . . . , qd−1 are distinct modulo n, the order of ω in F× qd
, and
2 d−1
hence {ω , ω q , ω q , . . . , ω q } are d distinct roots of f . Thus deg f ≥ d. On the other
hand, we have Fq [x]/h f i ∼ = Fq (ω ) ⊆ Fqd (Section 25.3), whence deg f ≤ d. Thus
deg f = d, and since the choice of ω was arbitrary, this is true for all irreducible
factors of Φn . ✷
For example, the order of 3 modulo 8 is 2, and in fact Φ8 splits into two irreduc-
ible factors of degree 2 over F3 : x4 + 1 = (x2 + x − 1)(x2 − x − 1).
E XAMPLE 14.51. We take q = 2 and n = 15. Then d = ord15 (2) = 4. The poly-
nomial x15 − 1 factors in F2 [x] as
x15 − 1 = Φ15 Φ5 Φ3 Φ1
= (x8 − x7 + x5 − x4 + x3 − x + 1)(x4 + x3 + x2 + x + 1)(x2 + x + 1)(x − 1)
= (x4 + x + 1)(x4 + x3 + 1)(x4 + x3 + x2 + x + 1)(x2 + x + 1)(x + 1).
As predicted by Lemma 14.50, Φ15 splits into two irreducible factors of degree 4,
and Φ5 , Φ3 , and Φ1 remain irreducible. Let β ∈ F16 be a root of x4 + x + 1. Then
β is a primitive 15th root of unity. The roots of the minimal polynomial x4 + x + 1
of β are β , β 2 , β 4 , β 8 .
For i ∈ Z, β i is a primitive lth root of unity, where l = ord(β i ) = n/ gcd(n, i)
(Exercise 8.13). We have ord(β 3 ) = 15/ gcd(3, 15) = 5, so that β 3 is a primitive
5th root of unity. Now ord5 (2) = 4, so that the minimal polynomial of β 3 has pre-
cisely the four roots β 3 , β 6 , β 12 , β 24 = β 9 . Similarly, ord(β 5 ) = 3 and ord3 (2) = 2,
whence β 5 is a primitive third root of unity and its minimal polynomial only has
the two roots β 5 , β 10 . ✸
i ∼ j ⇐⇒ ∃l ∈ Z: iql = j. (13)
n , then the equivalence class of i is the cyclotomic coset i · hqi of the cyclic
If i ∈ Z×
subgroup hqi of Z× n . If d = ordn (q) and β ∈ Fqd is a primitive nth root of unity,
416 14. Factoring polynomials over finite fields
then the powers β i and β j have the same minimal polynomial if and only if i ∼ j,
as in the example.
Lemma 14.50 implies that cyclotomic polynomials can be directly factored over
finite fields using equal-degree factorization, without performing either squarefree
or distinct-degree factorization. The cost is O∼ (n2 + n log q) operations in Fq or
O∼ (n2 log q + n log2 q) word operations if p ∤ n. Exercise 14.47 yields an even
faster algorithm for factoring xn − 1, taking only O∼ (n log2 q) word operations,
which can be modified so as to work for Φn as well. When p divides n, we have
p
Φn = Φn/p in Fq [x].
In Chapter 7, we discussed a class of cyclic codes that are of importance in
modern coding theory, the BCH codes. For a finite field Fq , a primitive nth root of
unity β ∈ Fqd in some extension field of Fq , and a positive integer δ , BCH(q, n, δ )
is the cyclic code (that is, the ideal) in Fq [x]/hxn − 1i generated by g mod xn − 1,
where g ∈ Fq [x] is the least common multiple of the minimal polynomials of
β , β 2 , . . . , β δ−1 over Fq . We now show how to compute such a generator poly-
nomial g.
4. compute β 2 , β 3 , . . . , β δ−1
5. for k = 1, . . . ,t do
i ←− min Sk , m ←− #Sk
compute β 2i , . . . , β (2m−1)i
use Exercise 12.10 to compute the minimal polynomial gk ∈ Fq [x]
of β i
6. return g1 · · · gt
g = g1 g2 g3 = x10 + x8 + x5 + x4 + x2 + x + 1 ∈ F2 [x]
T HEOREM 14.53.
Algorithm 14.52 works correctly as specified and takes O(M(nd)(n/d) log n +
M(n) log q) or O∼ (n2 + n log q) operations in Fq , where d = ordn (q).
Notes. The pioneering works for this area of computer algebra are those of Berlekamp
(1967, 1970), Zassenhaus (1969), and Cantor & Zassenhaus (1981).
14.2 and 14.3. The distinct-degree factorization of Section 14.2 appears in Zassenhaus
(1969), Kempfert (1969), Knuth (1998), already in the 1969 edition, Berlekamp (1970),
and Cantor & Zassenhaus (1981); the latter also contains the equal-degree factorization of
Section 14.3.
Actually the basic algorithms go back almost two centuries. Gauß’ Disquisitiones Gen-
erales de Congruentiis were to appear as Part 8 of his Disquisitiones Arithmeticae, but did
not make it (see page 372). Written in 1797 or 1798, but not quite polished to the Mas-
ter’s usual high gloss, his hand-written notes were published in his Nachlass (Gauß 1863a,
1863b). In article 370, Gauß writes: Sit itaque X functio, quae nullos amplius divisores
418 14. Factoring polynomials over finite fields
1 Let X be a polynomial that has no further multiple divisors. We have seen above that x p − x is the product of
all irreducible polynomials of degree one. If ξ is the greatest common divisor of the polynomials X and x p − x,
then ξ will be the product of all divisors of X of degree one, and X/ξ will not have such factors any more. But
if it is found that the polynomials X and x p − x are coprime, then X will have no divisor of degree one and hence
2
the congruence X ≡ 0 will have no real [integer] roots. Moreover, since x p − x is the product of all irreducible
′ p 2
polynomials of degrees two or one, the greatest common divisor ξ of x − x and X/ξ will contain all divisors of
X of degree two. Continuing from here, one sees that X will be factored in this manner into factors ξ, ξ ′ , ξ ′′ etc.,
which contain all [irreducible] divisors of degree one, two, three etc., respectively.
2 We do not want to expand on this question, since a skilled calculator, well versed in these principles, will easily
find special tricks when needed.
3 One expands [. . . ] x(A−1)/2 in powers of x less than xn , and sets this value equal to 1 and to −1. [. . . ]
Whenever the original equation has roots of both types [both squares and nonsquares], say p of the first type,
satisfying x(A−1)/2 = 1 and q of the other type, satisfying x(A−1)/2 = −1, the separation of these types is achieved
by the preceding method. [. . . ] One can set x = y ± k, k being arbitrary, and solve the equation in y by the same
principles.
Notes 419
The history of factorization algorithms involves many more people; see the references
in the surveys of Kaltofen (1982, 1990, 1992) and von zur Gathen & Panario (2001), and in
Shparlinski’s (1992, 1999) treatises. Other early algorithms are by Prange (1959), Lloyd
(1964), Lloyd & Remmers (1966), and Willett (1978). The survey by Slisenko (1981)
mentions unpublished algorithms by Skopin and Faddeev, apparently found in the late
1960s.
If each deg gi in Algorithm 14.3 is 0 or i, then the distinct-degree factorization is already
the complete factorization of f . How often does this happen? We consider monic random
polynomials in Fq [x] of degree n. Then, when n is fixed and q −→ ∞, the probability goes
to e−γ ≈ 56% for large n, and for q fixed and n −→ ∞, this probability tends to a limit cq ,
with 66.56% ≈ c2 > cq > e−γ for all q ≥ 3. This was shown by Flajolet, Gourdon & Pa-
nario (2001) (Theorem 4.1), who give further results on the distribution of factor degrees
of random polynomials and the average case analysis of factoring algorithms. Similar and
related results are in Knopfmacher & Knopfmacher (1993), Knopfmacher (1995), Knopf-
macher & Warlimont (1995), Gourdon (1996), Gao & Panario (1997), Panario (1997),
Panario, Gourdon & Flajolet (1998), Panario & Richmond (1998), and Panario & Viola
(1998).
Gourdon (1996), Panario (1997), and Panario, Gourdon & Flajolet (1998) give results
about the distributions of the degrees of the largest and the second largest irreducible factor
of a random polynomial in Fq [x].
In general, an isomorphism between finite fields Fq ∼ = F p [x]/h f i and Fq ∼
= F p [x]/hgi,
where f , g ∈ F p [x] are irreducible of degree n and q = pn , can be obtained by mapping x
mod f to a root of f in F p [x]/hgi. Lenstra (1991) shows that such an isomorphism can
even be constructed in deterministic polynomial time.
d−1 d−2 d−1
Instead of the norm N(α) = αq +q +···+1, one can also use the trace T (α) = αq +
d−2
αq + · · · + α in equal-degree factorization; see McEliece (1969), Berlekamp (1970),
Camion (1981, 1982, 1983), and von zur Gathen & Shoup (1992). Both functions have the
crucial property that N(α), T (α) ∈ Fq for all α ∈ Fqd . The trace also works in characteris-
tic 2 (Exercise 14.16) where it is more tricky to apply the norm for factoring.
14.6. Gauß (1863b), article 368, basically describes the squarefree part algorithm 14.19,
but does not deal with the difficulty when the characteristic divides all exponents (and
the editor Dedekind repeats the incorrect statement). Lagrange (1769), §15, notes that
f / gcd( f , f ′ ) has the same roots as f , but each with multiplicity one (over C).
Algorithm 14.21 is from Yun (1976). For a random polynomial in Fq [x] of degree n, the
expected degree of the squarefree part is asymptotically about n − 1/q (Flajolet, Gourdon
& Panario 2001, Theorem 2.1).
We have already noted that (4), saying that a polynomial with vanishing derivative over a
finite field of characteristic p > 0 is a pth power, is not true for arbitrary fields of character-
istic p. In fact, over sufficiently bizarre (but still “computable”) fields it is undecidable—in
the sense of Turing—whether a polynomial is squarefree or not (von zur Gathen (1984a),
based on van der Waerden (1930a) and Fröhlich & Shepherdson (1955–56)). Van der
Waerden’s result is of particular interest because he has to assume explicitly that an unde-
cidable problem—an “ignorabimus”—exists (this was proven by Turing later in 1937) and
because Hilbert’s (1930) article in the same volume of the Mathematische Annalen ends
with Hilbert’s credo: In der Mathematik gibt es kein ignorabimus.4
4 There is no undecidable problem in mathematics.
420 14. Factoring polynomials over finite fields
14.7. The iterated Frobenius algorithm is from von zur Gathen & Shoup (1992), where the
estimate (7) is proven in their Theorem 3.2. This is also used in Kedlaya & Umans (2009).
14.8. The first pioneering random polynomial-time algorithms, based on linear algebra,
are due to Berlekamp (1967, 1970). The matrix Q was already used by Petr (1937) who
determined the characteristic polynomial of Q − I and gave a distinct-degree factorization
method using Q as representing the Frobenius automorphism. Schwarz (1939, 1940, 1956,
1960, 1961) and Butler (1954) used Q in various algorithms, for example to compute the
number of factors of a given degree. Camion (1980) coined the term Berlekamp algebra
for the kernel of β.
Berlekamp (1970) introduced the (q − 1)/2 trick into modern polynomial factorization;
Legendre already stated it in 1785.
A different linear algebra based method for factoring polynomials in Fq [x] was devel-
oped by Niederreiter (1993a, 1993b, 1994a), Göttfert (1994), and Niederreiter & Göttfert
(1993, 1995); see Niederreiter (1994b) for an overview. The method turned out to be
closely related to Berlekamp’s algorithm. Gao & von zur Gathen (1994) showed how to
combine it with Wiedemann’s method. The special case where q is prime is discussed in
Exercise 14.42. Gao (2003) extends Niederreiter’s method to bivariate polynomials over a
finite field.
Kaltofen & Shoup (1998) have found clever improvements to the factorization methods
in this chapter that yield algorithms whose dependence on the degree of the polynomial
to be factored is less than quadratic, namely O(n1.815 (log q)0.407 ) operations in Fq . For
practical purposes, they recommend a O∼ (n2.5 + n log q) version of their method.
As Kaltofen and Shoup say in their “Note added in proof”, their estimates can be im-
proved slightly by combining them with the fast rectangular matrix multiplication algo-
rithm of Huang & Pan (1998). This does not require any new algorithmic idea. As it is
not in the literature, we briefly explain such an improvement, assuming familiarity with
both papers. Theorem 10.2 of Huang & Pan gives an upper bound on ω(1, 1, r), which
is defined so that an n × n times n × nr matrix product can be calculated with O(nω(1,1,r) )
arithmetic operations. This bound contains two parameters l and b. We set l = 7 and
b = −0.00191r + 0.03551 in their bound and obtain a function ϕ(r) with ω(1, 1, r) ≤ ϕ(r).
Then one verifies that ϕ(r) ≤ 0.95732r + 1.42261 for 1.36437 ≤ r ≤ 1.67555. In Lemma 3
of Kaltofen & Shoup (1998), the dominating cost is a t × t times t × t r matrix multiplica-
tion (more exactly, its transpose) with t = n1/r and r = 1/(1 − β/2), for a parameter β.
The cost for their algorithm is then O∼ (nω(1,1,r)/r + n1+β +x ), where x = logn log2 q, as in
Figure 14.9. Using fast square matrix multiplication and the Coppersmith & Winograd
exponent, we have ω(1, 1, r) ≤ r − 1 + ω(1, 1, 1) ≤ r + 1.375477. Equating the two expo-
nents of n yields the value of β which minimizes the cost and provides the upper bound
of 0.407x + 1.815 given in Kaltofen & Shoup (1998). Substituting the better linear bound
on ω(1, 1, r) for fast rectangular matrix multiplication from above and equating exponents,
we find the upper bound 0.41565x + 1.80636, as in Figure 14.9. The required values of r
all lie within the interval given above.
This estimate is not the best that one can get from the methods of Kaltofen & Shoup
and Huang & Pan, but it is not clear to us how to obtain a simple explicit description of
the running time that results from combining these methods in an optimal way. We do not
claim that calculations as the above are of much value for practical purposes.
For large fields of small characteristic, say F2k , Kaltofen & Shoup (1997) present even
faster solutions by applying variants of the iterated Frobenius algorithm 14.26 over the
Notes 421
prime field. The natural cost measure now is to count word operations; as an example, they
achieve O(n(log q)1.687 ) word operations when k = ⌈n1.5 ⌉.
14.9. The worst-case and average upper bounds on δ(n) are in Hardy & Wright (1985),
§22.10. An exact formula for I(n, q) and the approximation qn /n are in Gauß (1863b),
articles 344–347; the slightly sharper bound
qn q(qn/2 − 1) qn − q
− ≤ I(n, q) ≤
n (q − 1)n n
for n ≥ 2 is in Lidl & Niederreiter (1997), Theorem 3.25 and Exercises 3.26 and 3.27.
Algorithm 14.36 is due to Rabin (1980b), and Algorithm 14.40 to Ben-Or (1981). Lemma
14.41 was stated in Ben-Or (1981) and is proven in the solution to Exercise 7.32 of Bach &
Shallit (1996). Panario & Richmond (1998) give a precise analysis of the implied constant.
The expected minimal degree has a large variance, namely about cn for some constant
c ≈ 0.5568. Shepp & Lloyd (1966) proved a similar result about permutations, namely that
the expected length of the shortest cycle of a random permutation on n letters is O(log n).
Panario & Viola (1998) give an analysis of Rabin’s algorithm. The estimate of the prob-
ability that a random polynomial over a finite field with no small factors is irreducible is
from Gao & Panario (1997).
Galois (1830) proposed a probabilistic approach to finding irreducible polynomials over
finite fields; see the quote at the beginning of this chapter. The asymptotically fastest
method for computing irreducible polynomials is in Shoup (1994), using O∼ (n2 + n log q)
operations in Fq .
Further notes. The central open question in the theory of factoring polynomials over finite
fields is: can this be done in deterministic polynomial time? We recall that the distinct-
degree algorithm 14.3 is deterministic, but the equal-degree algorithm 14.10 is probabilis-
tic. Thus we may assume f ∈ Fq [x] to be equal-degree. Berlekamp (1970) significantly
simplified the problem: we may assume that q is a prime, and that f has only linear factors
(see Exercise 14.40). Thus the question is the following:
Several special cases have been solved: when p − 1 has only small prime factors (so
that p − 1 is smooth, see Section 19.5) (Moenck 1977a, von zur Gathen 1987, Mignotte &
Schnorr 1988), when Φk (p) is smooth for some cyclotomic polynomial Φk ∈ Z[y] (Bach,
von zur Gathen & Lenstra 2001), when f is cyclotomic when considered in Q[x] or, more
generally, has commutative Galois group (Huang 1985, Rónyai 1989), or when n is small
(Rónyai 1988). The most general result is Evdokimov’s (1994) algorithm with an almost
polynomial number of word operations (nlog n log p)O(1) . All these results assume the Ex-
tended Riemann Hypothesis (ERH; see Notes 18.4). Irreducible polynomials can be com-
puted in deterministic polynomial time under the ERH (Adleman & Lenstra 1986). Shoup
(1990) and Lange & Winterhof (2000) present deterministic polynomial-time algorithms
which factor almost all polynomials.
We stress that a solution of this interesting problem is unlikely to affect the practice of
factoring, since there the probabilistic algorithms are just fine.
422 14. Factoring polynomials over finite fields
Exercises.
14.1 (i) Let Fq be a finite field with q elements. Prove Wilson’s theorem ∏a∈F×q a = −1. Hint:
Every a ∈ F×q different from ±1 has a
−1 6= a.
(ii) Prove a converse of Wilson’s theorem: If n is an integer such that (n − 1)! ≡ −1 mod n, then n
is prime.
2
14.2 Suppose p ≥ 5 is a prime, f ∈ F p [x] has degree 4, and gcd(x p − x, f ) = gcd(x p − x, f ) = 1.
What can you say about the factorization of f in F p [x]?
14.3 Trace Algorithm 14.3 on computing the distinct-degree decomposition of the squarefree poly-
nomial
Tell from the output only how many irreducible factors of degree i the polynomial f has, for all i.
14.4 Let q ∈ N be a prime power.
(i) Use Theorem 14.2 to prove that if r is a prime number, then there are (qr − q)/r distinct monic
irreducible polynomials of degree r in Fq [x]. (Observe that, by Fermat’s little theorem 4.9, (qr − q)/r
is an integer.)
(ii) Now suppose that r is a prime power. Find a simple formula for the number of monic irreduc-
ible polynomials of degree r over Fq .
14.5 Let p ∈ N be a prime and f ∈ Z[x] monic of degree n. Prove that the congruence f (a) ≡ 0
mod p has n solutions a ∈ Z p if and only f mod p is a factor of x p − x; that is, if and only if
x p − x = f q + pr, where q and r have integral coefficients, and where r is a polynomial of degree less
than n.
14.6∗ Let q be a prime power and f ∈ Fq [x] squarefree of degree n.
(i) Prove that for 1 ≤ a ≤ b ≤ n, the polynomial
d
gcd ∏ (xq − x), f
a≤d<b
is the product of all monic irreducible factors of f whose degree divides some number in the interval
{a, a + 1, . . ., b − 1}.
qb qb−d
(ii) Determine gcd ∏ (x − x ), f .
a≤d<b
(iii) Consider the following blocking strategy for distinct degree factorization. We partition the set
{1, . . ., n} of possible degrees of irreducible factors of f into k intervals I1 = {c0 = 1, 2, . . ., c1 − 1},
I2 = {c1 , c1 + 1, . . ., c2 − 1}, . . ., Ik = {ck−1 , ck−1 + 2, . . ., ck − 1 = n}, with integers 1 = c0 < c1 <
c2 < · · · < ck = n + 1. Describe an algorithm which, on input f , computes the polynomials g1 , . . ., gk
such that g j is the product of all monic irreducible factors of f with degree in the interval I j , for
1 ≤ j ≤ k.
14.7 Show that −1 is a square in F×
q for an odd prime power q if and only if q ≡ 1 mod 4.
(v) Modify Berlekamp’s algorithm 14.31 so as to work for q = 2k , by computing b = Tk (a) rem f
in step 6. Prove that the modified algorithm fails with probability at most 1/2, and that its running
time is the same as that of the original algorithm.
14.17∗∗ The aim of this exercise is to reduce the expected cost estimate for equal degree factoriza-
tion from O((d log q + log n)M(n) log r) field operations, as shown in Theorem 14.9 and the discus-
sion following it, to O(d log q · M(n) + log(qn)M(n) log r).
Let q be an odd prime power and f ∈ Fq [x] squarefree of degree n with r ≥ 2 irreducible factors
f1 , . . ., fr of degree d = n/r. We let R, R1 , . . ., Rr and the Chinese remainder isomorphism χ =
χ1 × · · · × χr : R −→ R1 × · · · × Rr be as in Section 14.3. The norm on Ri ∼ = Fqd is defined by
2 d−1 d
N(α) = ααq αq · · ·αq = α(q −1)/(q−1), and we use the same formula to define the norm on R.
(i) Let α ∈ R× be a uniform random element, β = N(α), and 1 ≤ i ≤ r. Show that χi (β) is a root of
q−1 − 1, and conclude that χi (β) is a uniform random element in F×
x q . Hint: N is a homomorphism
of multiplicative groups.
(ii) Provided that q > r, what is the probability that the χi (β) are distinct for 1 ≤ i ≤ r? Prove that
this probability is at least 1/2 if q − 1 ≥ r2 .
(iii) For u ∈ Fq , let π(u) = u(q−1)/2 , so that π(u) ∈ {−1, 0, 1}, π(u) = 0 if and only if u = 0, and
π(u) = −1 if and only if u is a nonsquare. Moreover, let u, v ∈ Fq be distinct. Prove that for a
uniformly random t ∈ Fq , we have π(u + t) 6= π(v + t) with probability at least 1/2. Hint: The map
t 7−→ (u + t)/(v + t) if t 6= −v and −v 7−→ 1 is a bijection of Fq .
(iv) Consider the following variant of Algorithm 14.8, due to Rabin (1980b).
A LGORITHM 14.54 Equal-degree splitting.
Input: A squarefree monic reducible polynomial f ∈ Fq [x] of degree n, where q is an odd prime
power, a divisor d < n of n, so that all irreducible factors of f have degree d, and a ∈ Fq [x] of
degree less than n with χi (a mod f ) ∈ Fq for all i.
Output: A proper monic factor g ∈ Fq [x] of f , or “failure”.
1. g1 ←− gcd(a, f )
if g1 6= 1 and g1 6= f then return g1
2. choose t ∈ Fq at random
3. call the repeated squaring algorithm 4.8 in R = Fq [x]/h f i to compute b = (a +t)(q−1)/2 rem f
4. g2 ←− gcd(b − 1, f )
if g2 6= 1 and g2 6= f then return g2 else return “failure”
Use (iii) to prove that the failure probability of the algorithm is at most 1/2 if a 6∈ Fq .
(v) Use the algorithm from (iv) as a subroutine to create a recursive algorithm for equal-degree
factorization, which has the same input specification as the above algorithm and outputs all irreduci-
ble factors of f . The value of a is passed to the recursive calls. Prove that the algorithm never halts
if χi (a mod f ) = χ j (a mod f ) for some i 6= j, and that otherwise, if all χi (a mod f ) are distinct ele-
ments of Fq , the probability for its recursion depth to be more than k = 1 + ⌈2 log2 r⌉ is at most 1/2.
Conclude that in the latter case, the number of operations in Fq is O(M(n) log(qn) log r).
d
(vi) Now we first compute a = c(q −1)/(q−1) rem f for a uniform random polynomial c ∈ Fq [x] of
degree less than n, and then call the algorithm from (v) for that value of a and stop the recursion at
depth k. We assume that q − 1 ≥ r2 . Prove that with probability at least 1/4, this method yields the r
irreducible factors of f in time O(d M(n) log q + M(n) log(qn) log r).
14.18−→ Use Algorithm 14.13 to factor the polynomial x6 + x3 + x2 + x + 1 ∈ F2 [x] into irreducible
factors. Show all your steps.
14.19 Let F be a field and f ∈ F[x] with f (0) 6= 0. We recall rev( f ) = f ∗ = xdeg f f (1/x), the
reversal (or reciprocal polynomial) of f (Section 9.1). We say that f is self-reciprocal if f = f ∗ .
Exercises 425
(i) Show that ∗ is multiplicative, so that ( f g)∗ = f ∗ g∗ for all g ∈ F[x] with g(0) 6= 0.
(ii) Prove that f (α−1 ) = 0 ⇐⇒ f ∗ (α) = 0, for all α ∈ F. Conclude that the set of zeroes of f is
closed under inversion if f is self-reciprocal.
(iii) Show that every self-reciprocal polynomial f of odd degree satisfies f (−1) = 0.
(iv) Let f ∈ F[x] with f (0) 6= 0 be self-reciprocal and g ∈ F[x] an irreducible factor of f . Then
also g∗ is an irreducible factor of f .
(v) The squarefree polynomial f = (x21 + 1)/(x + 1) ∈ F2 [x] has—among others—the following
irreducible factors: x2 + x + 1, x3 + x + 1, and x6 + x4 + x2 + x + 1. What are the others?
14.20∗ Let f ∈ Fq [x] of degree n be given, and for a ∈ Fq , let Ba = {b ∈ Fq : f (b) = a} be the set of
preimages of a under the mapping b 7−→ f (b) induced by f .
(i) Given a, show how to compute ∏b∈Ba (y − b) ∈ Fq [y] with O(M(n) log(qn)) operations in Fq .
(ii) Given a, show how to compute probabilistically Ba with O(M(n) log n log(qn)) operations
in Fq .
(iii) If the function corresponding to f is bijective (so that #Ba = 1 for all a ∈ Fq ), then f is called
a permutation polynomial. Use Exercise 14.11 to derive a criterion when f = xn is a permutation
polynomial.
(iv) If f is not a permutation polynomial, then in fact
1
#{a: Ba 6= Ø} = # im f ≤ q 1 −
n
(Wan 1993; a weaker result is in von zur Gathen 1991b). Use this fact to derive a probabilistic (Monte
Carlo) test for permutation polynomials, taking O(n M(n) log(qn)) operations in Fq .
14.21 Let f ∈ Z[x] be of degree n and max-norm || f ||∞ = A, and f = (ux+v)g, with nonzero u, v ∈ Z
and g = ∑0≤i<n gi xi ∈ Z[x].
(i) Prove that |gi | ≤ (i + 1)A/|v| for 0 ≤ i < n − 1 if |u| = |v|, and conclude that then ||g||∞ ≤ nA.
(ii) Now assume that α = |u/v| < 1. Show that |gi | ≤ A(1 − αi+1 )/(1 − α)|v| for 0 ≤ i < n − 1,
and conclude that ||g||∞ ≤ A. Prove that the latter also holds if |u/v| > 1.
14.22 (i) Use the Leibniz rule to prove (2).
(ii) Conclude that f / gcd( f , f ′ ) = ∏ei fi′ 6=0 fi .
14.23 Prove or disprove:
(i) The polynomial x1000 + 2 ∈ F5 [x] is squarefree.
(ii) Let F be a field and f , g ∈ F[x]. Then the squarefree part of f g is the product of the squarefree
parts of f and of g.
14.24 (Yun 1977b) Over a field F of characteristic zero, Algorithm 14.19 reduces the problem of
computing the squarefree part of a polynomial to a gcd computation.
(i) Show that conversely computing a gcd of two squarefree polynomials f , g ∈ F[x] can be reduced
to computing the squarefree part of a certain polynomial.
(ii) Let f , g ∈ F[x] be monic nonconstant, with squarefree decompositions f = ∏1≤i≤m fii and
g = ∏1≤i≤k gii . Show that gcd( f , g) = ∏1≤i≤min{m,k} gcd( fi · · · fm , gi · · ·gk ), and conclude from (i)
that computing gcd’s can be reduced to computing squarefree decompositions.
14.25 Test the following polynomials for multiple factors in Q[x].
(i) x3 − 3x2 + 4, (ii) x3 − 2x2 − x + 2.
14.26 Let F be a field of characteristic zero, f ∈ F[x] monic nonconstant of degree n, f = g1 g22 · · ·gm
m
its squarefree decomposition, v = g1 · · ·gm , u = f /v, and w = f ′ /u.
v
(i) Show that gcd( f , f ′ ) = u and w = ∑ ig′i . Hint: Exercise 14.22.
1≤i≤m g i
426 14. Factoring polynomials over finite fields
14.34 Let Fq be a finite field with q elements, f ∈ Fq [x] nonconstant, and ξ = xq mod f ∈ R =
ˇ
Fq [x]/h f i. Prove or disprove that αq = ξ(α) for all α ∈ R.
14.35∗ Find “small” constants c1 , c2 ∈ Q such that the running time of the iterated Frobenius algo-
rithm 14.26 is at most (c1 n/d + c2 )M(d) log2 d + O(M(d) + n log d) additions and multiplications in
R when n and d are powers of 2. Hint: Exercise 10.2.
14.36∗ Let q be a prime power, f ∈ Fq [x] of degree n, and R = Fq [x]/h f i.
d−1
(i) Consider the following algorithm for computing the norm Nd (α) = ααq · · ·αq for α ∈ R and
a power of two d < n.
A LGORITHM 14.55 Norm computation.
Input: f ∈ Fq [x] of degree n, a power of two d ∈ N with d ≤ n, ξ q ∈ R = Fq [x]/h f i, where ξ = x
mod f ∈ R, and α ∈ R.
Output: Nd (α) ∈ R.
1. γ0 ←− ξ q , δ0 ←− ξ, l ←− log2 d
2. for i = 1, . . ., l do
call the modular composition algorithm 12.3 to compute γi = γ̌i−1 (γi−1 ) and
δ̌i−1 (γi−1 )
δi ←− δi−1 · δ̌i−1 (γi−1 )
3. return δl
Prove that the algorithm works correctly and takes O((n(ω+1)/2 + n1/2 M(n)) log d) operations
in Fq . Compare this to the time for computing the norm by employing the iterated Frobenius algo-
rithm 14.26.
(ii) Modify the algorithm so as to also work when d is not necessarily a power of two.
d−1
(iii) Design a similar algorithm for computing the trace Td (α) = α + αq + · · · + αq of α ∈ R.
14.37 Let q be a prime power, f = f1 · · · fr ∈ Fq [x] squarefree, with monic irreducible and pairwise
coprime f1 , . . ., fr ∈ Fq [x], and B ⊆ Fq [x]/h f i the Berlekamp algebra of f . Prove that the “Lagrange
interpolants” l1 , . . ., lr ∈ Fq [x] of degree less than deg f and with li ≡ 0 mod f j if j 6= i and li ≡ 1
mod fi are a basis of B.
14.38∗ Let f = f1 · · · fr ∈ F2 [x] be squarefree of degree n, with f1 , . . ., fr ∈ F2 [x] monic irreducible
and pairwise coprime, B ⊆ F2 [x]/h f i its Berlekamp algebra, and b1 mod f , . . ., br mod f a basis
of B, with all bi ∈ F2 [x] of degree less than n.
(i) Show that for 1 ≤ i ≤ r with at most one exception, there exist indices j, k such that fi | b j and
f i ∤ bk .
(ii) Let f = g1 · · ·gs be a partial factorization of f , with all g j monic nonconstant and pairwise
coprime, and 1 ≤ i ≤ r. Use Exercise 11.4 to show that
g1 gs
gcd(bi , g1 ), , . . ., gcd(bi , gs ),
gcd(bi , g1 ) gcd(bi , gs )
can be computed using O(M(n) log n) operations in F2 (we call this a refinement with bi ).
(iii) Show that by successively refining partial factorizations of f with b1 , . . ., br , starting with the
trivial factorization f = f , we obtain all irreducible factors of f in time O(r · M(n) log n).
14.39∗ Let p ∈ N be prime and q = pk for some positive k ∈ N, f ∈ Fq [x] monic squarefree of
degree n, and R = Fq [x]/h f i. We may replace the Frobenius endomorphism α 7−→ αq of R over Fq
in Berlekamp’s algorithm 14.31 by the absolute Frobenius endomorphism α 7−→ α p of R over the
prime field F p . Analyze this variant and compare its expected running time to that of the original
algorithm.
428 14. Factoring polynomials over finite fields
14.40∗ It is clear that finding roots of polynomials is a special case of factoring polynomials. This
exercise shows conversely how factoring over a finite field can be reduced to root finding over the
prime field. Let q = pk be a prime power for some positive k ∈ N, f ∈ Fq [x] monic squarefree
of degree n, R = Fq [x]/h f i, and B = {a mod f ∈ R: a p ≡ a mod f } ⊆ R the absolute Berlekamp
subalgebra (see Exercise 14.39).
(i) Let b ∈ Fq [x] such that b mod f ∈ B. Prove that f = ∏ gcd( f , b − a).
a∈F p
(ii) Let y be a new indeterminate and r = resx ( f , b − y) ∈ Fq [y]. Show that r has some roots in F p ,
and that any root of r in F p leads to a nontrivial factor of f if b 6∈ F p .
(iii) Give a deterministic polynomial-time reduction from factoring in Fq [x] to root finding in F p [x].
14.41∗ Let q be a prime power, f ∈ Fq [x] monic squarefree of degree n, and R = Fq [x]/h f i, as usual.
(i) Show that if f splits into r irreducible factors of degrees d1 , . . ., dr , then lcm{xdi − 1: 1 ≤ i ≤ r}
is the minimal polynomial of the matrix Q representing the Frobenius endomorphism α 7−→ αq on R.
Hint: Start with r = 1. Conclude that f is irreducible if and only if the minimal polynomial of Q is
xn − 1.
(ii) Use (i) and Exercise 12.15 to design a Monte Carlo test whether f is irreducible. Your test
should take O(n · M(n) logq) operations in Fq if q is “large enough”.
14.42∗∗ This exercise discusses the easiest case of another factoring method based on linear algebra,
due to Niederreiter (see Notes 14.8). Let p ∈ N be prime.
(i) Prove that for all rational functions h ∈ F p (x), the (p − 1)st derivative h(p−1) is a pth power.
(ii) Show that for any nonzero polynomial f ∈ F p [x], the rational function h = f ′ / f ∈ F p (x) is a
solution of the differential equation
h(p−1) + h p = 0. (14)
Hint: Prove this first when f is squarefree, using Exercise 9.27 over the splitting field of f , and
Wilson’s theorem (Exercise 14.1). For the general case, employ the squarefree decomposition of f
and Exercise 9.27.
(iii) Prove that if h = g/ f ∈ F p (x) satisfies (14), with nonzero coprime f , g ∈ F p [x] and f monic,
then deg g < deg f and f is squarefree.
(iv) Let f , g be as in (iii) and λ1 , . . .λn ∈ E the (distinct) roots of f in a splitting field E of f
over F p . By partial fraction decomposition, there exist d1 , . . ., dn ∈ E such that
g di
= ∑ .
f 1≤i≤n x − λi
Show that y = di /(x − λi ) solves (14) for 1 ≤ i ≤ n. (Hint: Uniqueness of partial fraction decompo-
sition). Prove that di = dk ∈ F p if λi and λk are roots of the same irreducible factor in F p [x] of f , and
conclude that
g f j′
= ∑ cj
f 1≤ j≤r fj
for some c1 , . . ., cr ∈ F p , where f1 , . . ., fr are the distinct monic irreducible factors of f .
(v) Let f ∈ F p [x] be monic of degree n with the factorization f = f1e1 · · · frer into irreducible factors,
and
g
N = {g ∈ F p [x]: deg g < n and h = satisfies (14)}.
f
Prove that f1′ f / f1 , . . ., fr′ f / fr is a basis of N as a vector space over F p .
(vi) Now let f be squarefree and B ⊆ F p [x]/h f i the Berlekamp algebra of f . Prove that the map
ϕ: N −→ B with ϕ(g) = g · ( f ′ )−1 mod f is a vector space isomorphism. Hint: Consider ϕ(g)
mod f j for all j.
Exercises 429
(vii) Assume that p > 2. Let f as in (vi), g = ∑1≤ j≤r c j f j′ f / f j ∈ N with all ci ∈ F p , and S ⊆ F×
p
the set of squares. Show that
gcd(g(p−1)/2 − ( f ′ )(p−1)/2 , f ) = ∏ f j,
c j ∈S
and conclude that this gcd is nontrivial with probability at least 1/2 if c1 , . . ., cr are chosen uniformly
at random in F p and gcd( f , g) = 1.
14.43∗∗ This exercise turns the theory from Exercise 14.42 into an algorithm for p = 2. Let f =
∑0≤i≤n fi xi ∈ F2 [x] be monic squarefree of degree n.
(i) Prove that N = {g ∈ F2 [x]: deg g < n and ( f g)′ = g2 }.
1/2
(ii) Let N ∈ F2n×n be the matrix of the linear operator g 7−→ ( f g)′ on the vector space of all
polynomials in F2 [x] of degree less than n with respect to the polynomial basis xn−1 , xn−2 , . . ., x, 1,
so that
!2 gn−1 hn−1
∑ hi xi ⇐⇒ N · ... = ... .
( f ∑ gi xi )′ =
0≤i<n 0≤i<n
g0 h0
Prove that
fn 0 0 0 0 0 ···
fn−2
fn−1 fn 0 0 0 ···
N = fn−4 fn−3 fn−2 fn−1 fn 0 ··· .
.. ..
. .
(iii) Design an algorithm for factoring f by determining a basis of N − I, where I is the n × n
identity matrix, and using an analog of Exercise 14.38. Prove that it takes O(nω ) operations in F2 ,
like Berlekamp’s algorithm.
14.44∗ Let q be a prime power, t ∈ N a prime divisor of q − 1, and a ∈ F× q.
(i) Show that the polynomial xt − a ∈ Fq [x] splits into linear factors if a is a tth power Hint: Use
Lemma 8.8.
(ii) Show that xt − a is irreducible if a is not a tth power Hint: Use (i) for the splitting field of xt − a
and consider the constant coefficient of a hypothetical factor f ∈ Fq [x] of xt − a.
(iii) Derive a formula for the probability that a random binomial xt − a (that is, for random a ∈ F× q)
is irreducible, and compare it to the probability that a random polynomial of degree t in Fq [x] is
irreducible.
14.45 Prove Lemma 14.47.
14.46 This exercise discusses a useful tool from number theory: Möbius inversion. Let the Möbius
function µ be defined as in (11).
(i) Prove that µ is multiplicative, so that µ(mn) = µ(m)µ(n) whenever m, n ∈ N>0 are coprime.
(ii) Show that ∑d|n µ(d) = 0 if n > 1, where the sum is over all positive divisors of n.
(iii) Let R be an arbitrary ring (commutative, with 1) and f , g: N>0 −→ R be two functions such
that
f (n) = ∑ g(d) for n ∈ N>0 .
d|n
Prove that
n n
g(n) = ∑ µ f (d) = ∑ µ(d) f for n ∈ N>0 .
d|n
d d|n
d
430 14. Factoring polynomials over finite fields
(ii) Give an algorithm which computes all irreducible factors of the polynomial xn − 1 in Fq [x]
using O(log q log n + n M(log n)) word operations and an expected number of O(M(n) log(qn) log r)
field operations in Fq , in total O∼ (n log2 q) word operations. Hint: Use the method of Exercise 11.4
to split factors already found and perform a similar analysis as in the proof of Theorem 14.11.
Research problems.
14.48 Find a deterministic polynomial-time algorithm for computing a root of a squarefree polyno-
mial f ∈ F p [x] which divides x p − x, where p is a prime number. (Exercise 14.40 implies that then
the general problem of factoring polynomials can be solved in deterministic polynomial time.)
14.49 Allowing probabilistic algorithms using only operations in Fq , show that Ω(n log q) oper-
ations are required to factor a polynomial of degree n in Fq [x]. This corresponds to the diagonal
y = x + 1 in Figure 14.9.
The operation of factoring [polynomials]
must be performed by inspection.
Charles Davies (1867)
1 All the effects of nature are only mathematical results of a small number of immutable laws.
15
Hensel lifting and factoring polynomials
In this chapter, we present two modular algorithms for factoring in Q[x] and F[x, y]
for a field F. The first one uses factorization modulo a “big” prime and is concep-
tually easier, and the second one uses factorization modulo a “small” prime and
then “lifts” it to a factorization modulo a power of that prime. The latter is compu-
tationally faster and comprises our most powerful employment of the prime power
modular approach introduced in Chapter 5.
433
434 15. Hensel lifting and factoring polynomials
part of f . Thus
factoring in Z[x] ←→ factoring in Q[x] plus factoring in Z.
The best known algorithms for factoring in Z (Chapter 19) are much less efficient
than those for Q[x] that we present in this and the next chapter. From now on,
“factoring in Z[x]” will usually refer to primitive polynomials, for which the part
“factoring in Z” is trivial.
The basic idea of the factoring algorithm is as follows. Let f ∈ Z[x] be a prim-
itive polynomial to be factored. Using the squarefree part algorithm 14.19 if nec-
essary, we may assume that f is squarefree. We take a “big” prime p ∈ Z not
dividing the leading coefficient of f and such that f mod p ∈ F p [x] is squarefree
(we will make precise later what “big” means). Using one of the (probabilistic)
algorithms in Chapter 14, we factor f modulo p. If g ∈ Z[x] is a factor of f and
g1 , . . . , gs are the irreducible factors of g modulo p, then we can recover g from
them. If f factors as f = f1 · · · fk in Z[x], then also f = f1 · · · fk in Z p [x], where the
bar means taking each coefficient modulo p. But if the true factor f1 is irreducible,
then f1 need not be irreducible, and our factorization modulo p will return all the
irreducible modular factors of all fi , but we will not immediately know which of
them belong together (see Figure 15.2).
The following questions arise if we want to turn this sketch into an algorithm.
◦ How large do we have to choose p so that we can recover the coefficients of
any factor from its image modulo p? The answer has already been given by
Mignotte’s bound 6.33 in Section 6.6.
◦ In what range do we have to choose a random p so that f mod p is squarefree
with sufficiently high probability? The answer to this question is provided
by the resultant theory from Chapter 6 and the prime number theorem in
Chapter 18.
◦ Finally, the trickiest question is: how can we find the modular factors of f
mod p that correspond to a true factor of f in Z[x]? Very easy: we simply try
all possible factor combinations. Unfortunately, this leads to an exponential
algorithm in the worst case; examples are given by the Swinnerton-Dyer poly-
nomials in Section 15.3. In Chapter 16, we present a method to circumvent
this: short vectors in lattices.
Our algorithms consist of two stages: a modular factorization stage, where we
take either a single big prime or a prime power as modulus, and a second stage
where we try to find true factors from modular ones, either by factor combination
or with the aid of short vectors in lattices. This is illustrated in Figure 15.1; each
of the two variants in the top row may be freely combined with each of the two
methods in the bottom row. The next section describes the “big prime” and “factor
combination” stages, Sections 15.4 and 15.5 the “prime power” approach, and
“short vectors” are treated in Chapter 16.
15.2. A factoring algorithm 435
modular
big prime prime power
factorization
❄ ✙ ❥ ❄
finding
factor combination short vectors
factors
A closer look at the Sylvester matrix shows that lc( f ) divides res( f , f ′ ) (Ex-
ercise 6.41). Hence f is squarefree if p does not divide res( f , f ′ ) ∈ Z \ {0}; the
resultant is nonzero because f is squarefree.
f =
≡ mod p
f = f1 · · · fk = lc( f )g1 · · · gr
lc( f )
f1 ≡ lc( f ) ∏ gi mod p. (1)
lc( f1 ) i∈S
If p/2 is larger than the Mignotte bound (n + 1)1/2 2n | lc( f )| · || f ||∞ , then the coef-
ficients of lc( f ) f1 / lc( f1 ) are integers less than p/2 in absolute value, by Corol-
lary 6.33, and the polynomials in (1) are equal if we use symmetric representatives
between −(p − 1)/2 and (p − 1)/2 for the elements of F p . Therefore we can
construct f1 from the gi ’s and S.
Unfortunately, there seems to be no easy way to find the set S: in Figure 15.2,
we are only given the boxes in the lower row, but do not know which ones have
the same color. Trying all subsets of {1, . . . , r} leads to the following algorithm.
For compatibility with later algorithms, it has no step numbered 4. We recall
the max-norm || f ||∞ = maxi | fi | and the one-norm || f ||1 = ∑i | fi | of a polynomial
f = ∑i fi xi ∈ Z[x].
1. if n = 1 then return { f }
b ←− lc( f ), B ←− (n + 1)1/2 2n Ab
2. repeat
choose a random odd prime number p with 2B < p < 4B
f ←− f mod p
′
until gcd( f , f ) = 1 in F p [x]
3. { modular factorization }
compute g1 , . . . , gr ∈ Z[x] of max-norm less than p/2 that are nonconstant,
monic, and irreducible modulo p, such that f ≡ bg1 · · · gr mod p
5. { initialize the index set T of modular factors still to be treated, the set G of
factors found, and the polynomial f ∗ still to be factored }
T ←− {1, . . . , r}, s ←− 1, G ←− Ø, f ∗ ←− f
6. { factor combination }
while 2s ≤ #T do
15.2. A factoring algorithm 437
T HEOREM 15.3.
Algorithm 15.2 works correctly. If β = log B, then β ∈ O(n + log A), and the
expected cost of steps 2 and 3 is
O β 2 M(β ) log β + (M(n2 ) + M(n)β ) log n · M(β ) log β or O∼ (n3 + log3 A)
P ROOF. By Lemma 15.1, f mod p is squarefree in step 3, since p > B implies that
p ∤ b.
We show first that the condition in step 9 is true if and only if g∗ h∗ = b f ∗ . If
the latter holds, then ||g∗ ||1 ||h∗ ||1 ≤ B, by Corollary 6.33. Conversely, let g∗ and h∗
be as in step 8. Then g∗ h∗ ≡ b f ∗ mod p. Now ||g∗ h∗ ||∞ ≤ ||g∗ h∗ ||1 ≤ ||g∗ ||1 ||h∗ ||1 ≤
B < p/2 implies that both sides of the congruence have coefficients less than p/2
in absolute value, and hence they are equal.
For a factor u ∈ Z[x] of f , we denote by µ(u) the number of monic irreducible
factors which divide u modulo p; since F p [x] is a UFD, these factors form a subset
of {g1 , . . . , gr }. We show by induction that the invariants
By Mignotte’s bound 6.33, the coefficients of lc(h)g and lc(g)h are at most B <
p/2 in absolute value. Since also ||g∗ ||∞ , ||h∗ ||∞ < p/2, we have lc(h)g = g∗ ,
lc(g)h = h∗ , g∗ h∗ = b f ∗ , and the condition in step 9 is true for that particular
subset S of T . This contradiction shows that f ∗ has no irreducible factor g with
µ(g) = s, and step 10 guarantees that the invariants hold again at the next pass
through step 6.
It remains to show that f ∗ is irreducible if 2s > #T in step 6. Let g ∈ Z[x] be
an irreducible factor of f ∗ and h = f ∗ /g. By (2), we have s ≤ µ(g), µ(h) ≤ #T if
h is nonconstant. But µ(g) + µ(h) = #T , and s > #T /2 implies that h = ±1 and
f ∗ = ±g is irreducible.
For the running time estimate, we first note that b ≤ || f ||∞ = A, and hence
β ∈ O(n + log A). In Section 18.4, we show that a random prime as required in
step 2 can be found by a probabilistic algorithm using O(β 2 M(β ) log β ) word op-
erations, and that p ∤ disc( f ) with probability at least 1/2 (Corollary 18.12). Hence
the expected number of iterations of step 2 is at most two. The cost for the gcd is
O(M(n) log n) arithmetic operations in F p or O(M(n) log n M(β ) log β ) word oper-
ations. Thus the expected cost of step 2 is O((β 2 + M(n) log n)M(β ) log β ) word
operations. By Corollary 14.30, step 3 can be done with O((M(n2 )+M(n)β ) log n)
arithmetic operations in F p . Each of these in turn takes O(M(β ) log β ) word oper-
ations, by Corollary 11.13, and the expected number of word operations for step 3
is O((M(n2 ) + M(n)β ) log n · M(β ) log β ).
Computing g∗ and h∗ in step 8 can be done with O(M(n) log n) additions and
multiplications modulo p, by Lemma 10.4, or O(M(n) log n M(β )) word opera-
tions. The primitive parts in step 9 can be computed with at most n gcds of integers
absolutely bounded by B, or O(n M(β ) log β ) word operations. This has to be done
k ≤ n many times. Between two subsequent times that the condition in step 9 is
true, there are at most 2#T executions of step 8. Now #T decreases by at least one
if the condition is true, and hence the total number of iterations of step 8 is at most
∑ 2i ≤ 2r+1 ≤ 2n+1 . ✷
1≤i≤r
15.2. A factoring algorithm 439
We now trace steps 8 and 9 for two specific subsets S ⊆ {1, . . . , 4}. It turns out that
the condition in step 9 is false for all subsets S ⊆ {1, . . . 4} of cardinality s = 1, and
f ∗ = f has no linear factor. For s = 2 and S = {1, 2}, we compute
in step 8. Obviously ||g∗ ||1 ||h∗ ||1 ≥ ||g∗ ||∞ ||h∗ ||∞ = 1863 · 1289 > B in step 9, and in
fact g∗ h∗ 6= b f ∗ , which can be seen by comparing the constant coefficients
in step 8, ||g∗ ||1 ||h∗ ||1 = 10 · 21 < B in step 9, and in fact g∗ h∗ = b f ∗ , so that
pp(g∗ ) = 3x2 + x + 1 and pp(h∗ ) = 2x2 + x + 4 are the irreducible factors of f
in Z[x]. ✸
Before computing g∗ and h∗ in step 8, one will test first whether the constant
coefficients of g∗ h∗ and b f ∗ are equal (unless f (0) = 0, which can be ruled out in
advance), as in Example 15.4. They can be computed with at most r multiplica-
tions of integers of absolute value at most B or O(r · M(n+log A)) word operations,
which is much faster than the worst case bound for steps 8 and 9 in the theorem.
In practice, most unsuccessful g∗ and h∗ already fail this simple test. Instead of
multiplying with b, we might also compute the monic associates of g∗ and h∗ by
rational number reconstruction (Section 5.10). If the constant coefficient of f is
smaller than b, then exchanging the roles of the leading and the constant coeffi-
cient decreases the required size of p. These remarks also apply to the prime power
algorithms 15.19 and 15.22 below and the corresponding algorithms in Chapter 16.
To factor an arbitrary polynomial f ∈ Z[x], we might apply Algorithm 15.2 to
the squarefree part h/ gcd(h, h′ ) ∈ Z[x] of h = pp( f ) and afterwards determine the
440 15. Hensel lifting and factoring polynomials
1. c ←− cont( f ), g ←− pp( f )
if lc( f ) < 0 then c ←− −c, g ←− −g
3. G ←− Ø
for i = 1, . . . , s do
5. return c and G
in F p [x]. The computational difficulty is that some fi mod p may not be irreducible
in F p [x], and that the factor combination stage may have to try exponentially many
combinations of the irreducible factors that were computed modulo p.
An example of a “bad” polynomial is the ith Swinnerton-Dyer polynomial
√ √ √ √
f = ∏(x ± 2 ± 3 ± 5 ± · · · ± pi ) ∈ Z[x],
where pi is the ith prime and the product runs over all 2i possible combinations of
+ and − signs. It follows from Galois theory that f is an irreducible polynomial
i
of
√ degree 2 in √ Z[x]. But since for any prime p, F p2 contains all the square roots
2 mod p, . . . , pi mod p, the reduction of f modulo p splits into linear factors
over F p2 . Hence the irreducible factors of f mod p in F p [x] are either all linear
(namely, if 2, 3, . . . , pi are squares modulo p) or all quadratic, if p does not divide
the discriminant of f (Exercise 15.8), and there are at least 2i−1 = n/2 of them,
where n = 2i is the degree of f . Then the factorization algorithm 15.2 will run
through about 2n/4 sets S before it is finally able to decide that f is irreducible.
Other examples of “bad” polynomials are the cyclotomic polynomials Φn , which
are irreducible over Q but split modulo each prime for most n (Exercise 15.7).
The Swinnerton-Dyer polynomials and the cyclotomic polynomials make the
factor combination stage work really hard. But is that typical? For example, we
have used the fact that squarefree polynomials “usually” remain squarefree mod-
ulo a prime. Can we hope that “usually” an irreducible polynomial in Z[x] remains
irreducible modulo a prime? The answer is no, and the powerful theorems of Fro-
benius (1896) and Chebotarev (1926) give precise information. Their explanation
requires some concepts not used elsewhere in this text; the background and a proof
can be found in Stevenhagen & Lenstra (1996).
So we have a primitive polynomial f ∈ Z[x] of degree n, irreducible over Q. We
let G be the Galois group of the splitting field of f over Q. Each automorphism in
G is a permutation of the n roots of f and has a unique decomposition into disjoint
cycles, say of lengths λ1 , . . . , λr . Then λ1 + · · · + λr = n, so that λ = (λ1 , . . . , λr )
is a partition of n. For an arbitrary partition λ of n, we let Hλ ⊆ G be the set of
those automorphisms that have cycle decomposition λ. Thus µ(λ) = #Hλ /#G is
the relative frequency with which the cycle type λ occurs in G.
442 15. Hensel lifting and factoring polynomials
f1 = x4 − 6x3 − 5x2 + 8,
f2 = x4 + x3 + x2 + x + 1,
√ √
f3 = x4 − 10x2 + 1 = ∏(x ± 2 ± 3)
in Q[x]. The first one f1 was chosen at random from the monic polynomials in Z[x]
with coefficients absolutely less than 10, f2 = Φ5 is the 5th cyclotomic polynomial,
and f3 is a Swinnerton-Dyer polynomial. With appropriate numberings of the
roots of f1 , f2 , f3 , their Galois groups are Gal( f1 ) = S4 , the full symmetric group
on four letters, Gal( f2 ) = h(1234)i ∼ = Z4 , the cyclic group with four elements, and
Gal( f3 ) is Klein’s group V4 ∼ = Z2 × Z2 . The partitions of 4, that is, the possible
cycle types of automorphisms of f1 , f2 , f3 , are (1, 1, 1, 1), (2, 1, 1), (2, 2), (3, 1),
and (4). For each of the three polynomials and each cycle type λ, Table 15.3 lists
the automorphisms of type λ in the Galois group. The fractions in bold are the
relative frequencies. ✸
cycle type f1 f2 f3
1 1 1
(1, 1, 1, 1) id id id
24 4 4
(12), (13), (14), 6
(2, 1, 1)
(23), (24), (34) 24
(12)(34), (13)(24), 3 1 (12)(34), (13)(24), 3
(2, 2) (13)(24)
(14)(23) 24 4 (14)(23) 4
(123), (124), (132), 8
(3, 1) (134), (142), (143),
(234), (243) 24
(1234), (1243), (1324), 6 (1234), 2
(4)
(1342), (1423), (1432) 24 (1432) 4
TABLE 15.3: Cycle types of the Galois groups of f1 , f2 , f3 and their relative frequencies.
If we factor f modulo a prime p that does not divide res( f , f ′ ), then the de-
grees λ1 , . . . , λr of the irreducible factors also form a partition of n, the factor-
ization pattern λ = (λ1 , . . . , λr ) of f modulo p. For any partition λ, we can
consider the set Pλ of those primes where λ is this factorization pattern. Then
Frobenius’ density theorem says that Pλ has density µ(λ), so that a randomly
chosen prime is in Pλ with probability µ(λ). Chebotarev proved a stronger ver-
sion of this result, and Chebotarev’s density theorem has become much better
known than Frobenius’ theorem. For practical purposes, we would like to use this
kind of estimate for the primes in our algorithms. Unfortunately, nothing much
can be proved about this, because even the best versions of Chebotarev’s theorem
15.3. Frobenius’ and Chebotarev’s density theorems 443
(Lagarias & Odlyzko 1977, Oesterlé 1979) do not allow us to conclude that the
asymptotic density of Pλ already applies to the fairly small values of p that we
use (or of any size that leads to practical algorithms). However, case studies like
Example 15.6 give rise to the hope that more may be true than what can be proved
today.
pattern f1 f2 f3
(1, 1, 1, 1) 3.96% 24.84% 24.78%
(2, 1, 1) 25.30%
(2, 2) 12.70% 24.91% 75.22%
(3, 1) 33.18%
(4) 24.86% 50.25%
TABLE 15.4: Factorization patterns of f1 , f2 , f3 modulo the first 10 000 primes not dividing
the discriminant.
E XAMPLE 15.6 (continued). For each of the three polynomials f1 , f2 , f3 from Ex-
ample 15.6, Table 15.4 shows the frequencies of factorization patterns modulo the
first 10 000 primes where the polynomial is squarefree. One can see that these
approximate the relative frequencies of the conjugacy classes quite well. For ex-
ample, the partition (2, 2), corresponding to a factorization into two irreducible
quadratic factors, occurs in 12.70% of all cases for f1 , which is close to the fre-
quency 12.5% of the cycle type (2, 2) in Gal( f1 ). For f2 , this factorization pattern
occurs about twice as often, in 24.91% of all cases, and 25% of the four elements
of its Galois group have cycle type (2, 2). ✸
and find
The above example shows one drawback to our first approach: the degrees of ĝ
and ĥ are higher than those of g and h, in particular their sum exceeds the degree
of f . This may happen because the multiples of m are zero divisors modulo m2 ,
and hence the product of the leading coefficients of two polynomials may vanish
modulo m2 .
To overcome this problem, we use division with remainder in R[x]. Since R is
not a field, this is not always possible. The following lemma states that division
with remainder by monic polynomials always works.
L EMMA 15.9. (i) Let f , g ∈ R[x], with g nonzero and monic. Then there exist
unique polynomials q, r ∈ R[x] with f = qg + r and deg r < deg g.
(ii) If f , g, q, r are as in (i) and f ≡ 0 mod m for some m ∈ R, then q ≡ r ≡ 0
mod m.
Part (i) has been proven in Section 2.4, and the proof of (ii) is Exercise 15.12. We
do not need the coefficients of the new polynomials exactly, but only modulo m2 .
This means that over a Euclidean domain R we can reduce them accordingly and
keep their sizes small. Here are the formulas that work.
3. return g∗ , h∗ , s∗ ,t ∗
Then f ≡ g∗ h∗ mod 25, and the degrees of g∗ , h∗ are the same as those of g and h;
the polynomials are simpler than ĝ, ĥ as calculated before. As in Example 9.24,
we obtain that 7 is a solution to x4 − 1 ≡ 0 mod 25 that is congruent to the starting
solution 2 modulo 5.
To obtain s∗ ,t ∗ , which we need for the next iteration, we compute
Polynomial division yields c = 10x − 10 and d = −10 with sb ≡ ch∗ + d mod 25.
Now
Then indeed s∗ g∗ + t ∗ h∗ ≡ 1 mod 25, and the degrees of s∗ ,t ∗ agree with those of
s,t, respectively. ✸
T HEOREM 15.11.
Algorithm 15.10 works correctly as specified. It uses O(M(n)M(log m)) word
operations if R = Z, m > 1, and all inputs have max-norm less than m2 , and
O(M(n)M(degy m)) operations in the field F if R = F[y] and the degree in y of
all inputs is less than 2 degy m.
15.4. Hensel lifting 447
P ROOF. For the correctness, we only prove the claims about g∗ , h∗ ; those for s∗ ,t ∗
are left as Exercise 15.17. We calculate
f − g∗ h∗ ≡ f − (g + te + qg)(h + se − qh)
= f − gh − (sg + th)e − ste2 − (sg − th)qe + ghq2
≡ (1 − sg − th)e − ste2 − (sg − th)qe + ghq2 ≡ 0 mod m2 ,
e2 ≡ 50 x2 − 50 mod 625,
q2 ≡ −225x + 300 mod 625, r2 ≡ −175 mod 625,
3 2
g2 ≡ x + 182 x − x − 182 mod 625, h2 ≡ x − 182 mod 625,
2
b2 ≡ −225x + 300x − 25 mod 625,
c2 ≡ 75x − 200 mod 625, d2 ≡ 275 mod 625,
s2 ≡ −267 mod 625, t2 ≡ 267x2 − 312x − 176 mod 625.
Then s2 g2 + t2 h2 ≡ 1 mod 625, which we don’t actually need if we are only inter-
ested in a factorization modulo p4 , f ≡ g2 h2 mod 625, and as in Example 9.24,
448 15. Hensel lifting and factoring polynomials
we see that 182 is the fourth root of 1 modulo 625 that is congruent to the starting
solution 2 modulo 5. ✸
e1 ≡ −5 mod 25,
q1 = 0, r1 ≡ 10x + 5 mod 25,
2
g1 ≡ x − 8x + 7 mod 25, h1 ≡ x2 + 8x + 7 mod 25,
b1 ≡ 5x2 + 10 mod 25,
c1 ≡ −10x mod 25, d1 ≡ −10 mod 25,
s1 ≡ −2x + 9 mod 25, t1 ≡ 2x + 9 mod 25,
2
e2 ≡ 50x − 50 mod 625,
q2 ≡ −100x mod 625, r2 ≡ 175x + 175 mod 625,
2
g2 ≡ x − 183x + 182 mod 625, h2 ≡ x2 + 183x + 182 mod 625,
b2 ≡ 125x2 + 150 mod 625,
c2 ≡ −250x mod 625, d2 ≡ 200x + 100 mod 625,
s2 ≡ −202x − 91 mod 625, t2 ≡ 202x − 91 mod 625. ✸
that p ∤ u. Now
Since p is not a zero divisor, we have p | pl−i | (g∗ v + hu). We denote by a bar the
reduction modulo p. Then sg + th = 1, g∗ = g, and g∗ v + hu = 0. Thus
and hence g | u. Since lc(g) = lc(g∗ ) and deg g = deg g∗ , we have deg u < deg g.
Since lc(g) = lc(g) is not a zero divisor, neither is g, and u is the zero polynomial.
This contradicts our assumption that p ∤ u, and the claim is proved. ✷
C OROLLARY 15.15.
Let R be a Euclidean domain, p ∈ R prime, l ∈ N>0 , f , g, u ∈ R[x] nonzero such that
p ∤ lc( f ), f mod p is squarefree, g divides f in R[x], and u is monic, nonconstant,
and divides f modulo pl and g modulo p. Then u divides g modulo pl .
There is also an infinite version of Hensel’s lemma. Let p ∈ R be prime and R(p)
the p-adic completion of R (Section 9.6). If R = Z, then this is the ring Z(p) of
p-adic integers, whose elements can be represented by “power series in p” of the
form ∑i≥0 ai pi with 0 ≤ ai < p for all i ∈ N. If R = F[y] for a field F and p = y,
then R(p) = F[[y]] is the ring of formal power series in y with coefficients in F.
The general multivariate Newton iteration works as follows. One has n functions
ϕ = (ϕ1 , . . . , ϕn ) in n variables y1 , . . . , yn , and from an approximation a ∈ R n to a
450 15. Hensel lifting and factoring polynomials
1. if r = 1 then compute f1∗ ∈ R[x] with f ≡ lc( f ) f1∗ mod pl and return f1∗
2. k ←− ⌊r/2⌋, d ←− ⌈log2 l⌉
4. compute s0 ,t0 ∈ R[x] such that s0 g0 + t0 h0 ≡ 1 mod p, deg s0 < deg h0 , and
degt0 < deg g0 , using the Extended Euclidean Algorithm if R/hpi is a field
and Exercise 15.29 otherwise
5. for j = 1, . . . , d do
j−1
6. call the Hensel step algorithm 15.10 with m = p2 to lift the con-
j−1
gruences f ≡ g j−1 h j−1 and s j−1 g j−1 + t j−1 h j−1 ≡ 1 modulo p2 to
j
congruences f ≡ g j h j and s j g j + t j h j ≡ 1 modulo p2
7. g ←− gd , h ←− hd
15.5. Multifactor Hensel lifting 451
T HEOREM 15.18.
Algorithm 15.17 works correctly as specified.
(i) If R = Z, p ∈ N is prime, || f ||∞ < pl , and || fi ||∞ < p for all i, then the algo-
rithm takes
O (M(n)M(l µ) + M(n) log n · M(µ) + n M(µ) log µ) log r
We may assume that r is a power of two. Steps 8 and 9 take T (n1 , . . . , nk ) and
T (nk+1 , . . . , nr ) word operations, respectively. Adding costs leads to the recursive
inequalities
If we balance degrees in step 2, as discussed in Section 10.1, then the factor log r
in the timing estimate above may be replaced by the entropy H(n1 /n, . . . , nr /n),
where ni = deg fi for 1 ≤ i ≤ r.
g ≡ f1 f2 ≡ x2 + 2x + 2 mod 5, h ≡ f3 f4 ≡ x2 − 2x + 2 mod 5
in step 3, and the Extended Euclidean Algorithm in F5 [x] yields s = −2x − 1 and
t = 2x − 1 in step 4. In Example 15.13, we have already performed the computa-
tions of steps 5 and 6, and we find g = x2 − 183x + 182 and h = x2 + 183x + 182 in
step 7. In steps 8 and 9, we recursively lift the factorizations
to factorizations
g ≡ f1∗ f2∗ = (x − 1)(x − 182) mod 625, h ≡ f3∗ f4∗ = (x + 182)(x + 1) mod 625.
Thus f ≡ (x − 1)(x − 182)(x + 182)(x + 1) mod 625, and the fourth roots of unity
modulo 625 = 54 are ±1 and ±182. ✸
15.6. Factoring using Hensel lifting: Zassenhaus’ algorithm 453
10. s ←− s + 1
11. return G ∪ { f ∗ }
There are several ways to find suitable primes in step 2: we might try the small
primes 2, 3, 5, . . . one after the other, or we might use a single precision prime just
below the processor’s word length from a precalculated list. Both approaches work
well in practice, but do not yield a generally valid result since for some particular
input all primes from any fixed list might divide the discriminant. Another alterna-
tive which provably works is to choose p randomly; the required number theoretic
arguments will be discussed in Section 18.4.
T HEOREM 15.20.
Algorithm 15.19 works correctly. We have γ ∈ O(n log(nA)), and the expected
cost of steps 2 and 3 is
2 2
O γ log γ loglog γ + (M(n ) + M(n) log γ ) log n · M(log γ ) loglog γ
P ROOF. The correctness proof of Theorem 15.3 carries over with the following
modifications. We replace the congruence in (2) by f ∗ ≡ b ∏i∈T gi mod pl . In
one part of that proof we assume that the condition in step 9 is false for all sub-
sets S ⊆ T of cardinality s, but that f ∗ has an irreducible factor g ∈ Z[x] with
µ(g) = s, and the fact that F p [x] is a UFD yields a set S ⊆ T of cardinality s
such that the condition in step 9 is true for that particular subset. Now Z pl [x] is
not a UFD in general (it even has nonzero zero divisors), and we have to replace
the argument by unique factorization in F p [x] plus an appeal to the uniqueness of
Hensel lifting (Theorem 15.14). Namely, let h = f ∗ /g and S ⊆ T with #S = s
be such that lc(h)g ≡ b ∏i∈S hi mod p and lc(g)h ≡ b ∏i∈T \S hi mod p. Now for
that same subset S, let g∗ ≡ b ∏i∈S gi mod pl and h∗ ≡ b ∏i∈T \S gi mod pl . Thus
b f ∗ ≡ lc(h)g · lc(g)h mod pl and b f ∗ ≡ g∗ h∗ mod pl are both liftings of the same
factorization of b f ∗ modulo p, and the uniqueness of Hensel lifting (Theorem
15.14) implies that lc(h)g ≡ g∗ mod pl and lc(g)h ≡ h∗ mod pl . Now B < pl /2,
by the choice of l, and as in the proof of Theorem 15.3, we arrive at the contradic-
tion that ||g∗ ||1 ||h∗ ||1 ≤ B holds in step 9.
Corollary 18.12 says that with O(γ log2 γ loglog γ ) word operations, we can find
a random p in step 2, and that p divides disc( f ) with probability at most 1/2.
15.6. Factoring using Hensel lifting: Zassenhaus’ algorithm 455
Now b | disc( f ), by Exercise 6.41, and Lemma 15.1 implies that the expected
number of iterations of step 2 is at most two. The length of p is in O(log γ ), the
cost for reducing all coefficients of f modulo p is O(n log A · log γ ) word oper-
ations, and the gcd takes O(M(n) log n · M(log γ ) loglog γ ) word operations. The
cost estimate for step 4 follows from Theorem 15.18 with µ = log p ∈ O(log γ ),
using log n log γ ∈ O(n + log A) and log γ loglog γ ∈ O(n + log A), and the rest of
the analysis is as in the proof of Theorem 15.3. ✷
in step 8 and obtain ||g∗ ||1 ||h∗ ||1 ≤ B and g∗ h∗ = b f ∗ in step 9. Thus pp(g∗ ) =
3x2 + x + 1 and pp(h∗ ) = 2x2 + x + 4 are the irreducible factors of f in Z[x], as in
Example 15.4. ✸
Steps 2 and 3 of the big prime algorithm 15.2 take about O∼ (n3 + log3 A) word
operations, while the cost for the corresponding steps 2 through 4 in the prime
power algorithm 15.19 is only about O∼ (n2 + n log A) word operations. If n ≈
log A, then the former is roughly cubic in n, while the latter is only quadratic.
Like Algorithm 15.2, Zassenhaus’ algorithm has exponential running time in the
worst case. Nevertheless, the algorithm works well in practice and should be used
in the complete factorization algorithm 15.5; this is confirmed by experiments in
Section 15.7. Collins (1979) showed, under a plausible but unproven hypothesis,
that the algorithm uses polynomial time “on the average”.
There is one further advantage of Zassenhaus’ algorithm over the big prime
approach: since the Mignotte bound determining l is usually far too large, we
may interleave Hensel lifting and factor combination, as follows. We first lift the
∗
factorization modulo pl for some l ∗ < l, then check whether some of the modular
factors are true factors in Z[x], remove these from f , and then lift the remaining
456 15. Hensel lifting and factoring polynomials
factorization modulo some higher power of p. This is iterated until all factors of f
are found, which—if we are lucky—may happen before pl is reached. A natural
choice for these l ∗ are consecutive powers of 2, starting with the smallest such l ∗
which is at least || f ||∞ .
If we are only interested in computing all integral or rational roots of a given
polynomial f ∈ Z[x], then we can greatly simplify Zassenhaus’ algorithm 15.19.
We have already discussed an approach via factoring modulo a big prime in Sec-
tion 14.5. For the prime power approach, we modify Algorithm 15.19 in the fol-
lowing respects. Firstly, since we are only interested in linear factors, we may
replace the bound 2B by 2nb(A2 + A) if the latter is smaller, as in the big prime
algorithm 14.17. Secondly, we need only compute the linear factors of f modulo p
in step 3 (executing the distinct-degree and equal-degree factorization only for de-
gree 1), and finally—and most importantly—the whole factor combination stage
may be replaced by a simple check whether the linear factors modulo pl are linear
factors in Z[x].
T HEOREM 15.21.
Given a nonconstant squarefree primitive polynomial f ∈ Z[x], we can compute
all its rational roots with an expected number of
O n log(nA)(loglog A)2 logloglog A
+ M(n) log n · M(log(n log A)) log(n log A) loglog(n log A) + n2 M(log(nA))
P ROOF. Let γ = logC ∈ O(n log(nA)). The expected cost for step 2 of Algorithm
15.19, modified as described above, is
word operations, as in the proof of Theorem 15.20. The expected cost for com-
puting all (monic) linear factors of f mod p in step 3 is O(M(n) log n log(nγ ))
arithmetic operations in F p , by Corollary 14.16, or
word operations. We take all monic linear factors plus the remaining monic co-
factor of f mod p as inputs to the Hensel lifting in step 4. The cost for step 4
is
O (M(n)M(log(nA)) + M(n) log n · M(log γ ) + n M(log γ ) loglog γ ) log n
15.6. Factoring using Hensel lifting: Zassenhaus’ algorithm 457
word operations, by Theorem 15.18 with µ = log p ∈ O(log γ ). For each linear
factor bx − c ∈ Z[x] dividing f modulo pl , with b = lc( f ), we compute the cor-
responding cofactor v ∈ Z[x] such that (bx − c)v ≡ b f mod pl in step 8, at a cost
of O(n M(log(nA))) word operations, as in the proof of Theorem 14.18. There
are at most n modular factors, and hence the total cost for checking all of them is
O(n2 M(log(nA))) word operations. We obtain an overall cost of
O(γ log2 γ loglog γ + M(n) log n log(nγ ) M(log γ ) loglog γ + n2 M(log(nA)))
word operations, and the claim follows. ✷
Due to the checking in the last step, the overall asymptotic running time of the
prime power algorithm for root finding is about the same as for the big prime
variant (Algorithm 14.17). However, the modular factorization stage of the former
takes about O∼ (n log2 A) word operations, while the cost for the modular factoriza-
tion stage, including Hensel lifting, is only about O∼ (n log A) for the prime power
algorithm. In practice, one would expect that most of the “false” roots exceed the
trailing coefficient in absolute value, and would test the remaining trial roots mod-
ulo some other small primes first; this should rule out most of those which are not
roots in Q. The hope is that then there remain only few false roots.
With minor changes, Zassenhaus’ algorithm 15.19 can be adapted to factor bi-
variate polynomials over a field F with effective univariate factorization, so that
we know how to factor univariate polynomials over F (for example, F = Q or
F = Fq for a prime power q). The degree in y of a polynomial f ∈ F[x, y] plays the
role of the max-norm, and a bound for possible factors of f is much simpler than
in the integer case: divisors of f never have larger degree than f does. “Primitive”
now is with respect to the variable x, so that contx ( f ) = 1. Moreover, we require
f to have a trivial gcd with its derivative with respect to x. This implies that f is
squarefree. The converse is true in characteristic zero; see Exercise 15.25 for a
counterexample in positive characteristic.
3. { modular factorization }
use the univariate factorization algorithm to compute a factorization f ≡
bh1 · · · hr mod (y − u) in (F[y]/hy − ui)[x] ∼
= F[x] with distinct monic irre-
ducible h1 , . . . , hr ∈ F[x]
4. { Hensel lifting }
call Algorithm 15.17 to compute a factorization f ≡ bg1 · · · gr mod (y − u)l
with polynomials g1 , . . . , gr ∈ F[x, y] that are monic with respect to x such
that degy gi < l and gi (x, u) = hi for 1 ≤ i ≤ r
5. { initialize the index set T of modular factors still to be treated, the set G of
factors found, and the polynomial f ∗ still to be factored }
T ←− {1, . . . , r}, s ←− 1, G ←− Ø, f ∗ ←− f
6. { factor combination }
while 2s ≤ #T do
11. return G ∪ { f ∗ }
T HEOREM 15.23.
Algorithm 15.22 works correctly. The expected cost of step 2 is O(nd +M(n) log n)
or O∼ (nd) arithmetic operations in F , and step 4 takes O(M(n) log n(log n + M(d))
or O∼ (nd) operations. The number of field operations for one iteration of steps
8 and 9 is O((n log d + M(n) log n)M(d)) or O∼ (nd), and there are at most 2n+1
iterations. If F = Fq is a finite field with q elements, then the expected number of
operations in Fq for step 3 is O(M(n2 ) log n + M(n) log n log q) or O∼ (n2 + n log q).
with a worse cost estimate for the modular factorization stage. Or we may factor
f modulo a nonlinear irreducible m ∈ Fq [y] of degree O(log(nd)) in step 3 instead
of modulo y − u, and lift this to a factorization modulo a sufficiently high power
of m in step 4. This increases the timings of steps 2 and 3 by a factor of at most
O∼ (log2 (nd)). Or we perform a field extension of degree O(log(nd)) and employ
the algorithm over the larger field, thereby multiplying a factor of O∼ (log2 (nd)) to
all timings. However, irreducible factors of f in Fq [x, y] may split over the larger
field. In some applications, such a finer factorization may be advantageous, but
if factors over Fq are needed, one has to take care of this separately if necessary.
For example, if g ∈ Fqt [x, y] is an irreducible factor of f over the larger field Fqt ,
t
then g(q −1)/(q−1) ∈ Fq [x, y] (the norm of g) is a power of an irreducible factor of f
over Fq .
To factor an arbitrary polynomial f ∈ F[x, y], we proceed similarly as described
after Algorithm 15.2, with one notable difference: If F = Fq is a finite field, then
Fq (y) is not a perfect field, and we cannot literally use the algorithms of Section
14.6 for squarefree factorization. For example, if p = char Fq , then the polynomial
f = x p − y is irreducible, but has derivative ∂ f /∂x = 0. If we exchange the roles
of x and y, then ∂ f /∂y = −1 and gcd( f , ∂ f /∂y) = 1 in Fq (x)[y], and the algorithm
can be applied. If both partial derivatives ∂ f /∂x and ∂ f /∂y vanish, as for f =
x p − y p , then f is a pth power, as in the univariate case (here f = (x − y) p ), and it is
sufficient to factor f 1/p . Here is the analog of Algorithm 15.5; see Exercise 15.25
for a correctness proof.
5. for all v ∈ V ∪W do
determine the multiplicity e of v in g by trial division
g
G ←− G ∪ {(v, e)}, g ←− e
v
6. if F is finite of characteristic p and g 6∈ F then
call the algorithm recursively with input g1/p , yielding a ∈ F and a
set of pairs H
a ←− a p
for each pair (g, e) ∈ H do G ←− G ∪ {(g, ep)}
else a ←− g
7. return a and G
computation
big prime small primes prime power
problem
Algorithm 5.10,
determinant Section 5.5
Exercise 5.32
linear system
Exercise 5.33
solving
Algorithms EZ-GCD
polynomial gcd Algorithms 6.36, 6.38
6.28, 6.34 (Notes 15.6)
polynomial EEA Algorithms 6.57, 6.59
integer
Exercise 8.36 Algorithm 8.25
multiplication
polynomial Algorithms 8.16, 8.20,
multiplication Exercise 5.34
polynomial
Exercise 9.14 Exercise 10.21 Algorithm 9.3
division
roots of integers Section 9.5
root finding Algorithm 14.17 Theorem 15.21
squarefree
Exercises 15.26, 15.31 Exercise 15.27
decomposition
polynomial Algorithms
Algorithm 15.2
factorization 15.19, 15.22, 16.22
For all problems listed, there exist big prime algorithms, and in most cases also
small primes and prime power algorithms, although we did not discuss all of them.
Usually the small primes or prime power variants are more efficient, both in theory
and in practice, than either the big prime approach or a direct computation. To ap-
ply the prime power approach, the computational problem needs to be described
15.7. Implementations 461
in terms of “equations” which are then lifted. Some problems are badly suited for
the small primes approach, such as polynomial factorization.
15.7. Implementations
In this section, we continue the description of N TL and B I P OL A R from Sec-
tion 9.7, the focus now being on polynomial factorization. All experiments with
N TL were done in version 1.5.
B I P OL A R is a C++ library for polynomial factorization in F2 [x]. It contains
algorithms for squarefree decomposition (Section 14.6), distinct-degree factoriza-
tion (Section 14.2), and equal-degree factorization (Section 14.3). Experiments
show that for random polynomials, the distinct-degree factorization stage is by far
the dominant part of the whole computation.
Both in theory and in practice, a gcd computation is more costly than a multi-
plication or a division with remainder. Since a polynomial of degree n does not
have irreducible factors of all degrees between 1 and n (on average, the number
of irreducible factors is O(log n); see Notes 15.7), most gcds in the distinct-degree
factorization algorithm 14.3 are equal to 1. B I P OL A R uses a blocking strategy to
reduce the number of gcds, at the expense of additional—but cheaper—modular
multiplications. The range {1, . . . , n} of possible degrees for the irreducible factors
of f is partitioned into disjoint intervals, and then for each interval I—proceeding
from lower to higher degrees—the
product
of all irreducible factors with degree
qi
in I is obtained as gcd f , ∏i∈I (x − x) and removed from f (Exercise 14.6). If
we are lucky, then each of these polynomials is already irreducible; otherwise a
fine distinct-degree factorization à la Algorithm 14.3 is performed. Experiments
with random polynomials show that on average, this is only necessary for small
degrees. In B I P OL A R, the intervals grow linearly in size; this takes into account
the fact that random polynomials tend to have many small but few large factors.
Every time a factor is split off, an irreducibility test (similar to Algorithm 14.36)
for the remaining polynomial is started up on a second processor. Much of the data
required for this test has already been computed in the distinct-degree factorization
phase.
Figure 15.6 gives some running times with B I P OL A R from 1998 on two Sun
Sparc Ultra 1 computers rated at 167 MHz each; one running the distinct-degree
algorithm described above, and the second one performing the irreducibility test
in parallel. The timings are the maximum of the CPU times on both machines. An
implementation on a parallel machine can factor polynomials in F2 [x] of degree
over one million (Bonorden, von zur Gathen, Gerhard, Müller & Nöcker 2001).
The abort degree is the degree to which the distinct-degree factorization had
progressed when the computation was finished. It is printed in bold if the irre-
ducibility test won; otherwise the distinct-degree factorization terminated when
462 15. Hensel lifting and factoring polynomials
5’ 3818 12616
6’ 4724 10002
degree about max{m1 /2, m2 } was reached, where m1 , m2 are the degrees of the
largest and the second largest factor of the input polynomial, respectively.
For factoring in F p [x] for a prime p and in Q[x], N TL first computes the square-
free decomposition. Over finite prime fields, both the algorithms of Berlekamp
(1967,1970) and Shoup (1995) (who also does distinct- and equal-degree factor-
ization) are implemented. For efficiency reasons, there are special factoring sub-
routines for “small” primes p that fit into one machine word. Figure 15.7 shows
some running times in N TL for various primes and degrees. The timings are aver-
ages for 10 pseudorandomly chosen inputs.
To factor a squarefree polynomial with integral coefficients in Q[x], N TL first
computes—after extracting its content—its irreducible factorizations modulo sev-
eral “small” primes, thus (hopefully) gaining some information about the fac-
torization pattern in Q[x], as described at the end of Section 15.3. Then one of
these primes is selected and the factorization is lifted using a variant of Algorithm
15.17. For each product in the factor combination stage, the divisibility test is
only executed after checking that the degree of the product is compatible with all
modular factorization patterns, and then performing the constant coefficient test.
15.7. Implementations 463
30
25
20
CPU minutes
15
10
n = 64
5
n=k
k = 64
30
binomial
25 random
20
CPU minutes
15
10
F IGURE 15.8: Factoring xn−1 − 1 in Z[x] in NTL (green crosses). The timings depend
highly on the factorization of n − 1. The test series is for n = 32, 64, 96, . . . , 2048. The
running times for the seven values n = 704, 1024, 1248, 1376, 1408, 2016, and 2048 were
above four hours, in five of these cases even over one day. For comparison, we have
included the average timings for 10 pseudorandom polynomials of degree n − 1 with coef-
ficients in {−1, 0, 1} (blue curve).
464 15. Hensel lifting and factoring polynomials
30
25
20
CPU minutes
15
10
n = 64
5
n=k
k = 64
30
1 random factor
25 2 random factors
4 random factors
8 random factors
20 16 random factors
CPU minutes
15
10
F IGURE 15.10: Factoring polynomials of degree about n with about n-bit integer coef-
ficients in NTL. The green curve is for pseudorandom polynomials, the blue curve for
products of two pseudorandom polynomials of degree (n/2) − 1 with about n/2-bit coeffi-
cients, and so on.
Notes 465
Figures 15.8 through 15.10 give some running times in N TL for pseudorandom
polynomials with various degrees, coefficient sizes, and factorization patterns. The
timings are averaged over 10 pseudorandomly chosen inputs. Since random poly-
nomials are irreducible with high probability (see Notes 15.3), we also took poly-
nomials with a designed number of pseudorandom factors of the same degree as
input; in fact, these were the irreducible factors in almost all cases.
Figure 15.10 indicates that the algorithms take longer if there are more factors,
as expected. For a fixed input size n · k, the “diagonal” case n = k appears to
be the most favorable to the implementation, as in Figure 15.9. A comparison
to Figure 15.7 indicates that the software factors random polynomials with k-bit
coefficients over the integers much faster than modulo k-bit primes. (A major dif-
ference between the two factorization tasks is that random polynomials of degree
n are irreducible over Q with high probability, but modulo a prime only with prob-
ability about 1/n.) Presumably the reason is that the modular factorization stage,
which takes about O∼ (n2 log p + n log2 p) word operations, uses a small prime p
with only about log2 k bits when factoring over Z by Hensel lifting.
Notes. 15.1. The first factoring algorithms for Z[x] are due to von Schubert (1793),
Gergonne (1822), and Kronecker (1882, 1883). In our terminology, they use a “small
primes approach” with linear moduli x − ui for small integers ui , plus factor combination.
It involves the factorization of large integers and is utterly impractical.
15.2. Algorithm 15.2 appears in Musser (1971). Our algorithms become somewhat simpler
when the input is monic. One can reduce the general case to this, replacing f ∈ Z[x] by
lc( f )n−1 f (x/ lc( f )), but this is computationally disadvantageous.
In our approach, factors are selected according to the number of irreducible modular
factors that they comprise. One might also consider selecting them according to their
degree, but Collins (1979) argues that this is disadvantageous. Collins & Encarnación
(1996) and Abbott, Shoup & Zimmermann (2000) propose some heuristic techniques for
the factor combination stage.
Arjen Lenstra (1984, 1987) gives algorithms for factoring polynomials over algebraic
number fields.
15.3. The Swinnerton-Dyer polynomials were suggested by H. P. F. Swinnerton-Dyer, as
Berlekamp (1970) mentions. Kaltofen, Musser & Saunders (1983) investigate generaliza-
tions and also give bounds on the coefficient sizes.
Frobenius (1896) had found his theorem in 1880, and Chebotarev (1926) generalized it
in the following way, as already conjectured by Frobenius. In the full symmetric group Sn ,
all permutations with the same cycle structure form a conjugacy class, but this may not be
true in other Galois groups. As an example, the two 4-cycles in the Galois group of f2 in
Table 15.3 are not conjugate within that group. But still each set of permutations with the
same cycle structure is a union of conjugacy classes. While Frobenius’ theorem refers to
cycle structure (and primes with that factorization pattern), Chebotarev’s result proves the
corresponding density estimate for the finer division into conjugacy classes (and primes
whose Frobenius automorphism lies within that conjugacy class).
Van der Waerden (1934) proved that random integer polynomials have the full sym-
metric group as their Galois group with probability 1. In particular, they are probably
466 15. Hensel lifting and factoring polynomials
irreducible. See also Dörge (1926). Quantitative estimates are in Gallagher (1973). Wilf
(1994), §4.1, proves that the average number of cycles of a random permutation on n letters
is Hn ∈ ln n + O(1), where Hn = 1 + 21 + · · · + 1n is the nth harmonic number (Section 23.2).
15.4. Legendre (1785) factors some integer polynomials by a p-adic method. One of his
examples is in Exercise 15.11. Another example gives two cubic factors of a polynomial
of degree six. But he does not state a general method, and cautions the reader (pages
506/507): Ces méthodes sont fort imparfaites, mais l’utilité de leur objet nous a engagés à
les insérer ici, quelque petit que soit le nombre des cas où on peut s’en servir avec succès.1
Hensel (1918) introduced the p-adic numbers, and his factoring method Hensel lift-
ing was first used in a computer algebra context by Zassenhaus (1969); see also Kempfert
(1969). As with so many topics of this book, Gauß had preempted them all. In his Nachlass
(Gauß 1863a, 1863b, see page 372) we find in articles 373 and 374 an explicit description
of the lifting procedure modulo prime powers, and Gauß concludes si functio X aequales
non habeat divisores secundum modulum p, eam secundum modulum pk similiter in fac-
tores discerpi posse, uti secundum modulum p. At si X divisores aequales habeat, res fit
multo magis complicata neque adeo ex principiis praecedentibus prorsus exhauriri potest.2
He then even considers the case where multiple factors modulo p may occur, but the cal-
culations in his manuscript end dramatically in the middle of an equation.
Indeed, an integer polynomial f that is squarefree modulo a prime p has a unique fac-
torization modulo any power pk , and this is easily computed by Hensel lifting. But when
f is not squarefree modulo p, this factorization is quite tricky. Hensel lifting reduces the
problem to the case where f is a power of an irreducible polynomial modulo p. There
may be exponentially (in deg f ) many irreducible factors, but a representation of them can
still be computed in polynomial time (in deg f , log p, and k) if the discriminant is nonzero
modulo pk (von zur Gathen & Hartlieb 1998). This is based on polynomial-time factoring
algorithms over the p-adic integers Z(p) ; see Chistov (1990) and Cantor & Gordon (2000).
Exercise 15.18 shows how factoring the innocuous polynomial x modulo a composite num-
ber is a nontrivial task.
15.5. Victor Shoup has implemented a somewhat more efficient variant of Algorithm 15.17
in N TL. It is described in the 1999 edition of this book. A different approach to lift factors
simultaneously is in von zur Gathen (1984a).
15.6. The prime power factorization algorithm 15.19, based on Hensel lifting, is essentially
due to Zassenhaus (1969). Loos (1983) gives an algorithm based on Hensel lifting for
computing all rational roots of an integer polynomial.
A conceptually simple way to factor bivariate polynomials over small finite fields is to
make an extension of prime degree larger than deg( f ); then all factors over the extension
are actually in the ground field (von zur Gathen 1985). However, this approach is compu-
tationally inferior to the other solutions presented.
Trager (1976) shows that if F ⊆ E is a finite Galois extension of fields, f ∈ F[x] is
irreducible, and g ∈ E[x] is an irreducible factor of f , then the norm of g is a power of f .
Moses & Yun (1973) propose the EZ-GCD algorithm for computing gcds in Z[x] and
rings of multivariate polynomials via Hensel lifting; see also Lauer (2000). Yun (1976)
1 These methods are quite imperfect, but the importance of their goal induced us to insert them here, however
small the number of cases may be where they can be used successfully.
2 If the polynomial X is squarefree modulo p, then it factors modulo pk in the same way as modulo p. But if X
has multiple factors, the task is much more complicated and cannot even be solved by the preceding principles in
a straightforward manner.
Exercises 467
Exercises.
15.1 (i) Prove Eisenstein’s theorem: If f ∈ Z[x] and p ∈ N is a prime number such that p ∤ lc( f ),
p divides all other coefficients of f , and p2 ∤ f (0), then f is irreducible in Q[x].
(ii) Conclude that for any n ∈ N, the polynomial xn − p is irreducible in Q[x].
15.2 Trace Algorithm 15.2 on factoring f = 30x5 + 39x4 + 35x3 + 25x2 + 9x + 2 ∈ Z[x]. Choose the
prime p = 5003 in step 2.
15.3 Here are the irreducible factorizations of the monic polynomial f ∈ Z[x] of degree 6 modulo
some small primes:
What can you say about the degrees of the irreducible factors of f in Z[x]?
15.4−→ Compute the coefficients of the Swinnerton-Dyer polynomial
√ √ √ √ √ √ √ √
f = (x + −1 + 2)(x + −1 − 2)(x − −1 + 2)(x − −1 − 2) ∈ Z[x]
15.9∗∗ Let Fq be a finite field with q elements, for an odd prime power q, let x, y be indeterminates
over Fq , and
√ p √ p √ p √ p
f = (x + y + y + 1)(x + y − y + 1)(x − y + y + 1)(x − y − y + 1).
Show that f ∈ Fq [x, y] and that f is irreducible, but that f (x, u) ∈ Fq [x] splits into at least two factors
for all u ∈ Fq .
15.10∗ A partition of a positive integer n is a sequence λ = (λ1 , . . ., λr ) of positive integers such
that λ1 ≥ · · · ≥ λr and n = λ1 + · · · + λr ; r is the length of the partition. For example, if F is a
field and f ∈ F[x] of degree n, then the factorization pattern of f , with the degrees of the factors in
descending order, is a partition of n.
If λ = (λ1 , . . ., λr ) and µ = (µ1 , . . ., µs ) are two partitions of n, then we say that λ is finer than
µ and write λ 4 µ if there is a surjective map σ: {1, . . ., r} −→ {1, . . ., s} such that µi = ∑σ( j)=i λ j
for all i ≤ s. For example, λ = (4, 2, 1, 1) is finer than µ = (5, 3), as furnished by σ(1) = σ(3) = 1
and σ(2) = σ(4) = 2. (The function σ need not be unique.) In particular, (n) is the coarsest and
(1, 1, . . ., 1) is the finest partition of n.
(i) Prove that if f ∈ Z[x] has degree n and p ∈ N is prime, µ is the factorization pattern of f in
Q[x], and λ is the factorization pattern of f mod p in F p [x], then µ < λ.
(ii) Show that λ 4 λ, λ 4 µ =⇒ ¬(µ 4 λ), and λ 4 µ 4 ν =⇒ λ 4 ν holds for all partitions λ, µ, ν
of n, so that 4 is a partial order on the set of all partitions of n.
(iii) Enumerate all partitions of n = 8, and draw them in form of a directed graph, with an edge
from λ to µ if µ is a direct successor of λ with respect to the order 4, so that λ 4 µ, λ 6= µ, and
λ 4 ν 4 µ =⇒ λ = ν or ν = µ for all partitions ν.
(iv) Use (iii) to show that there exist partitions λ, µ of 8 that do not have a supremum with respect
to 4. (Thus the partitions do not form a “lattice” in the sense of order theory, not to be confused with
the Z-module lattices in Chapter 16.)
(v) Let an,r denote the number of partitions of n of length r. Thus an,1 = an,n = 1 and an,r = 0
for 1 ≤ n < r. Prove the recursion formula an,r = ∑1≤ j≤r an−r, j for 1 ≤ r < n. Calculate an,r for
1 ≤ r ≤ n ≤ 8, and compare with your results from (iii).
15.11 (Legendre 1785, p. 490) Let f = x3 − 292x2 − 2 170 221x + 6 656 000 ∈ Z[x]. Find 13-adic
i
linear factors x − ai with f rem x − ai ≡ 0 mod 132 for i = 0, 1, 2, starting with a0 = 0.
15.12 Prove Lemma 15.9 (ii).
15.13 Suppose that the monic polynomial f ∈ Z[x] has degree 8, and p is a prime so that f mod
p = g1 g2 g3 factors into three irreducible and pairwise coprime polynomials g1 , g2 , g3 ∈ F p [x] with
deg g1 = 1, deg g2 = 2, and deg g3 = 5.
(i) What can you say about the possible factorizations of f modulo p100 ?
(ii) What can you say about the possible factorizations of f in Q[x]?
(iii) Suppose q is another prime for which f mod q = h1 h2 with h1 , h2 ∈ Fq [x] irreducible and
deg h1 = deg h2 = 4. What can you say about the possible factorizations of f in Q[x], using all this
information?
15.14 Let f = x15 − 1 ∈ Z[x]. Take a nontrivial factorization f ≡ gh mod 2 with g, h ∈ Z[x] monic
and of degree at least 2. Compute g∗ , h∗ ∈ Z[x] such that
Show your intermediate results. Can you guess some factors of f in Z[x]?
15.15 Let f = 14x4 + 15x3 + 42x2 + 3x + 1 ∈ Z[x].
(i) Find a suitable prime p ∈ N such that f mod p is squarefree and has degree 4.
Exercises 469
(ii) Compute the irreducible factorization of f mod p in F p [x]. Choose two factors g, h ∈ Z[x] that
are coprime modulo p such that h is monic and irreducible modulo p and f ≡ gh mod p. Determine
s,t ∈ Z[x] with sg + th ≡ 1 mod p.
(iii) Execute two successive Hensel steps (Algorithm 15.10 for m = p and m = p2 ) to obtain a
factorization f ≡ g∗ h∗ mod p4 with g ≡ g∗ mod p and h ≡ h∗ mod p. Can you derive a factorization
of f in Q[x] from it?
15.16−→ Consider the polynomial
f = x5 + 3 y3 + 39 y2 + 50 y + 28 x4 + 36 y5 + 2 y4 + 47 y3 + 63 y2 + 49 y + 58 x3
+ 91 y6 + 18 y5 + 81 y4 + 37 y3 + 36 y2 + 53 y + 64 x2
+ 74 y7 + 54 y6 + 24 y5 + 39 y4 + 71 y3 + 18 y2 + 93 y + 53 x
+ 62 y6 + 72 y5 + 87 y4 + 27 y3 + 19 y2 + 61 y ∈ F97 [x, y].
(i) Compute a factorization f ≡ gh mod y with coprime nonconstant polynomials g, h ∈ F97 [x],
and polynomials s,t ∈ F97 [x] with sg + th = 1.
(ii) Execute two successive Hensel steps (Algorithm 15.10 with m = y and m = y2 ) to obtain
polynomials g∗ , h∗ ∈ F97 [x, y] such that f ≡ gh mod y4 , g∗ ≡ g mod y, and h∗ ≡ h mod y.
15.17 Complete the proof of Theorem 15.11.
15.18 (Shamir 1993) Let N = p · q be the product of two distinct primes p, q.
(i) Show that u = p2 + q2 is a unit in Z× N.
(ii) Verify the factorization x ≡ u−1 (px + q)(qx + p) mod N.
(iii) Prove that the two linear factors in (ii) are irreducible in ZN [x]. Hint: CRT.
15.19∗ Let N = p1 · · · ps be a product of s distinct primes, and f ∈ ZN [x] be monic and squarefree.
(i) Let g1 ∈ Z p1 [x] be irreducible, and g ∈ ZN [x] with g ≡ g1 mod p1 and g ≡ 1 mod pi for i ≥ 2.
Prove that g is irreducible in ZN [x].
(ii) Assume that we have factored f modulo each pi . Determine the factorization of f into irre-
ducible polynomials in ZN [x]. How many irreducible factors are there, in terms of the numbers of
irreducible factors modulo each pi ?
(iii) How many irreducible factors does x3 − x have modulo 105? Find four of them.
15.20 This exercise discusses a variant of Hensel lifting with linear convergence.
(i) One step works as follows. In Algorithm 15.10, we have an additional input p ∈ R, and the
congruence sg + th ≡ 1 should hold modulo p instead of m. In step 1, we perform all computations
modulo mp instead of m2 , and step 2 is omitted completely. Prove that then the output specifications
of Algorithm 15.10 for f , g∗ , h∗ hold if m2 is replaced by mp.
(ii) Now we start with a factorization of f , including the polynomials s,t, as specified in Algorithm
15.10 for m = p, and want to compute a factorization modulo pl for some l ∈ N. Show that for
R = Z, this takes O(M(n)M(l log p) log l) word operations when using the quadratic lifting algorithm
15.10 for m = p, p2 , p4 , p8 , . . ., and O(M(n)M(l log p)l) word operations when using the linear lifting
algorithm from (i) for m = p, p2 , p3 , p4 , . . ..
In fact, by employing fast lazy multiplication techniques (van der Hoeven 1997), the cost for linear
Hensel lifting can be reduced to O∼ (nl log p) as well (Bernardin 1998, private communication).
15.21 Let R be a ring (commutative, with 1) and f ∈ R[x], g = ∑0≤i≤m gi xi , h = ∑0≤i≤k hi xi be poly-
nomials such that n = deg f = m +k ≥ 1 and lc( f ) = gm hk . Regarding the n coefficients g0 , . . ., gm−1 ,
h0 , . . ., hk−1 as indeterminates, we define n polynomials ϕ0 , . . ., ϕn−1 in these indeterminates by let-
ting ϕi be the coefficient of xi in gh − f for 0 ≤ i < n.
470 15. Hensel lifting and factoring polynomials
(i) Prove that the Jacobian J ∈ R[g0 , . . ., gm−1 , h0 , . . ., hn−1 ]n×n , whose ith row comprises the par-
tial derivatives ∂ϕi /∂h j and ∂ϕi /∂g j , is precisely the Sylvester matrix of g and h.
(ii) Conclude that for specific values of the coefficients of g, h and a given p ∈ R such that lc( f )
is a unit modulo p, there exist s,t ∈ R[x] such that sg + th ≡ 1 mod p if and only if J is invertible
modulo p. Hint: Exercise 6.15.
15.22 Prove the running time estimate of Theorem 15.18 for the case R = F[y].
15.23 Let f = 6x5 + 23x4 + 51x3 + 65x2 + 65x + 42 ∈ Z[x] and p = 11.
(i) Compute the irreducible factorization of f mod p.
(ii) Use Algorithm 15.17 to lift the factorization above to a factorization of f modulo p4 .
(iii) Try to find nontrivial factors of f in Z[x] via factor combination.
15.24∗ Prove Theorem 15.23.
15.25∗ (i) Show that the bivariate polynomial factorization algorithm 15.24 works correctly when
F is a field of characteristic zero. First convince yourself that u = v is the squarefree part of g.
(ii) Let Fq be a finite field of characteristic p and h ∈ Fq [x, y]. Prove that h is a pth power if and
only if ∂h/∂x = ∂h/∂y = 0.
(iii) Show that h is squarefree if it is coprime to one of ∂h/∂x or ∂h/∂y. Hint: Exercise 14.22.
(iv) Prove that in step 3 of Algorithm 15.24, gcd(u, ∂u/∂x) = gcd(w, ∂w/∂x) = 1 in Fq (y)[x] and
gcd(v, ∂v/∂y) = 1 in Fq (x)[y], and that u, v, and w are squarefree.
(v) Now assume that h is an irreducible factor of g with multiplicity e in step 3 of Algorithm 15.24.
Conclude from the above that if p ∤ e, then h | vw in step 3 and h ∤ g in step 8, and that he still divides
g in step 8 if p | e.
(vi) Prove that Algorithm 15.24 works correctly when F = Fq .
15.26∗ (Gerhard 2001a) This exercise discusses a small primes modular algorithm for computing
the squarefree decomposition of a primitive polynomial f ∈ Z[x].
(i) Let R be a UFD and f ∈ R[x] nonconstant and primitive. Prove that there exist primitive
squarefree and pairwise coprime polynomials g1 , . . ., gm ∈ R[x] such that gm is nonconstant and
f = g1 g22 · · ·gm ×
m . Show that m is unique and the gi are unique up to multiplication by units in R .
For the special cases R = Z or R = F[y], where F is a field, we can make the decomposition above
unique by stipulating that lc(gi ) ∈ R be positive or monic, respectively, assuming that lc( f ) is also
positive or monic. Then we call the sequence (g1 , . . ., gm ) the primitive squarefree decomposition
of f .
(ii) Now let R = Z, p be a prime not dividing lc( f ) and f ≡ lc( f )h1 h22 · · ·hkk mod p be the square-
free decomposition of f modulo p, with monic h1 , . . ., hk ∈ Z[x] that are squarefree and pairwise
coprime modulo p, and hk 6= 1. Show that k ≥ m and the modular squarefree part h1 · · ·hk divides
modulo p the squarefree part g = g1 · · ·gm of f . Prove that k = m and gi ≡ lc(gi )hi mod p for all i if
p does not divide the (nonzero) discriminant res(g, g′ ) ∈ Z of g.
(iii) Prove the following generalization of Mignotte’s bound (Corollary 6.33): If f , g1 , . . ., gm ∈
Z[x] are nonzero polynomials with f = g1 · · ·gm and n = deg f , then
(iv) Design a small primes modular algorithm for computing the primitive squarefree decomposi-
tion of f , in analogy to the small primes modular gcd algorithm 6.38. Your algorithm should check
that the result is correct, so that it is Las Vegas, and use O∼ (n2 +n log A) word operations if A = || f ||∞ .
15.27∗ Using Exercise 15.26, design a prime power modular algorithm for computing the squarefree
decomposition of a primitive polynomial f ∈ Z[x]. Your algorithm should check that the result is
correct, so that it is Las Vegas, and use O∼ (n2 + n log A) word operations if n = deg f and A = || f ||∞ .
Exercises 471
15.28 We have indicated in Section 15.7 that factoring a random polynomial with k-bit coefficients
over the integers is computationally faster than factoring the same polynomial modulo a k-bit prime.
This suggests a factoring algorithm over finite prime fields which first factors the input polynomial
over the integers and then calls the factoring algorithm over finite fields for its (in Z[x]) irreducible
factors. Explain why this is not of much help for random polynomials.
15.29 Let R be a ring, 1 ≤ k < r, f1 , . . ., fr ∈ R[x] monic, nonconstant, and pairwise Bézout-coprime,
b ∈ R× , g = b f1 · · · fk , and h = fk+1 · · · fr . Show that g and h are Bézout-coprime. (Hint: Proceed as
in the solution of Exercise 10.13.) More precisely, prove that there exist polynomials s,t ∈ R[x] such
that sg + th = 1, deg s < deg h, and degt < deg g.
15.30 The aim of this exercise is to shave off the factor log r in the running time estimate of Theo-
rem 15.18 when using classical arithmetic. In addition to the input specification of Algorithm 15.17,
we assume that the fi are sorted by degree, so that n1 = deg f1 ≤ n2 = deg f2 ≤ · · · ≤ nr = deg fr .
Let li = ⌊log ni ⌋ for all i and e = e(n1 , . . ., nr ) = ⌈log ∑1≤i≤r 2li ⌉. (As usual, log denotes the binary
logarithm.)
(i) Assume r ≥ 2 and let 1 ≤ k < r be maximal such that ∑k<i≤r 2li ≤ 2e−1 . Prove that such a k
exists, that actually equality holds, and conclude that e(n1 , . . ., nk ) ≤ e−1 and e(nk+1 , . . ., nr ) ≤ e−1.
(ii) We replace the definition of k in step 2 of Algorithm 15.17 by the definition as in (i) and
denote by T (n1 , . . ., nr ) the cost of the algorithm with classical arithmetic. Prove that there is a
positive constant c such that
Research problem.
15.32 Let f ∈ Z[x], p be a prime, and k ∈ N. Can you find all factorizations of f into irreducible
factors modulo pk in time polynomial in deg f and k log p? An apparently difficult case is when the
discriminant res( f , f ′ ) is zero.
La clarté est, en effet, d’autant plus nécessaire,
qu’on a dessein d’entraîner le lecteur plus loin
des routes battues et dans des contrées plus arides.1
Joseph Liouville (1846)
1 Clarity is all the more necessary when one intends to guide the reader further away from the beaten track and
into more arid countryside.
16
Short vectors in lattices
16.1. Lattices
The methods we discuss in this chapter deal with computational aspects of the ge-
ometry of numbers , a mathematical theory initiated by Hermann Minkowski in the
1890s. This theory produces many results about Diophantine approximation, con-
vex bodies, embeddings of algebraic number fields in C, and the ellipsoid method
for rational linear programming.
Let f = ( f1 , . . . , fn ) ∈ R n . In this chapter, we use the norm (or 2-norm, or
Euclidean norm) of f , given by
1/2
|| f || = || f ||2 = ∑ fi2 = ( f ⋆ f )1/2 ∈ R,
1≤i≤n
473
474 16. Short vectors in lattices
F IGURE 16.1: The lattice in R 2 generated by (12, 2) (red) and (13, 4) (green).
E XAMPLE 16.4. We let n = 3, f1 = (1, 1, 0), f2 = (1, 0, 1), f3 = (0, 1, 1), and
calculate f1∗ = f1 = (1, 1, 0),
f2 ⋆ f1∗ 1 ∗ ∗ 1 1
µ21 = ∗ ∗ = , f2 = f2 − µ21 f1 = ,− ,1 ,
f1 ⋆ f1 2 2 2
f3 ⋆ f1∗ 1 f3 ⋆ f2∗ 1 ∗ ∗ ∗ 2 2 2
µ31 = ∗ ∗ = , µ32 = ∗ ∗ = , f3 = f3 − µ31 f1 − µ32 f2 = − , , ,
f1 ⋆ f1 2 f2 ⋆ f2 3 3 3 3
1 1 0 1 0 0 1 1 0
F = 1 0 1 = 21 1 0 · 12 − 12 1 = M · F ∗ .
1 1
0 1 1 2 3 1 − 32 2
3
2
3
We have || f1 ||2 = || f2 ||2 = || f3 ||2 = 2 and || f1∗ ||2 = 2, || f2∗ ||2 = 3/2, || f3∗ ||2 = 4/3. ✸
476 16. Short vectors in lattices
T HEOREM 16.5.
Let f1 , . . . , fn ∈ R n be linearly independent, and fi∗ , . . . , fn∗ their Gram-Schmidt
orthogonal basis. Let 0 ≤ k ≤ n, and let Uk = ∑1≤i≤k R fi ⊆ R n be the R-subspace
spanned by f1 , . . . , fk .
F IGURE 16.2: The Gram-Schmidt orthogonal basis of (12, 2) and (13, 4).
| det A| ≤ || f1 || · · · || fn || ≤ nn/2 Bn .
P ROOF. We may assume that A is nonsingular and the fi are linearly independent.
If ( f1∗ , . . . , fn∗ ) is their Gram-Schmidt orthogonal basis, then Theorem 16.5 implies
that ∗
f1 f
. .1
det . = det . = || f1∗ || · · · || fn∗ || ≤ || f1 || · · · || fn ||.
. .
fn fn∗
The second inequality follows from noting that || fi || ≤ n1/2 B for all i. ✷
L EMMA 16.7. Let L ⊆ R n be a lattice with basis ( f1 , . . . , fn ), and let ( f1∗ , . . . , fn∗ )
be its Gram-Schmidt orthogonal basis. Then for any f ∈ L \ {0} we have
P ROOF. Let f = ∑1≤i≤n λi fi ∈ L \ {0} be arbitrary, with all λi ∈ Z, and let k be the
highest index such that λk 6= 0. Substituting ∑1≤ j≤i µi j f j∗ for fi yields
f= ∑ λi ∑ µi j f j∗ = λk fk∗ + ∑ νi fi∗
1≤i≤k 1≤ j≤i 1≤i<k
where we used the pairwise orthogonality of the fi∗ and that λk ∈ Z \ {0}. ✷
478 16. Short vectors in lattices
f2
u f1
F IGURE 16.3: The vectors computed by the basis reduction algorithm 16.10 for the lattice
of Example 16.3.
T HEOREM 16.9.
Let ( f1 , . . . , fn ) be a reduced basis of the lattice L ⊆ R n and f ∈ L \ {0}. Then
|| f1 || ≤ 2(n−1)/2 · || f ||.
P ROOF. We have || f1 ||2 = || f1∗ ||2 ≤ 2|| f2∗ ||2 ≤ 22 || f3∗ ||2 ≤ · · · ≤ 2n−1 || fn∗ ||2 . Thus
|| f || ≥ min{|| f1∗ ||, . . . , || fn∗ ||} ≥ 2−(n−1)/2 || f1 ||, using Lemma 16.7. ✷
1. for i = 1, . . . , n do gi ←− fi
compute the GSO G∗ , M ∈ Q n×n , as in (1) and (2), i ←− 2
2. while i ≤ n do
3. for j = i − 1, i − 2, . . . , 1 do
4. gi ←− gi − ⌈µi j ⌋g j , update the GSO { replacement step }
g1 g∗1
step M action
g2 g∗2
12 2 1 0 12 2
4 41 row 2 ←− row 2 − row 1
13 4 37 1 − 11
37
66
37
12 2 1 0 12 2
5 4 exchange rows 1 and 2
1 2 37 1 − 11
37
66
37
1 2 1 0 1 2
4 44 row 2 ←− row 2 − 3 · row 1
12 2 16
5 1 5 − 22
5
1 2 1 0 1 2
6 1 44
9 −4 5 1 5 − 22
5
TABLE 16.4: Trace of the basis reduction algorithm 16.10 on the lattice of Example 16.3.
In fact, Algorithm 16.10 does more than required: Lemma 16.12 (iii) below
implies that |µi j | ≤ 1/2 holds for the GSO of the reduced basis (g1 , . . . , gn ). A re-
duced basis with this additional property is “almost orthogonal”.
E XAMPLE 16.3 (continued). Table 16.4 traces the algorithm on the lattice of Ex-
ample 16.3, and Figure 16.3 depicts the vectors gi in the computation. We start
with g1 = f1 = (12, 2) (red) and g2 = f2 = (13, 4) (green). In the second row of
Table 16.4, g2 is replaced by u = g2 − ⌈41/37⌋g1 = (1, 2) (yellow). Then g1 = f1
and g2 = u are exchanged in the third row. In the last row, v = g2 − ⌈16/5⌋g1 =
f1 − 3u = (9, −4) (blue) is computed, and the algorithm returns the reduced basis
u = (1, 2) and v = (9, −4). We can see clearly in Figure 16.3 that the final g1 = u
(the yellow vector) is much shorter than the two input vectors f1 , f2 , and that the
computed basis u, v (the yellow and the blue vectors) is nearly orthogonal. ✸
480 16. Short vectors in lattices
In the example above, the final g1 is actually a shortest vector. This seems to
happen quite often, but Theorem 16.9 only guarantees that the norm of the first
vector in the computed basis is bigger by a factor of at most 2(n−1)/2 than the norm
of a shortest vector, where n is the dimension of the lattice.
L EMMA 16.12. (i) We consider one execution of step 4, and let λ = ⌈µi j ⌋ for
short. Let G, G∗ , M and H, H ∗ , N in Q n×n be the matrices of the gk , g∗k , µkl
before and after the replacement, respectively, and E = (ekl ) ∈ Z n×n the
matrix which has ekk = 1 for all k, ei j = −λ, and ekl = 0 otherwise. Then
(iii) The Gram-Schmidt orthogonal basis g∗1 , . . . , g∗n does not change in step 4,
and after the loop in step 3 we have |µil | ≤ 1/2 for 1 ≤ l < i.
P ROOF. (i) The equality H = EG is just another way of saying that gi is replaced
by gi − λg j and all other gk remain unchanged. Since j < i, for any k ≤ n the space
spanned by g1 , . . . , gk remains the same, and hence the orthogonal vectors g∗1 , . . . , g∗n
16.3. Cost estimate for basis reduction 481
are not changed, which means that G∗ = H ∗ . Now the third claim follows from the
equations analogous to (2),
EMG∗ = EG = H = NH ∗ = NG∗ ,
1 0 ··· ··· ··· ··· ··· 0
.. ..
· 1 . .
..
..
· · 1 . .
..
..
· · · 1 . .
..
..
· · · · 1 . .
..
..
◦ ◦ • · · 1 . .
∗ ∗ ∗ ∗ ∗ ∗ 1 0
∗ ∗ ∗ ∗ ∗ ∗ ∗ 1
L EMMA 16.13. Suppose that gi−1 and gi are exchanged in step 5, and denote by
hk and h∗k the vectors and their Gram-Schmidt orthogonal basis after the exchange,
respectively. Then
1 1 3
||h∗i−1 ||2 = ||g∗i ||2 + µ2i,i−1 ||g∗i−1 ||2 ≤ ||g∗i−1 ||2 + ||g∗i−1 ||2 = ||g∗i−1 ||2 ,
2 4 4
by the condition for the exchange, the orthogonality of g∗i and g∗i−1 , and the fact
that |µi,i−1 | ≤ 1/2, by the previous lemma.
(iii) We let u = ∑1≤l<i−1 µi−1,l g∗l and U = ∑1≤l<i−1 R gl for short. Then the vector
hi is the component of gi−1 = g∗i−1 + u orthogonal to U + R gi . Now Theorem 16.5
∗
L EMMA 16.14. At the beginning of each iteration of the loop in step 2, the fol-
lowing invariants hold:
1
|µkl | ≤ for 1 ≤ l < k < i, ||g∗k−1 ||2 ≤ 2||g∗k ||2 for 1 < k < i.
2
P ROOF. The claim is trivial at the beginning of the algorithm. So we assume that
the invariants hold at the beginning of step 3 and prove that they hold again at the
end of step 5. Lemma 16.12 implies that the first invariant also holds for k = i
immediately before step 5, and since an exchange does not affect the µkl for k <
i − 1, the first invariant holds after step 5 in any case. Again by Lemma 16.12, the
g∗k do not change in steps 3 and 4, and the second invariant is still valid immediately
before step 5. Now an exchange in step 5 does not affect the g∗k for k 6∈ {i − 1, i},
by Lemma 16.13, and the second invariant holds again after step 5 in any case as
well. ✷
In particular, the above lemma implies that the basis g1 , . . . , gn is reduced upon
termination of the algorithm, and it remains to bound the number of iterations of
the loop in step 2. At any stage in the algorithm and for 1 ≤ k ≤ n, we consider the
matrix
g1
Gk = ... ∈ Z k×n
gk
comprising the first k vectors, their Gramian matrix Gk · GTk = (g j ⋆ gl )1≤ j,l≤k ∈
Z k×k , and the Gramian determinant dk = det(Gk · GTk ) ∈ Z. For convenience, we
let d0 = 1.
16.3. Cost estimate for basis reduction 483
g∗k
Then det Mk = 1, G∗k · (G∗k )T ∈ R k×k is a diagonal matrix with diagonal entries
||g∗1 ||2 , . . . , ||g∗k ||2 , Gk = Mk G∗k , and
So now we have found our desired loop variant D = ∏1≤k<n dk , and can bound
the number of arithmetic operations. Step 1 takes O(n3 ) operations in Z. With
the notation as in Lemma 16.12, one execution of step 4 amounts to computing
the matrix products EG and EM, at a cost of O(n) operations. Thus the number
of operations in Z used in the loop in step 3 is O(n2 ). If an exchange happens in
step 5, then only g∗i−1 , g∗i , and rows and columns i − 1 and i of the transition matrix
M change, and they can be updated using O(n) operations, which is dominated by
the cost for the loop 3. We always have 1 ≤ D ∈ Z, and its initial value D0 , at the
start of the algorithm, satisfies
since fi∗ is a projection of fi for all i. By Lemma 16.16, D does not change in steps
3 and 4, and decreases at least by a factor of 3/4 if an exchange happens in step 5,
so that the number of such exchange steps is bounded by log4/3 D0 ∈ O(n2 log A).
At any stage in the algorithm, let e ∈ N denote the number of exchange steps
performed so far and e∗ the number of times where the else-branch in step 5 has
484 16. Short vectors in lattices
been taken. Since i is decreased by one in an exchange step and increased by one
otherwise, the number i + e − e∗ is constant throughout the loop of step 2. Initially,
it equals 2, and hence n + 1 + e − e∗ = 2 at termination. Thus the total number of
iterations of the loop in step 2 is e + e∗ = 2e + n − 1 ∈ O(n2 log A), and we get a
total of O(n4 log A) operations in Z, as claimed in Theorem 16.11.
!
g1 ||g∗1 ||2
µ21 ||g∗ ||2 d1 , d2
step g2 action
µ31 µ32 2 D
g3 ||g∗3 ||2
! ! 3
1 1 1 1
3 14 3, 14
4 −1 0 2 3 rep(3, 2)
14 13 42
3 5 6 3 14 9
14
! ! 3
1 1 1 1
3 14 3, 14
4 −1 0 2 rep(3, 1)
13 −1 3 42
4 5 4 3 14 9
14
! ! 3
1 1 1 1
3 14 3, 14
5 −1 0 2 ex(3, 2)
1 −1 3 42
0 1 0 3 14 9
14
! ! 3
1 1 1 1
3 2 3, 2
5 0 1 0 ex(2, 1)
1 −1 3 6
−1 0 2 3 2 9
2
! ! 1
0 1 0 1 1, 2
4 1 1 1 2 rep(2, 1)
0 1 2
−1 0 2 2 9
2
! ! 1
0 1 0 0 1, 2
6 1 0 1 2
0 1 2
−1 0 2 2 9
2
TABLE 16.6: Trace of the basis reduction algorithm 16.10 on the lattice L = Z(1, 1, 1) +
Z(−1, 0, 2) + Z(3, 5, 6). We have d1 = ||g∗1 ||2 , d2 = ||g∗1 ||2 ||g∗2 ||2 , D = d1 d2 , and (det L)2 =
d3 = ||g∗1 ||2 ||g∗2 ||2 ||g∗3 ||2 = 9 throughout. Only the relevant values of the µi j and the squares
of the norms of the g∗i are given, and we have abbreviated a replacement gi ←− gi − ⌈µi j ⌋g j
by rep(i, j) and an exchange of gi and gi−1 by ex(i, i − 1) in the “action” column.
Table 16.6 traces Algorithm 16.10 and the values of the Gramian determinants
dk and of their product D on a three-dimensional lattice.
We still have the task of bounding the size of (the numerators and denomina-
tors of) the rational numbers that occur in the algorithm. The following lemma
16.3. Cost estimate for basis reduction 485
P ROOF. (i) We can write g∗k = gk − ∑1≤l<k λkl gl , with some λkl ∈ R. (In fact, the
λkl are the coefficients of M −1 below the diagonal.) We take the inner product with
g j for some j < k. Then g∗k ⋆ g j = 0, and
gk ⋆ g j = ∑ λkl (gl ⋆ g j ).
1≤l<k
(i) At any stage in the algorithm, except possibly in steps 3 and 4 when k = i,
we have ||gk || ≤ n1/2 A.
(ii) During each execution of step 4, ||gi || ≤ n(2A)n .
486 16. Short vectors in lattices
P ROOF. Initially, we have ||gk || ≤ A for all k. Step 5 does not change the ||gk ||, and
it is sufficient to examine what happens in steps 3 and 4. So we assume that the
claims are true immediately before step 3. The vectors gk for k 6= i are not affected
by step 4. Let mi = max{|µil |: 1 ≤ l ≤ i} be the maximal absolute value in the ith
row of M. From gi = ∑1≤l≤i µil g∗l and the orthogonality of the g∗l ’s, we find
||gi ||2 = ∑ µ2il ||g∗l ||2 ≤ nm2i A2 , and ||gi || ≤ n1/2 mi A. (4)
1≤l≤i
At the end of loop 3, we have mi = 1, by Lemma 16.12; this concludes the proof
of (i).
Lemma 16.17 and (i) imply that at the beginning of loop 3, we have
1/2
mi ≤ max{dl−1 : 1 ≤ l < i} · ||gi || ≤ An−2 · n1/2 A = n1/2 An−1 . (5)
1 1 3 1
|µil − ⌈µi j ⌋µ jl | ≤ |µil | + |⌈µi j ⌋| · |µ jl | ≤ mi + (mi + ) · = mi + ≤ 2mi
2 2 2 4
for 1 ≤ l < j. For l = j, the new value of µi j is absolutely at most 1/2, by con-
struction, and also the values of µil for l > j, by Lemma 16.12. Together we find
that for each value of j, the value of mi doubles at most, so that during the loop 3
the value of mi increases at most by a factor 2i−1 ≤ 2n−1 . Together with (5), this
shows that mi ≤ n1/2 (2A)n−1 at all times. Using (4), we have
P ROOF of Theorem 16.11. We have already shown the correctness, and that the
number of arithmetic operations in Z is O(n4 log A). The denominators dl of the
rational numbers computed in the algorithm are at most A2n , and their length is
O(n log A). The numerators are absolutely at most
◦ ||gk ||∞ ≤ ||gk || ≤ n(2A)n for gk , by Lemma 16.18,
◦ ||dk−1 g∗k ||∞ ≤ ||dk−1 g∗k || ≤ A2k−2 A ≤ A2n for g∗k , by Lemma 16.17 and (3),
1/2
◦ |dl µkl | ≤ dl dl−1 ||gl || ≤ A2l Al−1 n(2A)n ≤ n(2A4 )n for µkl , by Lemmas 16.17 and
16.18,
and hence their length is O(n log A) as well. ✷
16.4. From short vectors to factors 487
C OROLLARY 16.19.
Given linearly independent vectors f1 , . . . , fn ∈ Z n with max1≤i≤n || fi || = A, we can
compute a “short” nonzero vector u ∈ L = ∑1≤i≤n Z fi with
using O((n4 log A)M(n log A) log(n log A)) or O∼ (n5 log2 A) word operations.
P ROOF. The claim follows immediately from Theorem 16.11, noting that one
arithmetic operation in Z (addition, multiplication, division with remainder, or
gcd) on integers of length m can be performed with O(M(m) log m) or O∼ (m)
word operations. ✷
L EMMA 16.20. Let f , g ∈ Z[x] have positive degrees n, k, respectively, and sup-
pose that u ∈ Z[x] is nonconstant, monic, and divides both f and g modulo m for
some m ∈ N with || f ||k ||g||n < m. Then gcd( f , g) ∈ Z[x] is nonconstant.
P ROOF. Suppose that gcd( f , g) = 1 in Q[x]. Then there exist s,t ∈ Z[x] such
that s f + tg ≡ res( f , g) mod m, by Corollary 6.21. Since u divides both f and
g modulo m, it divides res( f , g) modulo m. But u is monic and nonconstant, and
thus res( f , g) ≡ 0 mod m. Since | res( f , g)| ≤ || f ||k ||g||n < m, by Theorem 6.23,
it follows that res( f , g) is zero. This contradiction to our assumption shows that
gcd( f , g) ∈ Q[x] is nonconstant. By Corollary 6.10, the gcd of f and g in Z[x] is
also nonconstant. ✷
The idea of the factoring algorithm is as follows. Suppose that we are given a
squarefree primitive polynomial f ∈ Z[x] of degree n and have computed a monic
polynomial u ∈ Z[x] of degree d < n that divides f modulo m for some m ∈ N.
488 16. Short vectors in lattices
Then we find a “short” polynomial g ∈ Z[x], meaning that ||g||n < m|| f ||− deg g , that
is also divisible by u modulo m. Then the above lemma gives us a nontrivial factor
of f in Z[x].
To find such a g of degree less than some bound j, we consider the lattice L ⊆ Z j
generated by (the coefficient vectors of)
{uxi : 0 ≤ i < j − d} ∪ {mxi : 0 ≤ i < d}.
An element g of L has the form
g = qu + rm with q, r ∈ Z[x], deg q < j − d, deg r < d, (6)
and degree less than j. In particular, u divides g modulo m. If, on the other
hand, some g ∈ Z[x] is of degree less than j and divisible by u modulo m, then we
have g = q∗ u + r∗ m for some q∗ , r∗ ∈ Z[x]. Division with remainder by the monic
polynomial u yields q∗∗ , r∗∗ ∈ Z[x] with r∗ = q∗∗ u+r∗∗ and deg r∗∗ < deg u. Letting
q = q∗ + mq∗∗ and r = r∗∗ , we see that g has the form (6), and conclude that
g ∈ L ⇐⇒ deg g < j and u divides g modulo m. (7)
Thus we can use basis reduction to find a “short” vector g ∈ L with the desired
properties.
T HEOREM 16.23.
The algorithm works correctly, and its expected cost in word operations is
O n6 (n + log A)M(n2 (n + log A))(log n + loglog A) or O∼ (n10 + n8 log2 A).
and Lemma 16.20 says that gcd(g, g∗ ) is nonconstant in Z[x]. Since g is irreducible
and deg g∗ ≤ j − 1 = deg g, we have g = ± pp(g∗ ).
We let h = f ∗ /g and S ⊆ T be as in step 9. As in the proof of Theorem 15.20,
the uniqueness of Hensel lifting (Theorem 15.14) implies that lc(g)h ≡ h∗ mod pl
in step 9. Since pl /2 is larger than the Mignotte bound bB on ||bh||∞ , we have
lc(g)h = h∗ , h = pp(h∗ ), and f ∗ = ± pp(g∗ ) pp(h∗ ), and Corollary 6.33 implies
that the condition in step 9 is true. The actions taken in the then clause ensure
that the invariants (8) hold at the next pass through step 6. This proves that the
algorithm will indeed return the factor g of f .
The cost of the algorithm is dominated by the cost for the short vector computa-
tions in step 7. We have ||v|| ≤ j1/2 ||v||∞ ≤ n1/2 pl for all generators v of L in step 7.
Letting δ = log(n1/2 pl ) ∈ O(n2 + n log B) = O(n2 + n log A), Corollary 16.19 im-
plies that one short vector computation takes O( j4 δ M( jδ ) log( jδ )) word opera-
tions. Let f1 , . . . , fk ∈ Z[x] be the irreducible factors of f . By what we have shown
above, the value j in step 7 runs through j = 2, . . . , 1 + deg fi for each irreducible
factor fi . Now ∑1≤i≤k (1 + deg fi ) = k + n ≤ 2n, and hence
∑ ∑ j4 δ M( jδ ) log( jδ )
1≤i≤k 2≤ j≤1+deg fi
by the superlinearity properties of M (Section 8.3). This establishes the time esti-
mate. ✷
We might also replace steps 1 through 4 of Algorithm 16.22 by the first three
steps of the big prime algorithm 15.2, yielding an algorithm with the same asym-
ptotic time bound.
of the two vectors (73, 72) and (−143, 73), and the polynomial g∗ in step 8 is
g∗ = 73x + 72. In step 9, we find that only g1 mod 5 = x − 1 divides g∗ mod 5,
whence S = {1} and
h∗ ≡ 6g2 g3 g4 ≡ 6x3 − 420x2 − 840x − 1728 mod 56 .
Now both g∗ and h∗ are primitive, || pp(g∗ )||1 || pp(h∗ )||1 ≥ || pp(g∗ )||∞ || pp(h∗ )||∞ >
B ≈ 3219.9, and in fact f 6= ± pp(g∗ ) pp(h∗ ), which can also seen by comparing
leading coefficients, and we continue the loop 7 with j = 3.
So now we consider the lattice generated by the vectors
(1, −5136, 0), (0, 1, −5136), (0, 0, 15 625).
Exercise 16.6 shows that a “short” vector in this lattice is (3, 1, 1) ∈ Z 3 , and hence
g∗ = 3x2 + x + 1 in step 8. Now both g1 mod 5 = x − 1 and g3 mod 5 = x − 2 divide
g∗ mod 5, so that S = {1, 3}, h∗ ≡ 6g2 g4 = 6x2 + 3x + 12 mod 56 , pp(g∗ ) = g∗ ,
and pp(h∗ ) = 2x2 + x + 4 in step 9. In fact, we have f = pp(g∗ ) pp(h∗ ), g∗ is an
irreducible factor of f (although we started with a smaller value for l as required),
and the assignments in the if clause yield T = {2, 4}, G = {x − 984, x − 6828},
f ∗ = 2x2 + x + 4, and b = 2. The next iteration of the while loop 6 would reveal
that f ∗ is irreducible, as we have already seen in Example 15.4. ✸
One might run factor combination and the short vector algorithm concurrently
(on one or, even better, on two processors) after Hensel lifting, and take the result
from whoever finishes first. This hybrid algorithm is reasonably fast on all inputs,
at a cost of at most doubling the overall running time.
C OROLLARY 16.25.
A polynomial f ∈ Z[x] of degree n ≥ 1 and with max-norm || f ||∞ = A can be
completely factored in Q[x] with an expected number of
O n6 (n + log A)M(n2 (n + log A))(log n + loglog A) or O∼ (n10 + n8 log2 A)
word operations.
word operations, and the claim follows from n1 +· · ·+ns ≤ n and the superlinearity
of M (Section 8.3). ✷
f = x3 + y3 − z3 ∈ Q[x, y, z] (9)
this reads:
Throughout this book, we have assumed (at least implicitly) this representation
for univariate and bivariate polynomials as inputs to algorithms, such as gcd com-
putations or factorization. (In examples, the format like (9) is used.) Multivariate
polynomials can be factored in random polynomial time in the length of this dense
representation over the usual fields of relevance to computer algebra, such as finite
fields, the rational numbers, and finite algebraic and transcendental extensions of
these. In fact, it is not hard to adapt the gcd algorithms of Chapter 6 and the bi-
variate factorization in the previous section to this situation. Is the problem then
494 16. Short vectors in lattices
If the list consists of s entries, then clearly the length is at least s. But this is not
enough; we have to bring the degree into play, since otherwise arbitrarily large
degrees might occur. So we consider the length of a list entry (ak , ik1 , . . . , ikt ) to be
1 + ik1 + · · · + ikt ; if we count word operations, say over Q, then the summand 1
has to be replaced by the length of ak . This convention for the length can be ex-
pressed by saying that the individual degrees ik1 , . . . are encoded in unary. One
might think that the binary encoding for the exponents is more natural. But then
the degree may be exponential in the length, and even univariate polynomials be-
come unmanageable. For very simple questions no polynomial-time answer is
known in this ultra-concise encoding; for example: given two polynomials in this
representation, does the first one divide the second one?
This sparse representation is the natural mathematical notation, and the user of a
computer algebra system will want to see her input and output in that format. For a
“random” polynomial (with a fixed number of variables and fixed degree), almost
all possible coefficients will be nonzero, and there will not be much difference be-
tween the sparse and the dense representations. However, natural problems given
to a computer algebra system tend to be sparse; see the cyclohexane example in
Section 24.4.
Unfortunately, no algorithm for factoring is known that runs in time polynomial
in the length of the sparse representation. There are even examples where the
output size is more than polynomial in the input size. But even if one allows time
polynomial in the combined input plus output size, no direct “sparse” solution is
known, but the arithmetic circuit and black box representations discussed below
solve the problem.
The key to get over this hurdle is to consider even more concise representations.
At first sight, the problem becomes even harder, since the input size (for a fixed
polynomial) might be even smaller. But the gain is that the output might also be
smaller, and, above all, that new computational methods may be used.
16.6. Factoring multivariate polynomials 495
x y z
The first new idea is the arithmetic circuit representation, where a polyno-
mial is represented by an arithmetic circuit, as illustrated in Chapters 2 and 8, that
computes f using x1 , . . . , xt and constants from F as inputs and only addition and
multiplication gates. (There is an efficient way to remove division gates if they
are also present.) For (9), this looks like Figure 16.7. Equivalently, an arithmetic
circuit may be represented by a straight-line program such as
g1 ←− x ∗ x
g2 ←− g1 ∗ x
g3 ←− y ∗ y
g4 ←− g3 ∗ y
g5 ←− z ∗ z
g6 ←− g5 ∗ z
g7 ←− g2 + g4
g8 ←− g6 − g7
ments of this in the literature, none of them is strong enough to derive a (proba-
bilistic) polynomial-time algorithm.
However, the situation can be saved by leaving one more variable and consid-
ering more general substitutions of the form ax1 + bx2 + c for the variables, where
a, b, c are chosen randomly from a (sufficiently large) finite subset of the ground
field. Then for an irreducible polynomial in F[x1 , . . . , xn ], the substituted polyno-
mial in F[x1 , x2 ] will be irreducible for almost all random choices. An arbitrary
polynomial can be mapped to two variables by such a substitution, then the bivari-
ate factoring technology can be applied, and finally Hensel lifting to get back to
the original multivariate situation. The role of the efficient Hilbert irreducibility
theorem is to insure that one (probably) does not have to worry about irreduci-
ble polynomials splitting after the substitution. This phenomenon required fac-
tor combination or a short vector computation for substitutions Z[x] −→ Z p [x] or
F[x, y] −→ F[x], but such methods would not lead to polynomial-time methods in
the multivariate case.
An even more powerful technique is the black box representation. A polyno-
mial f ∈ F[x1 , . . . , xn ] is now given by a “black box” subroutine which on input
a1 , . . . , an ∈ F returns the value f (a1 , . . . , an ) ∈ F. We have discussed this type of
representation for matrices in Section 12.4. Initially, a polynomial will often be
given in some other representation, say the sparse one. It is then easy to build
a black box for it. The power of the method is that now these black boxes can
be handled efficiently; Kaltofen & Trager (1990) give random polynomial-time
algorithms for several problems, including factorization. Finally, the black box
representation has to be converted back to human-readable output. There are sev-
eral interpolation algorithms for achieving this. Now an output polynomial with a
few hundred terms is rather useless for the human reader (but possibly useful as
input to another procedure). One interpolation method has the beautiful feature
that one can tell it to print only about a dozen (or about a hundred) terms (and to
say that there are more if that is so).
The black box technology has also been successfully applied to other problems
such as the gcd of two multivariate polynomials.
Notes. 16.1. Minkowski (1910) describes the geometry of numbers that he invented.
Grötschel, Lovász & Schrijver (1993) is a good textbook in this area, and Kannan (1987)
present an overview on computational aspects of this theory, including basis reduction and
several applications.
Ajtai (1997) shows that computing a shortest vector in a lattice is “NP-hard”. This is
under probabilistic polynomial-time reductions rather than the usual deterministic reduc-
tion for standard NP-hardness. As long as BPP = 6 NP is considered about as likely as
P 6= NP, this difference does not matter much.
16.2 and 16.3. The Gram-Schmidt orthogonalization procedure is from Schmidt (1907),
§3, who states that Gram (1883) has given essentially the same formulas. Hadamard (1893)
proved Theorem 16.6. The geometrical idea is that the volume | det A| of the polytope
Notes 497
The generic determinant polynomial for n × n matrices is an example where the length
of the sparse representation, which is essentially n!, is exponential in the length of the
arithmetic circuit representation, since there is an arithmetic circuit (with divisions) of size
O(n3 ) performing Gaussian elimination.
Lang (1983), chapter 9, describes Hilbert’s irreducibility theorem and the theory of
Hilbertian fields for which this theorem holds. Results on specific substitutions that con-
serve irreducibility are in Sprindžuk (1981, 1983) and Dèbes (1996). Efficient probabilistic
versions of Hilbert irreducibility, valid over any field but reducing only to two variables,
can be found in Kaltofen (1985b), von zur Gathen (1985), and Kaltofen (1995a). Huang &
Wong (1998) give a similar result for more general polynomial ideals.
The important paper of Kaltofen & Trager (1990) introduced the black box method and
gave several algorithms discussed above. A seminal idea for sparse interpolation is due to
Zippel (1979); several other papers deal with various aspects of interpolation: Ben-Or &
Tiwari (1988), Kaltofen & Lakshman (1988), Borodin & Tiwari (1990), Grigoriev, Karpin-
ski & Singer (1990), Clausen, Dress, Grabmeier & Karpinski (1991), Grigoriev, Karpinski
& Singer (1994). Freeman, Imirzian, Kaltofen & Lakshman (1988) and Díaz & Kaltofen
(1998) describe implementations of the straight-line and the black box technologies, re-
spectively.
Exercises.
16.1 Let F ∈ R n×n be nonsingular. Show that the GSO M, F ∗ of F is uniquely determined by the
conditions that F = MF ∗ , M be lower triangular with ones on the diagonal, and F ∗ (F ∗ )T be diagonal.
16.2∗ Prove Theorem 16.5.
16.3 We define an inner product R1
⋆ on the vector
p space V of continuous real-valued functions on the
real interval [−1, 1] by f ⋆ g = −1 f (y)g(y) 1 − y2 dy.
(i) Convince yourself that ⋆ is in fact an inner product.
(ii) Compute the Gram-Schmidt orthogonal basis of f0 , f1 , f2 , f3 , where fi (x) = xi for −1 ≤ x ≤ 1.
(The resulting polynomials are the monic associates of the first four Chebyshev polynomials of the
second kind.).
16.4∗ Let g1 , . . ., gn ∈ R n be linearly independent and L = ∑1≤i≤n Zgi the lattice that they generate.
Prove that for each vector x ∈ R n there is a vector g ∈ L such that
1
kx − gk2 ≤ (kg1 k2 + · · · + kgn k2 ).
4
Hint: Induction on n. For the induction step, determine a suitable λ ∈ Z such that the vector x − λgn
has minimal distance to the hyperplane spanned by g1 , . . ., gn−1 .
16.5 (i) Compute the GSO of (22, 11, 5), (13, 6, 3), (−5, −2, −1) ∈ R 3 .
(ii) Trace Algorithm 16.10 on computing a reduced basis of the lattice in Z 3 spanned by the vectors
from (i). Trace also the values of the di and of D, and compare the number of exchange steps to the
theoretical upper bound from Section 16.3.
16.6−→ Compute a “short” vector in the lattice in Z 3 spanned by (1, −5136, 0), (0, 1, −5136), and
(0, 0, 15 625).
16.7∗ The following algorithm takes an arbitrary nonsingular matrix A ∈ Z n×n and computes a
Hermite normal form H of A (Notes 4.5), such that H = UA for a matrix U ∈ Z n×n which is
unimodular, so that detU = ±1.
Exercises 499
16.10 Let x, y ∈ Cn .
(i) Prove the Cauchy-Schwarz inequality |x ⋆ y| ≤ ||x||2 ||y||2 . Hint: Consider the inner product
(||y||2 x + ||x||2 y) ⋆ (||y||2 x + ||x||2 y).
(ii) Use (i) to prove the triangle inequality ||x + y||2 ≤ ||x||2 + ||y||2 .
16.11∗ Lemma 16.17 shows that at any stage in the basis reduction algorithm 16.10, dl µkl and
dk−1 g∗k have integral coefficients for 1 ≤ l < k ≤ n. By multiplying the entries of the GSO by (and,
where possible, dividing out) appropriate dl ’s, convert Algorithm 16.10 into a fraction-free algorithm,
so that all intermediate coefficients are in Z.
16.12∗∗ This exercises discusses basis reduction for polynomials. Let F be a field, R = F[y], and
n ∈ N>0 . The max-norm of a vector f = ( f1 , . . ., fn ) ∈ Rn is || f || = || f ||∞ = max{deg fi : 1 ≤ i ≤ n}.
For vectors f1 , . . ., fm ∈ R which are linearly independent over F(y), the field of fractions of R, the
R-module spanned by f1 , . . ., fm is M = ∑1≤i≤m R fi , and ( f1 , . . ., fm ) is a basis of M.
(i) Let f1 , . . ., fm ∈ Rn be linearly independent (over F(y)), with fi = ( fi1 , . . ., fin ) for 1 ≤ i ≤ m.
We say that the sequence ( f1 , . . ., fm ) is reduced if
◦ || f1 || ≤ || f2 || ≤ · · · ≤ || fm ||, and
◦ deg fi j ≤ deg fii for 1 ≤ j ≤ n, with strict inequality if j < i, for 1 ≤ i ≤ m.
In particular, we have || fi || = deg fii for 1 ≤ i ≤ m. Prove that f1 is a shortest vector in the R-module
M = ∑1≤i≤m R fi , so that || f1 || ≤ || f || for all nonzero f ∈ M.
(ii) Consider the following algorithm, from von zur Gathen (1984a).
A LGORITHM 16.27 Basis reduction for polynomials.
Input: Linearly independent (over F(y)) row vectors f1 , . . ., fm ∈ Rn , where R = F[y] for a field F,
with || fi || < d for 1 ≤ i ≤ m.
Output: Row vectors g1 , . . ., gm ∈ Rn and a permutation matrix A ∈ Rn×n such that (g1 , . . ., gm ) is a
reduced sequence and (g1 A, . . ., gm A) is a basis of M = ∑1≤i≤m R fi .
1. let g1 , . . ., gm be such that {g1 , . . ., gm } = { f1 , . . ., fm } and ||gi || ≤ ||gi+1 || for 1 ≤ i < m
A ←− id, k ←− 1
2. while k ≤ m do
3. { (g1 , . . ., gk−1 ) is reduced and ||gi || ≤ ||gi+1 || for 1 ≤ i < m }
u ←− ||gk ||
4. for i = 1, . . ., k − 1 do
5. q ←− gki quo gii , gk ←− gk − qgi
6. if ||gk || < u then
r ←− min{i: i = k or (1 ≤ i < k and ||gi || > ||gk ||)}
replace gr , . . ., gk−1 , gk by gk , gr , . . ., gk−1
k ←− r, goto 2
7. l ←− min{k ≤ j ≤ n: deg gkl = u}
let B ∈ Rn×n be the permutation matrix for the exchange of columns k and l
for i = 1, . . ., m do gi ←− gi B
A ←− BA, k ←− k + 1
8. return g1 , . . ., gm and A
Show that M = ∑1≤i≤m R · gi A holds throughout the algorithm, and conclude that the gi are always
nonzero vectors.
(iii) Assume that the invariants in curly braces are true in step 3. Convince yourself that ||gk−1 || ≤ u
holds during steps 4 and 5 if k ≥ 2. Show that gii 6= 0 holds in step 5 if k ≥ 2, so that the division
with remainder can be executed, and prove the invariants ||gk || ≤ u and deg gk j < u for 1 ≤ j < i of
the loop 4.
Exercises 501
(iv) Show that (g1 , . . ., gk−1 ) is reduced and ||gi || ≤ ||gi+1 || for 1 ≤ i < m holds each time the
algorithm passes through step 3. Conclude that it works correctly if it halts in step 8.
(v) Show that ||gi || < d for 1 ≤ i ≤ m holds throughout the algorithm. Prove that the cost for
one execution of steps 3 through 7 is O(nm) arithmetic operations (additions, multiplications, and
divisions with remainder) in R or O(nm M(d)) operations in F.
(vi) Show that the function s(g1 , . . ., gm ) = ∑1≤i≤m ||gi || never increases in the algorithm and
strictly decreases if the condition in step 6 is true. Conclude that the number of times when the latter
happens is at most md and that the number of iterations of the loop 2 is at most (m − 1)(md + 1).
(vii) Putting everything together, show that the running time of the algorithm is O(nm3 d M(d)) or
O∼ (nm3 d 2 ) arithmetic operations in F.
(viii) Trace the algorithm on the F97 [y]-module generated by
5y3 + 44y2 + 37y + 91, 8y3 + 86y2 + 91y + 89, 16y3 + 65y2 + 20y + 76 ,
8y3 + 70y + 37, 16y3 + 7y2 + 54y + 38, 32y3 + 23y2 + 80y + 77 ,
16y2 + 84y + 63, 32y2 + 15y + 19, 64y2 + 48y + 51 ∈ F97 [y]3 .
Mulders & Storjohann (2000) give an algorithm for computing a reduced basis taking only O(nm2 d 2 )
arithmetic operations in F.
16.13 State and prove the analog of Lemma 16.20 for polynomials in F[x, y] for a field F when || · ||2
is replaced by || f ||∞ = degy f .
16.14∗ Use Exercises 16.12 and 16.13 to adapt Algorithm 16.22 to bivariate polynomials over a
field. Prove that your algorithm works correctly and analyze its running time. You may assume that
F has effective univariate factorization and is “large enough”, so that the modulus p may be chosen
linear.
16.15 Let F be a field and n ∈ N. What is the size of the sparse representation of the polynomial
i
∏0≤i<n (x + y2 ) ∈ F[x, y]? Find an arithmetic circuit representation of size 3n − 2.
16.16∗ You are to design an algorithm for factoring multivariate polynomials over a field F with
efficient univariate factorization. Suppose that f ∈ F[x1 , . . ., xt ] has degree less than n in each vari-
i−1
able, and consider the Kronecker substitution σ: F[x1 , . . ., xt ] −→ F[x] which maps xi to xn for
1 ≤ i ≤ t. This is a ring homomorphism.
(i) Show that polynomials with degree less than n in each variable can be uniquely recovered
from their image under σ. More precisely, let U ⊆ F[x1 , . . ., xt ] be the vector space of all these
polynomials, and V = {h ∈ F[x]: deg h < nt }. Show that σ gives a vector space isomorphism between
U and V .
(ii) Prove that the following procedure correctly factors f : Factor σ( f ) into irreducible factors
h1 , . . ., hr ∈ F[x], and test for each factor combination h of them whether its inverse σ −1 (h), in the
sense of (i), divides f .
(iii) Analyze the cost of your algorithm from (ii). You will first have to estimate the cost for mul-
tivariate multiplication (Exercise 8.38). Ignore the time for univariate factorization in this analysis.
(iv) Trace your algorithm on the example f = −x4 y + x3 z + xz2 + yz2 ∈ F3 [x, y, z].
Research problem.
16.17 Can one compute the gcd of two multivariate polynomials in random polynomial time in the
length of the sparse representation plus the degree? Is the output length always polynomial in the
input length? As mentioned in Section 16.6, one can factor polynomials in random polynomial time
both in the arithmetic circuit and in the black box representation.
Il faut bien distinguer entre la géométrie utile et la géométrie curieuse.
L’utile est le compas de proportion inventé par Galilée [. . . ]
Presque tous les autres problèmes peuvent éclairer l’esprit et le
fortifier; bien peu seront d’une utilité sensible au genre humain.1
Voltaire (1771)
But yet one commoditie moare [. . . ] I can not omitte. That is the
filyng, sharpenyng, and quickenyng of the witte, that by practice of
Arithmetike doeth insue. It teacheth menne and accustometh them, so
certainly to remember thynges paste: So circumspectly to consider
thynges presente: And so prouidently to forsee thynges that followe:
that it maie truelie bee called the File of witte.
Robert Recorde (1557)
1 One has to distinguish carefully between practical geometry and theoretical geometry. Practical is the rule of
proportions invented by Galileo [. . . ] Almost all other problems can enlighten the mind and strengthen it; rather
few will be of any reasonable usefulness to mankind.
2 To share a night between a beautiful woman and a clear sky, the day in seeking agreement between one’s
observations and calculations, seems to me happiness on earth.
17
Applications of basis reduction
This chapter presents four applications of basis reduction: breaking certain cryp-
tosystems and linear congruential pseudorandom generators, finding simultaneous
Diophantine approximations, and a refutation of Mertens’ conjecture. We can only
give the basic ideas; technical details can be found in the references, provided in
the notes. The first two sections assume familiarity with the basics of cryptogra-
phy, as explained in Chapter 20.
For example, an instance is to ask whether there exist x1 , . . . , x6 ∈ {0, 1} such that
366x1 + 385x2 + 392x3 + 401x4 + 422x5 + 437x6 = 1215.
This problem is NP -complete, as is a slight generalization of it, called the knap-
sack problem. After Diffie & Hellman (1976) invented public key cryptography,
Merkle & Hellman (1978) proposed a public key cryptosystem based on the subset
sum problem. The computations in this system were much less voluminous than
for other systems such as RSA (Section 20.2), and its higher throughput seemed
to promise a bright future. Several other such systems were proposed, based on
versions of the knapsack problem. But the roof fell in when Shamir (1984) broke
the Merkle & Hellman system, and almost all subsequently proposed improved
schemes have suffered the same fate. Basis reduction has played a major role in
some of these cryptanalyses.
In the notation of Section 20.1, Alice publishes her public key a1 , . . . , an for such
a knapsack cryptosystem. When Bob wants to send her n bits x1 , . . . , xn secretly,
he encodes them as s = ∑1≤i≤n ai xi and sends s. Decoding a general such problem
is NP -complete and hence infeasible, but the idea now is to use a special type
of problem for which decoding is easy with some secret additional knowledge,
503
504 17. Applications of basis reduction
but hopefully hard without the secret. These special subset sum problems start
with “superincreasing” b1 ≪ b2 ≪ · · · ≪ bn as the summands; a trivial example
is bi = 2i−1 , where the solution (x1 , . . . , xn ) is just the binary representation of s.
More generally, it is sufficient to have bi > ∑1≤ j<i b j for all i; the solution is then
unique and easy to calculate. The “easiness” is then hidden by multiplying the bi ’s
with a random number c modulo another random number m to obtain the public
ai ’s. Alice’s private key c, m allows her to multiply s by c−1 modulo m and then
solve an easy subset sum problem. At first sight, the ai look like a general subset
sum problem, but the cryptanalysts’ work then showed that this hiding does not
work. Of course, the breaking of these schemes does not mean that large instances
of an NP -complete problem can be solved routinely; the “superincreasing” subset
sum problem is just too special.
The connection between the subset sum problem and short vectors is given by
the fact that a solution of (1) yields a short vector in the lattice L ⊆ Z n+1 generated
by the rows r1 , . . . , rn+1 ∈ Z n+1 of the matrix
1 0 · · · 0 −a1
0 1 · · · 0 −a2
.. .. . . .. .. ∈ Z (n+1)×(n+1) .
. .
. . .
0 0 · · · 1 −an
0 0 ··· 0 s
To see this, let (x1 , . . . , xn ) ∈ {0, 1}n be a solution of (1). Then
v= ∑ xi ri + rn+1 = (x1 , . . . , xn , 0) ∈ L
1≤i≤n
√
is a vector with ||v||2 ≤ n, which is very small since the ai are typically very
large numbers. The approach to breaking such a cryptosystem is to compute a
reduced basis of L and to hope that the resulting short vector is (essentially) v. Of
course, this does not work too well for general subset sum problems, but it does
work for low-density subset sums, where the ratio n/(maxi log2 ai ) of information
bits to transmitted bits is small. This number is about 1/n for Merkle & Hellman’s
original scheme, and then this attack is very successful. In the example, the density
6/ log2 437 ≈ 0.684 is high.
For example, with a1 , . . . , a6 as in the beginning, we consider the lattice L ⊆ Z 7
generated by the rows of the matrix
1 0 0 0 0 0 −366
0 1 0 0 0 0 −385
0 0 1 0 0 0 −392
0 0 0 1 0 0 −401 ∈ Z 7×7 .
0 0 0 0 1 0 −422
0 0 0 0 0 1 −437
0 0 0 0 0 0 1215
17.2. Pseudorandom numbers 505
For general n, Dirichlet (1842) showed that there are infinitely many approxi-
mations with |αi − pi /q| ≤ q−(1+1/n) for all i. Lenstra, Lenstra & Lovász (1982)
expressed this as a short vector problem, as follows. Given individual rational ap-
proximations αi ≈ βi = ui /vi with ui , vi ∈ Z for 1 ≤ i ≤ n (but not necessarily the
same denominator as demanded for a simultaneous approximation), and a rational
ε with 0 < ε < 1, we take Q = ε−n as an approximate bound on the denominator q.
We set w = 2−n(n+1)/4 εn+1 , and let L ⊆ Q n+1 be the lattice generated by the rows
f0 , . . . , fn ∈ Q n+1 of the matrix
w β1 β2 · · · βn
0 −1 0 · · · 0
0 0 −1 · · · 0
∈ Q (n+1)×(n+1) .
.. .. .. . . ..
. . . . .
0 0 0 · · · −1
In our treatment, we always assumed the vectors generating the lattice to have inte-
gral coefficients, but basis reduction also works for rational coefficients, as we have
them here. It will produce in polynomial time a reduced basis for L = ∑0≤i≤n Z fi .
By multiplying together the n + 1 inequalities in the proof of Theorem 16.9, we
find that its first vector g satisfies
||g||2(n+1) ≤ || f0∗ ||2 · 2|| f1∗ ||2 · · · 2n || fn∗ ||2 = 2n(n+1)/2 || f0∗ ||2 · · · || fn∗ ||2 .
Since f0∗ , . . . , fn∗ are orthogonal, we find from Theorem 16.5 (iv)
1/(n+1)
f0∗
||g|| ≤ 2n/4 (|| f0∗ || · · · || fn∗ ||)1/(n+1) = 2n/4 det ..
.
fn∗
1/(n+1)
f0
= 2n/4 det ...
= ε < 1.
fn
Lagarias (1985) gave the following all-integer variant. Input is the vector β =
(u1 /v1 , . . . , un /vn ) ∈ Q n . For any nonzero q ∈ N, we write
ui pi
{{β q}} = min max −
p1 ,...,pn ∈Z 1≤i≤n vi q
for the best approximation quality with denominator q. For pi , one simply takes
the integer nearest to ui q/vi . A further input is a bound Q on the denomina-
tor. If a simultaneous approximation denominator q∗ exists with 1 ≤ q∗ ≤ Q and
ε = {{β q∗ }}, say as guaranteed by Dirichlet’s theorem but unknown, then the
algorithm produces an approximation q which is almost as good:
√
1 ≤ q ≤ 2n/2 QV, and {{β q}} ≤ 5 n 2(n−1)/2 ε. (2)
We let V = v1 · · · vn , and assume that ε > 0. For all j ∈ {0, . . . , n + log2 (QV )}, we
consider the lattice L j ⊆ Z n+1 spanned by the rows of the matrix
u1 u2 un
2 j QV QV QV
v1 v2 vn
0 QV 0 · · · 0
0 0 0
(n+1)×(n+1)
QV ··· ∈Z .
. . . .
.. .. .. ..
0 0 0 ··· QV
The lower n vectors have only one nonzero entry each. We run the basis reduction
( j) ( j)
algorithm 16.10 on this basis, and let x( j) = (x0 , . . . , xn ) ∈ Z n+1 be the short
( j)
vector returned. Lagarias shows that for some value of j, the denominator q = x0
provides an approximation satisfying (2), and that the whole algorithm runs in
polynomial time.
E XAMPLE 17.1. We try Lagarias’ method on the binary logarithms of the mu-
sical intervals 2, 3/2, 4/3, 5/4, 6/5, 9/8 from Section 4.8. Since log2 2 = 1 and
log2 (3/2) + log2 (4/3) = 1, it suffices to find simultaneous Diophantine approxi-
mations for α1 = log2 (4/3) ≈ 0.42, α2 = log2 (5/4) ≈ 0.32, α3 = log2 (6/5) ≈
0.26, and α4 = log2 (9/8) ≈ 0.17. We take as initial approximation ui /vi the dec-
imal expansion of αi rounded to two digits, so that we start with a simultaneous
Diophantine approximation with common denominator V = 100 (instead of the
product required above). Letting Q = 1 and j = 0, we obtain the lattice L ⊆ Z 5
generated by the rows of the matrix
1 42 32 26 17
0 100 0 0 0
0 0 100 0 0
.
0 0 0 100 0
0 0 0 0 100
508 17. Applications of basis reduction
Mertens (1897) contains a table and a foldout chart of values up to 10 000, and
√
he conjectured that |M(x)| ≤ x for all x ∈ N; a similar conjecture had been made
in 1885 by Stieltjes.
The conjecture may seem to come out of the blue, but in analytic number theory
one studies various functions that take values 0, 1, −1 (or other complex values
with absolute value 0 or 1) such as the Jacobi symbol (Section 18.5) and proves
√
that their sum up to x is absolutely bounded by O( x). The same is true for the
absolute value of the sum of a random sequence of 1 and −1 (Exercise 19.18; the
sum itself has mean 0); in fact, the quotient M(x)/x goes to zero if and only if µ
takes the values 1 and −1 roughly equally often. This principle will motivate the
bound on the size of elliptic curves (Hasse’s theorem 19.20).
Mertens proved that his conjecture implies the famous Riemann Hypothesis
(Notes 18.4). Furthermore, it was known that it implies the unsolvability of a cer-
tain (inhomogeneous) simultaneous Diophantine approximation problem, as in the
previous section, involving roots of Riemann’s zeta function. However, Odlyzko &
te Riele (1985) used basis reduction in a lattice in R 70 to show that this approxima-
tion problem does have a solution, and thus disproved Mertens’ conjecture. Their
account is eminently readable also for the non-specialist, and their method sug-
gests that a counterexample might exist for an x of order exp(1065 ), but current
algorithmics do not allow us to calculate M for such huge arguments. So we know
√
that an x with M(x) > 1.065 x exists, but we do not know any such x.
Notes 509
Notes. 17.1. The subset sum problem was proven to be NP-complete by Karp (1972);
see problem SP13 of Garey & Johnson (1979). The original successful attack on the Merkle
& Hellman system was by Shamir (1984). Lagarias & Odlyzko (1985) described the short
vector attack, and Odlyzko (1990) gives a nice overview of the problem. Other subset sum
cryptosystems were proposed by Graham & Shamir (see Shamir & Zippel (1980) for a
description), Lu & Lee (1979), Niederreiter (1986), Goodman & McAuley (1984), Ong,
Schnorr & Shamir (1984). Most of them were broken in the 1980s using basis reduction,
among others by Adleman (1983) and Brickell (1984, 1985). The only knapsack type
cryptosystem withstanding all attacks up to now is the Chor & Rivest (1988) scheme.
Many further applications of basis reduction in cryptography are discussed in Nguyen &
Stern (2001).
17.2. Lagarias (1990), §8, surveys pseudorandom number generators in cryptography.
17.3. Dirichlet (1842) showed that there exist simultaneous Diophantine approximations
with absolute error bound q−(1+1/n) , and Lagarias (1982a, 1982b) presents many results
concerning best approximations. Lagarias (1985) discusses the computational complexity
of various such problems, which, depending on the specification, ranges from polynomial-
time to NP-complete. As an example, the following is NP-complete: given β ∈ Q n , as in
Section 17.3, and integers Q, s,t, is there an approximation denominator q with 1 ≤ q ≤ Q
and {{βq}} ≤ s/t?
Exercises.
17.1−→ We consider the following knapsack cryptosystem. The pairs AA, AB, . . ., AZ, BA, BB, . . .,
BZ, . . ., ZA, ZB, . . ., ZZ of letters are identified with the 10-bit representations of the numbers 0, . . .,
262 − 1 = 675. For example, the pair AL corresponds to the bit string x9 x8 · · ·x0 = 0000001011.
Longer messages are broken into two-letter blocks and each block is treated separately.
1. The private key is c9 , . . ., c0 , m, w ∈ N with ci+1 ≥ 2ci for 0 ≤ i ≤ 8, m > ∑0≤i≤9 ci , and
gcd(w, m) = 1.
2. The public key is ai = (wci rem m) ∈ N for i = 0, . . ., 9.
3. A bit string x = x9 x8 · · ·x0 is encrypted as s = ∑0≤i≤9 xi ai ∈ N.
4. To decrypt a ciphertext s, you compute t ∈ N such that t ≡ w−1 s mod m and 0 ≤ t < m. Then
t = ∑0≤i≤9 xi ci ∈ N, and you can reconstruct x9 , x8 , . . ., x0 from t.
(i) Write procedures for encryption and decryption, and check them with the key c0 = 1 and ci+1 =
2ci + 1 for 0 ≤ i ≤ 8, m = 9973, and w = 2001, on the message “ALGEBRAISFUN”.
(ii) Prove that t = ∑0≤i≤9 xi ci actually holds in step 4.
(iii) Now you are an eavesdropper who knows the public key
i 9 8 7 6 5 4 3 2 1 0
ai 2720 2580 5963 5712 7529 8393 6372 6749 6660 2775
(in decimal representation). Try basis reduction to find the original message. This need not work for
all blocks.
Part IV
Fermat
Pierre Fermat (c. 1601–1665) has been called the greatest amateur
mathematician. After growing up in Beaumont-de-Lomagne in Gascony (where
his home now houses an interesting museum⋆⋆ ), he studied in Orléans and
Toulouse, became “commissioner of requests” in 1631, and conseiller du roi in
the local parlement, through which any petitions to the king had to pass. He died
in Castres, where he was in the commission implementing the Édit de Nantes,
which gave some protection to the persecuted protestant Huguenots. Fermat
never left the area, never published a paper, and still became the second-best
mathematician of his century (after Newton). Fermat communicated his
mathematical discoveries in numerous letters, usually without proof and often in
the form of challenges, to his contemporaries. (Among them was René Descartes,
who could only be reached through his friend Marin Mersenne in Paris, because
for many years he lived in Holland without a fixed address—a Flying Dutchman
of mathematics, like the modern-day late Pál Erdős.)
Fermat was a pioneer in several
areas. His method for drawing
a tangent to certain plane curves was
a step in the invention of calculus—
later came Newton and Leibniz.
He invented probability theory, in
extensive correspondence with Blaise
Pascal around 1654. He determined
extrema of functions as zeroes of their
derivative, and used this to calculate
the path of light through different
media according to the “principle of
least time”. There was a controversy
between him and Descartes about
the discovery of analytical geometry;
certainly Fermat was the first to use
it in three dimensions.
But Fermat’s greatest contributions—and those of interest for computer
algebra—were in number theory. He was fascinated by perfect and amicable
numbers, and the Pell–Fermat equation x2 − ny2 = 1. Fermat discovered that
primes of the form 4n + 1 can be represented (in exactly one way) as a sum of two
squares; for example, 29 = 52 + 22 . (It is easy to show that numbers of the form
4n − 1 are never sums of two squares; see Exercise 18.1.) His “method of infinite
descent” can determine the (un)solvability of many Diophantine equations.
⋆⋆ worth the detour
512
Fermat wrote to Bernard Frénicle de Bessy around August 1640 that the numbers
0 1 2 3 4
22 + 1 = 3, 22 + 1 = 5, 22 + 1 = 17, 22 + 1 = 257, and 22 + 1 = 65 537 are
n
primes; he conjectured that all these Fermat numbers Fn = 22 + 1 were prime.
He was wrong; the next values of Fn , at least up to n = 23, are not prime; see
Section 4.3. Not much harm done; he pointed out that he did not have a proof of
his conjecture. We come across Fermat numbers in Chapter 8, where they are
used in the integer Fourier Transform, and Chapter 18. Weil (1984) presents
Fermat’s achievements in detail.
The theorem that includes
Fermat into our little Hall
of Fame is that for a prime
p and an integer a, a p−1 − 1
is divisible by p. He stated
it in a letter to Frénicle on 18
October 1640: Tout nombre
premier mesure infailliblement
une des puissance −1
de quelque progression que
ce soit, et l’exposant de la dite
puissance est sous-multiple du
nombre premier donné −1.1
He forgot to mention that we
have to disallow the geometric
progression a, a2 , a3 , . . .
if p divides a. We will call
it and various generalizations
“Fermat’s little theorem” in this book; they play a crucial role in primality testing
and the factorization of polynomials and integers (Chapters 14, 18, and 19).
Leibniz rediscovered and proved this result in unpublished notes from 1680; see
Notes 4.4. Euler (1732/33, 1747/48) was the first to publish a proof. He also
derived conditions on the factors of Fermat numbers, which led him to the factor
641 of F5 .
Finally, there is Fermat’s (in)famous remark in the margin near the eighth
problem of Book II of Bachet’s translation of Diophantus’ Arithmetic, which
deals with rational solutions of the equation x2 + y2 = z2 : Cubum autem in duos
cubos, aut quadratoquadratum in duos quadratoquadratos & generaliter nullam in
infinitum ultra quadratum potestatem in duos eiusdem nominis fas est dividere;
cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non
1 Every prime number divides invariably one of the powers −1 in any given geometric progression, and the
exponent of this power is a divisor of the given prime number −1.
513
caperet.2 A proof of this eluded mathematicians for over three centuries and
inspired Kummer’s theory of ideals and the construction of large parts of the
edifice of arithmetic algebraic geometry, culminating in Wiles’ proof of
“Fermat’s last theorem” via a special case of the Taniyama–Weil conjecture
(Wiles 1995, Taylor & Wiles 1995; see van der Poorten 1996 for the mathematics
and Singh 1997 for the story). The designation comes from the fact that after all
of Fermat’s claims had been proven, this remained open as the last one.
His son, Samuel de Fermat, published Diophant’s Arithmetic with Fermat’s
annotations, and in 1679 the Varia opera mathematica D. Petri de Fermat,
Senatoris Tolosani. His dedication to Ferdinand II. von Fürstenberg, featured on
page 513, reads: To His Highness Prince Ferdinand, Bishop of Paderborn,
Coadiutor of Münster, Duke of Pyrmont, Free Baron of Fürstenberg. By Samuel
de Fermat S. P. Motto: soft and strong. Ferdinand II. (1626–1683) was a shining
light of Paderborn science, student at the University of Paderborn from 1644 to
1646, erudite author of Monumenta Paderbornensia on the local history,
correspondent with the leading philosophers and scientists of his times, and
sponsor of the arts and architecture. His residence is shown in Figure 13.4.
Fermat’s dedication makes it plausible that he financed the Varia opera.
Samuel de Fermat includes a poem, whose title and first lines are:
2 But it is impossible to divide a cube into two cubes, or a fourth power into two fourth powers, or generally any
power beyond the squares into two like powers; I discovered a truly marvelous proof of this fact. The margin is
too narrow to write it down.
3 On the Prince’s famous work Monumenta Paderbornensia : The Prince, hope and pillar of the chorus of the
Muses, celebrates the sources of the Pader river with his eternal song. Just as he who builds such monuments
towers high, he carries in his way [through his generosity] another work [Fermat’s Opera ] higher up to the stars!
514
Il est remarquable qu’on déduise ainsi du calcul intégral
une propriété essentielle des nombres premiers; mais
toutes les vérités mathématiques sont liées les unes aux autres,
et tous les moyens de les découvrir sont également admissibles.1
Adrien-Marie Legendre (1830)
1 It is remarkable that one should deduce in this way from integral calculus an essential property of the prime
numbers; but all mathematical truths are connected to each other, and all means of discovering them are equally
admissible.
2 “You have said that before,” Kollberg said drily. “It is pure guesswork.”—“The principle of probability.”
18
Primality testing
We want to know whether a given integer is prime or not. Certainly we can find
out by factoring it. Can you think of any other way? Well, there is, and the major
discovery in this area is that primality testing is much easier than factoring, at least
to current knowledge. One can test integers with many thousands of digits, but
factoring numbers with only 300 digits is in general not feasible.
In this chapter, we provide an efficient probabilistic algorithm to test primality;
factorization is the subject of the next chapter. As an easy application, we can also
find large prime numbers, as they are required in some modular algorithms and
in modern cryptography. We conclude with brief discussions of other primality
testing algorithms. The long-standing quest for a deterministic polynomial-time
primality test, stated as a Research Problem in the first two editions of this book,
was resolved by Agrawal, Kayal & Saxena (2004).
For numbers of a special form, such as the Mersenne numbers Mn = 2n − 1,
particularly efficient methods have been known since the 19th century. Indeed,
throughout history the largest known prime has usually been a Mersenne prime.
On 23 August 2008, a UCLA computer managed by Edson Smith discovered
M43 112 609 , the largest among 47 known Mersenne primes. It has 12 978 189 deci-
mal digits. This current world record (at the time of writing) is an achievement of
the Great Internet Mersenne Prime Search (GIMPS), based on software by George
Woltman and Scott Kurowski. This record, together with another one, discovered
two weeks later and slightly smaller, earned a US$ 100 000 award by the Electronic
Frontier Foundation. GIMPS harnesses the spare power of over 20 000 computers
all over the world, and performs about 720 billion calculations per second. This
new paradigm of internet computing started in the area of integer factorization, and
may solve in the future very large instances of such easily distributed problems.
517
518 18. Primality testing
(Section 25.2). The other integers N ≥ 2 are composite. (The number 1 is neither
prime nor composite, but a unit. In the ring Z, −5 is a prime just as 5 is; see
Section 3.1 for a discussion of associates.) The prime numbers form the “building
blocks” for all integers, according to the following basic fact.
The idea of primality was known to the Pythagoreans (around 500 BC), and
Book IX of Euclid’s Elements contains his famous proof that there are infinitely
many primes (see page 26).
This chapter deals mainly with testing whether a given integer √ N is prime or not.
Can we do better than to try division by all integers up to N, a method already
known to Eratosthenes in the third century BC? Yes, indeed, there are efficient
algorithms that differentiate between prime and composite numbers, and as a result
the set of prime numbers is in P . In this text, we only present a probabilistic
algorithm. It shows that this set is in the complexity class ZPP (see Section
25.8), and is eminently practical.
We recall the following facts. Z× N = {a mod N ∈ ZN : gcd(a, N) = 1} is the mul-
tiplicative group of units in ZN = Z/NZ. Remember that a unit in a ring is an
element that has an inverse in the ring. The elements of Z× N form a multiplica-
tive group of cardinality ϕ(N) = #Z× N ; ϕ is Euler’s totient function. If the prime
e1 er
factorization of N is N = p1 · · · pr , where p1 , . . . , pr are distinct positive primes
and e1 , . . . , er are positive integers, then the Chinese Remainder Theorem 5.3 says
that ZN ∼ = Z pe1 × · · · × Z perr (a ring isomorphism), and that Z× ∼ × ×
N = Z pe1 × · · · × Z per r
1 1
(a group isomorphism). If N is prime, then ZN is a field, and Z× N is a group of
order ϕ(N) = N − 1. If N = pe is a prime power, then ϕ(N) = pe−1 (p − 1), and in
general, ϕ(N) = pe11 −1 · (p1 − 1) · · · prer −1 · (pr − 1), by Corollary 5.6.
A central fact is Fermat’s little theorem 4.9 which says that aN−1 ≡ 1 mod N
for a prime N and any a ∈ Z which is coprime to N. For coprime integers a, N
we define the order ordN (a) of a modulo N as the smallest integer k ≥ 1 such
that ak ≡ 1 mod N. Euler’s theorem, generalizing Fermat’s, states that aϕ(N) ≡ 1
mod N, and is a consequence of Lagrange’s theorem (Section 25.1). Besides these
“upper bounds” on the order, we also need some “lower bounds”.
P ROOF. (i) Let e = ordN (a) and divide k by e with remainder: k = qe + r with
0 ≤ r < e. Then ar = ak−qe = ak · (ae )−q ≡ 1 mod N, and hence r = 0. By Euler’s
theorem, we have aϕ(N) ≡1 mod N, and (i) follows.
p p (e−1)i
(ii) We have a ≡ ∑ p ≡ 1 mod pe . By (i), ordN (a) is either 1 or p,
0≤i≤p i
and since a 6≡ 1 mod N, the claim follows. ✷
If a and N are not coprime, then neither are b and N, and the algorithm correctly
returns “composite”. So we may assume that gcd(a, N) = 1. Then by Fermat’s
little theorem, the answer is correct if the test replies “composite”. If it replies
“possibly prime”, it may be right or it may be wrong. We have to understand when
and why an error may occur. To this end, we consider the subgroup of
N−1
LN = {u ∈ Z×
N:u = 1}
of Z× ×
N . Clearly LN is a group, and Fermat’s little theorem says that LN = ZN if N is
× 1 ×
prime. If LN 6= ZN , then in fact #LN ≤ 2 #ZN , since the size of a finite group is an
integer multiple of the size of any of its subgroups, by Lagrange’s theorem (Sec-
tion 25.1). If the a chosen in step 1, taken modulo N, happens to be in Z×N \ LN , then
the test will answer “composite”. Such an a, and also its residue class a mod N, is
called a Fermat witness to the compositeness of N. Similarly, if a mod N ∈ LN ,
then a (and also a mod N) is a Fermat liar for N.
520 18. Primality testing
T HEOREM 18.3.
If N is prime, then the Fermat test 18.2 returns “possibly prime”. If N is compos-
ite and not a Carmichael number, then it returns “composite” with probability at
least 1/2. The algorithm uses O(log N · M(log N)) word operations.
P ROOF. If gcd(a, N) > 1, then also gcd(b, N) > 1, and the test returns “compos-
ite”, so that we only need to consider the cases where a and N are coprime. If N
is composite and not Carmichael, then #LN ≤ ϕ(N)/2, as noted above, so that at
least half of the possible choices for a in step 1 (coprime to N) are Fermat wit-
nesses. Repeated squaring in step 2 takes O(log N) multiplications modulo N or
O(log N M(log N)) word operations, and the bound on the running time follows. ✷
If N is a Carmichael number, then the Fermat test returns either “possibly prime”
or “composite”. The latter happens only when gcd(a, N) > 1.
We now resolve the shortcoming of the Fermat test in a drastic way: the new test
not only distinguishes primes from Carmichael numbers, it actually factors these
seemingly difficult numbers in random polynomial time. In general, factoring
integers is much harder than testing them for primality, and so these numbers turn
out to be quite harmless after all.
P ROOF. We take a prime number p and assume that it divides the Carmichael
number N exactly e ≥ 2 times. By the Chinese Remainder Theorem, there exists
an a ∈ Z with a ≡ 1 + pe−1 mod pe and a ≡ 1 mod N/pe . Then a has order p
modulo pe , by Lemma 18.1, and hence also modulo N. Since aN−1 ≡ 1 mod N, it
follows that p divides N − 1, by the same lemma. Since p also divides N, we have
a contradiction, and the claim is proved. ✷
2. d ←− gcd(a, N)
if d > 1 then return d
6. g ←− gcd(b j + 1, N)
if g = 1 or g = N then return “probably prime” else return g
522 18. Primality testing
T HEOREM 18.6.
If N is prime, then Algorithm 18.5 returns “probably prime”. If N is composite and
not a Carmichael number, then the algorithm returns “composite” with probability
at least 1/2. If N is a Carmichael number, the algorithm returns a proper divisor of
N with probability at least 1/2. It uses O(log N · M(log N)) word operations.
i
P ROOF. By induction, we have bi ≡ a2 m mod N for 0 ≤ i ≤ v, and in particular
bv ≡ aN−1 mod N. If bi−1 = 1, then also bi = 1, for any i. If N is composite and
not Carmichael, then with probability at least 1/2, a is a Fermat witness for N,
bv 6= 1, and the algorithm returns “composite” in step 5. We next assume that N
is prime. Then bv = 1. If b0 = 1, then the algorithm correctly returns “probably
prime” in step 3. Otherwise, we have b j 6= 1 and b2j ≡ b j+1 = 1 mod N in step 6.
By Lemma 25.4, the polynomial x2 − 1 ∈ ZN [x] has at most two zeroes. Hence the
only square roots of 1 modulo N are 1 and −1, so that b j = N − 1 and g = N, and
the correct result is returned in step 6.
The last case to be considered is when N is a Carmichael number. We let P be
the set of prime divisors of N. Since N is squarefree, we have N = ∏ p∈P p. We
consider
2i m
I = {i: 0 ≤ i ≤ v and ∀u ∈ Z×
N u = 1}.
Then v ∈ I, by the definition of Carmichael numbers, and i + 1 ∈ I for any i ∈ I
with i < v. Since m is odd, we have (−1)m = −1 6= 1, and therefore 0 6∈ I. Hence
there exists some l < v such that I = {l + 1, l + 2, . . . , v}. Now let
l
2m
G = {u ∈ Z×
N:u = ±1} ⊆ Z×
N.
This is a subgroup of Z× ×
N , and we now show that G 6= ZN . There exists some p ∈ P
l
and b ∈ Z coprime to p with b2 m 6≡ 1 mod p, since otherwise we would have l ∈ I.
We take some such p and b. The Chinese Remainder Theorem implies that there
exists a c ∈ Z such that c ≡ b mod p and c ≡ 1 mod N/p. Then c mod N ∈ Z× N \ G.
Being a proper subgroup, G has at most #Z× N /2 = ϕ (N)/2 elements.
If a in step 1 is chosen so that a mod N ∈ Z× N \ G, then we claim that the algo-
l+1
rithm will actually discover a proper divisor of N. The fact that bl+1 ≡ a2 m ≡ 1
mod N implies that for all p ∈ P, also bl+1 ≡ 1 mod p. Again, the only square roots
l
of 1 modulo p are 1 and −1, so that for each p, a2 m mod p is either 1 or −1. Since
l
bl mod N = a2 m mod N is neither 1 nor −1, both possibilities actually occur, we
have j = l in step 5, and
g = gcd(bl + 1, N) = ∏ p
p∈P
l
a2 m ≡−1 mod p
The first statement says that a random integer near x is prime with probability
about (ln x)−1 . If we choose random n-bit integers and test them for primality, we
expect to find a prime with about n · ln 2 trials. Throughout this section, “ln” is the
“natural” logarithm for the prime number theory, but we continue to use “log” in
“O” estimates of running times, where the base is irrelevant.
In order to find a large prime p, say with B < p ≤ 2B for some given B, we
simply test uniformly selected random numbers p in the range for primality and
return the first number that passes k such tests, for some given k. On any composite
number, the tests return “probably prime” with probability at most 2−k . One might
then want to conclude that the output is prime with probability at least 1 − 2−k .
This is fallacious. Imagine that there were only few primes between B and 2B, say
just one. Then for small k one would be much more likely to receive a composite
number than a prime. Thus the density of the primes enters the following result.
T HEOREM 18.8.
Given positive integers B, k, the output of the above procedure is prime with prob-
ability at least 1 − 2−k+1 ln B. It uses an expected number of O(k(log2 B)M(log B))
word operations.
P ROOF. The probability space here is the set of all random choices within the
procedure. By the prime number theorem, the set P of primes considered has size
B 3 B
#P = π (2B) − π (B) ≥ 1− ≥ , (1)
ln B ln B 2 ln B
18.4. Finding primes 525
P ROOF. There are at most loga |M| ≤ loga C primes in P that divide M. ✷
We are now in a position to provide one of the ingredients for the modular
algorithms for the determinant (Section 5.5), gcds and the Extended Euclidean
Algorithm (Chapter 6), root finding (Sections 14.5 and 15.6), and factorization
(Chapters 15 and 16) in Z[x], and for cryptography: finding suitable primes. Table
18.1 summarizes the costs and requirements. The second last algorithm does not
occur explicitly in Section 16.5; essentially, one has to replace the first four steps of
526 18. Primality testing
cost for
modular prime requirements prime algorithm
algorithm finding
deter- big prime §5.5 p > 2nn/2 An n3 log3 A n4 log A
minant small primes 5.10 p1 , . . . , pr < 2r ln r n log A n4 log A
√
big prime 6.34 p > n+1 · 2n+1 A2 n +log3 A
3 2
n +n log A
gcd
small primes 6.38 p1 , . . . , pr < 2r ln r n log A n2 +n log A
EEA small primes 6.57 p1 , . . . , pr < 2r ln r n log A n3 log A
root big prime 14.17 p > 2n(A2 +A) log3 A n log A+n log2 A
2
TABLE 18.1: Costs and requirements of various modular algorithms on inputs of degree
(or dimension) n and max-norm at most A. For all small prime and prime power algorithms,
there is a parameter r ∈ O(n log(nA)). For some big prime algorithms, we also have the
requirement that p does not divide a certain subresultant, of word length O(n log(nA)).
The last column contains the running time for the remaining algorithm without the prime
finding stage. All stated costs are with fast arithmetic and ignore logarithmic factors.
Algorithm 16.22 by the first three steps of the big prime algorithm 15.2. For most
algorithms, we see in the fourth column that the time for finding one or several
small primes is much less than the time for finding a big prime; in practice, we
would work with a precomputed list of small primes, as discussed below. However,
also the remaining stages of small primes and prime power algorithms are faster
than the corresponding stages of their big prime counterparts: in theory only by
logarithmic factors, which do not show up in the last column of Table 18.1, but
they are clearly visible in practice (see Section 6.13).
T HEOREM 18.10.
(i) There is a probabilistic algorithm which, with probability at least 3/4, re-
turns a prime p between B +1 and 2B, for any positive integer B ∈ N of word
length β . Moreover, if M ∈ Z is a nonzero number such that 6 ln |M| ≤ B,
then p is prime and p does not divide M with probability at least 1/2. The
algorithm takes O(β 2 · M(β ) log β ) word operations.
P ROOF. (i) If B ≥ 6, then Theorem 18.8 with k = 2 + ⌈log2 ln B⌉ gives the first
claim. Using Lemma 18.9 and (1), we find that p divides M with probability
18.4. Finding primes 527
at most
logB C lnC · 2 ln B 1
≤ ≤
#P ln B · B 3
if it is prime. Therefore the probability that p has the required properties is at least
3 1 1 B/6
4 (1 − 3 ) = 2 . If B ∈ {1, . . . , 5}, then |M| ≤ ⌊e ⌋ ≤ B, so that none of the primes
between B + 1 and 2B divides M, and we may take one of 2, 3, 5, or 7 for p.
(ii) We have pr < r(ln r + lnln r − 1/2) ≤ 2r ln r for r ≥ 20, by the prime number
theorem 18.7. In fact, pr < 2r ln r for all r ≥ 2. We find our primes by the sieve
of Eratosthenes, as follows. We write down a list of all integers below x = 2r ln r.
Then we cross out all even numbers, all multiples of 3, all multiples of 5, and so
√
on, for each prime less than x. The remaining integers are not divisible by a
√
prime less than x, and hence they are prime. The cost is ⌊x/p⌋ steps for each
√
prime p ≤ x, altogether at most
1
x ∑√ ∈ O(x loglog x)
p< x
p
p prime
Our first application is the big prime modular gcd algorithm 6.34.
C OROLLARY 18.11.
Let n ∈ N≥2 , f , g ∈ Z[x] be primitive, with degrees at most n and max-norms at
most A, h = gcd( f , g), b = gcd(lc( f ), lc(g)), B = ⌈(n + 1)1/2 2n+1 bA⌉, and β =
log B. If n ≥ 5 or A ≥ 5, then we can find an integer p with B < p ≤ 2B such that,
with probability at least 1/2, p is prime and does not divide res( f /h, g/h). This
algorithm uses O(β 2 M(β ) log β ) or O∼ (n3 + log3 A) word operations.
P ROOF. We let σ = res( f /h, g/h), and have |σ | ≤ (n + 1)n A2n , by Theorem 6.35,
and therefore 6 ln |σ | ≤ 12n ln((n + 1)A). Since 12n < 2n+1 and ln((n + 1)A) <
(n + 1)1/2 A if n ≥ 5, and
in spite of their conceptual simplicity. In Figure 6.4 the big prime running times
are quite erratic, but smooth when the cost of prime generation is suppressed. In
small primes or prime power modular algorithms, the cost of obtaining primes is
negligible.
The prime finding step in the factorization algorithms 15.2 (big prime) and 15.19
and 16.22 (prime power) in Z[x] is quite inexpensive.
C OROLLARY 18.12.
Let f ∈ Z[x] be squarefree of degree n ≥ 2 and with max-norm || f ||∞ = A, γ =
2n ln((n + 1)A), and suppose that A ≥ 5 if n ≤ 4.
(i) There is a probabilistic algorithm which, with probability at least 1/2, out-
puts a prime p between B + 1 and 2B and not dividing res( f , f ′ ), where
B = ⌈(n + 1)1/2 2n+1 | lc( f )|A⌉. Then β = log B ∈ O(n + log A), and the al-
gorithm uses an expected number of O(β 2 M(β ) log β ) or O∼ (n3 + log3 A)
word operations.
(ii) With O(γ log2 γ loglog γ ) or O∼ (n log A) word operations we can find (prob-
abilistically) a prime p of word length in O(log γ ) and such that p ∤ res( f , f ′ )
with probability at least 1/2.
With some more calculations using the prime number theorem one can shave off
a logarithmic factor in the estimate of (ii) (Exercise 18.21). Similar improvements
are possible for small primes modular determinant computation (Algorithm 5.10),
small primes modular gcd computation (Algorithm 6.38), and the small primes
modular EEA (Algorithm 6.57).
A software implementation of small primes or prime power modular algorithms
should precompute a table of small primes, so that for most purposes only table
look-up is needed. Rather than using the first primes, it is more efficient to take
the largest single precision primes. As discussed at the beginning of Chapter 5 and
in Section 8.3, it is advantageous in the small primes modular approach to choose
p1 , . . . , pr to be Fourier primes, so that pi − 1 is divisible by some large power 2t
of 2, for all i. There are quantitative versions of Dirichlet’s (1837) famous theo-
rem on primes in arithmetic progressions that give asymptotic estimates, but even
18.5. The Solovay and Strassen test 529
the best versions (Alford, Granville & Pomerance 1994, Bach & Sorenson 1996)
are considerably less precise than the prime number theorem 18.7. For practical
purposes, however, it is reasonable to assume that a random number p ≡ 1 mod 2t
near x is prime with probability about 2/ ln x. To find enough such primes, we
consecutively test 2t + 1, 2 · 2t + 1, 3 · 2t + 1, . . . for primality until we have found r
primes. This will be a precomputation stage. Exercise 18.19 estimates the number
of single precision Fourier primes for 32-bit and 64-bit processors.
In our big prime algorithms for gcd computation and factorizations, it may hap-
pen that the number p given by Theorem 18.10 is not prime. If we stumble upon
a nonzero element which is not invertible in our computation, then we recognize
our p as composite and start all over again with a new one. However, it may hap-
pen that all computations go through even if p is composite. In the gcd case, it
is possible to show that the output is nevertheless correct, but in the polynomial
factoring algorithm, reducible polynomials may wrongly be declared irreducible.
However, this only happens with probability at most 1/2, by Theorem 18.10, and
we may simply rerun the whole algorithm several times independently to make the
error probability arbitrarily small. Or, preferably, we use the prime power factoring
algorithm, which is faster and returns the complete factorization in any case.
are equal unless and only unless both a and N are congruent to 3 modulo 4. The
Jacobi symbol is the generalization to an arbitrary odd N. If N = pe11 · · · per r is its
prime factorization, then it is defined as
e1 er
a a a
= ··· .
N p1 pr
530 18. Primality testing
This quantity can be computed by an efficient method, akin to the Euclidean Al-
gorithm, without actually factoring N (Notes 18.5 and Exercise 18.23).
When N is a prime, then Lemma 14.7 implies that
a
≡ a(N−1)/2 mod N (3)
N
for all a ∈ Z. Solovay & Strassen (1977) prove that (3) is false for at least half of all
a in {1, . . . , N −1} if N is composite and not a prime power. Their algorithm checks
(3) for randomly chosen a; each test takes O(log N · M(log N)) word operations.
Although Berlekamp’s (1970) probabilistic algorithm for factoring polynomials
(Section 14.8) had been around for a while, it was the Solovay & Strassen (1977)
result for integers that aroused widespread interest in the power of randomized al-
gorithms. (Are numbers more intuitive to computer scientists than polynomials?
The reader should by now—and even more so after reading Chapter 19—be con-
vinced that polynomials are much easier objects than numbers.) See Notes 6.5.
101031 − 1
=
9
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111
11111111111.
Notes. Good references for the material of this chapter are Knuth (1998), §4.5.4, Koblitz
(1987a), Bach (1990), Lenstra & Lenstra (1990), Lenstra (1990), Adleman (1994), and
Bach & Shallit (1996).
The word prime number (πρω̃τος ἄριθμος) comes, according to Iamblichus, from the
fact that in Eratosthenes’ sieve (Section 18.4) they are the first to appear in the sequence of
their multiples which have to be removed.
An integer is perfect if it equals the sum of all its proper divisors; 6 = 1 + 2 + 3 is an
example. Euclid proves in Proposition 36 of Book 9 of his Elements that 2n−1 Mn is perfect
for any Mersenne prime Mn (Exercise 18.11); for n = 2 and 3 we obtain 6 and 28. The
39th known Mersenne prime provides in this way the largest known perfect number (at the
time of writing).
The idea of internet computing was pioneered by Silverman in the area of factoring inte-
gers (see Caron & Silverman 1988), and became popular with Lenstra & Manasse’s (1990)
article. All about Mersenne prime records can be found at http://www.mersenne.org.
18.2. Carmichael numbers have their name from the work of Carmichael (1909/10, 1912).
Mahnke (1912/13) discusses Leibniz’ proof of Fermat’s little theorem (see Notes 4.4) and
his attempts at a converse; Leibniz thought for a while that N is prime if 2N−1 ≡ 1 mod N.
In his discussion, Mahnke gives the defining property of Carmichael numbers, proves that
neither a prime power nor a product of two primes is Carmichael, and gives five examples,
including 561. He mentions a letter of Bachmann with similar results. Actually, Ball &
Coxeter (1947), first issued in 1892, attribute a Chinese origin to Leibniz’ incorrect pri-
mality criterion, and Tarry (1898) asked in the 19th century version of sci.math whether
532 18. Primality testing
the criterion is true. In his 11-line reply, Korselt (1899) gives the definition of Carmichael
numbers (as on page 520) and states that he has proved the characterization of Exercise
18.9 (ii), namely squarefreeness and divisibility of N − 1 by the least common multiple of
all p − 1. Thus we may consider Korselt as the discoverer of Carmichael numbers, and
the characterization is known as Korselt’s criterion. The editor notes after Korselt’s reply
that five other replies were received to this question; toutes à peu près dans le même sens1 .
Lenstra (1979b) proves that if aN−1 ≡ 1 mod N for every prime a < ln2 N, then N is
squarefree.
18.3. Miller (1976) proposed a deterministic version of the strong pseudoprimality test
18.5 and showed that it runs in polynomial time under the ERH (Theorem 18.6), and Rabin
(1976, 1980a) suggested the probabilistic variant. Neither of the two algorithms looks for
factors of Carmichael numbers. Earlier versions of the test were given by Dubois (1971)
and Selfridge (not later than 1974, unpublished), but they did not reach a wide audience.
Dubois suggests the strong pseudoprimality test with a = 2, 3, and 5. He is well aware that
it may fail, and proposes to use a = 7 as well. See the end of these Notes for the smallest
N on which this variant fails.
Bach, Miller & Shallit (1986) state a generalized version of Algorithm 18.5 for integer
factorization, without actually mentioning the application to the Carmichael case. The fact
that Carmichael numbers can be factored in random polynomial time seems to be folklore.
Alford, Granville & Pomerance (1994) solved a long-standing open problem by proving
that there are infinitely many Carmichael numbers.
For an odd composite integer N, the probability for a random a ∈ {1, . . . , N − 1} with
gcd(a, N) = 1 to be a strong liar is at most 1/2, by the proof of Theorem 18.6. Rabin
(1980a), Monier (1980), and Atkin & Larson (1982) have shown the smaller bound 1/4. To
generate random primes, suppose that we fix n and k, choose n-bit odd numbers uniformly
at random, subject them to k strong pseudoprimality tests, and return the first one that
passes all these tests. We call pn,k the probability that a composite number is returned.
Damgård, Landrock & Pomerance (1993) deal with the subtleties of estimating pn,k , as
noted before Theorem 18.8, and prove several estimates, for example:
1 15/4 −n/2−2k
p600,1 ≤ 2−75 , pn,k < n 2 if 4k ≥ n ≥ 21.
7
All reasonably small numbers have small strong witnesses: Pomerance, Selfridge & Wag-
staff (1980) prove that for all composite N ≤ 25 × 109 (except for N = 3 215 031 751), at
least one of 2, 3, 5, and 7 is a strong witness. Pinch (1993) describes erroneous results of
primality tests implemented in some computer algebra systems.
Both the Solovay–Strassen and the strong pseudoprimality tests should properly be
called compositeness tests because they show the set P RIMES of all prime numbers is in
co-RP and its complement (without 0 and 1) C OMPOSITES is in RP, which is a (possibly
proper) subset of BPP (Section 25.8), but the wrong terminology has stuck.
18.4. The prime number theorem is a central result in number theory, and has a long and
distinguished history. Proofs of the asymptotic version stated first in Theorem 18.7 are in
many texts, for example Hardy & Wright (1985). The precise version stated in Theorem
18.7 is from Rosser & Schoenfeld (1962).
1 all in about the same sense
Notes 533
An early attempt at the prime number theorem was by Legendre (1798), and Gauß
(1849) said that he found the estimate around 1792. Chebyshev (1849, 1852) proved that
π(x) is asymptotically x/ ln x, up to a constant factor, and de la Vallée Poussin (1896) and
Hadamard (1896) proved that π(x) = x/ ln x + R
o(x/ ln x). A better approximation is given
by the logarithmic integral π(x) ≈ Li(x) = 2x dt/ lnt.
A vital tool in modern prime number theory is Riemann’s (1859) zeta function ζ(s),
a meromorphic function on the complex plane. It is obtained by analytic continuation of
which is defined when ℜs > 1, and which already Euler used. Riemann made his fa-
mous conjecture, the Riemann Hypothesis, that all zeroes s of ζ lie on the critical line
ℜs = 1/2: [. . .] und es ist sehr wahrscheinlich, dass alle Wurzeln [von ζ( 12 + it)] reell sind.
Hiervon wäre allerdings ein strenger Beweis zu wünschen; ich habe indess die Aufsuchung
desselben nach einigen flüchtigen vergeblichen Versuchen vorläufig bei Seite gelassen, da
er für den nächsten Zweck meiner Untersuchung entbehrlich schien.2 A proof of this
conjecture, still elusive after over 130 years, would imply dramatic improvements in the
estimates for the error term in the prime number theorem. Clever methods have been de-
vised to calculate billions of roots of the zeta function (van de Lune, te Riele & Winter
1986, Odlyzko & Schönhage 1988, Odlyzko 1995c); fast arithmetic is a must for such
high-performance calculations.
Already Legendre (1798) had used a logarithmic integral, but he was well aware that he
had no proof of his (incorrect) formula. He set the task solved in this chapter: Il serait à
désirer, pour la perfection de la théorie des nombres, qu’on trouvât une méthode praticable
au moyen de laquelle on pût décider assez promptement si un nombre donné est premier
ou s’il ne l’est pas.3 Did he already feel that there is a computational difference between
testing primality and factoring?
The zeta function has been generalized from integers to algebraic number fields. The
conjecture that all those generalizations have their zeroes on the critical line is called the
Extended Riemann Hypothesis. For several algorithms, the estimates of their running time
(or their proofs of correctness) rely on the ERH; see Notes 14.9.
Pritchard (1983, 1987) and Sorenson (1998) give several more efficient versions of the
sieve of Eratosthenes.
18.5. We heard the “unless and only unless” from Hendrik Lenstra. The “iff” was coined
by Halmos (see Halmos 1985, page 403), and Conway invented comic imitations like
“unlesss”.
Monier (1980) compares the two tests by Solovay & Strassen (1977) and by Miller and
Rabin. Eisenstein (1844) and Lebesgue (1847) present algorithms for the Jacobi symbol.
They are analyzed in Shallit (1990), and efficient methods are given by Bach & Shallit
(1996), §5.9, and Meyer & Sorenson (1998).
Miller, Rabin, Solovay, and Strassen shared the ACM Paris Kanellakis Award for their
work.
2 [. . .] and it is very probable that all roots [of ζ( 1 + it)] are real. A rigorous proof of this would be desir-
2
able; I have, however, left aside the quest for one after several brief and unsuccessful attempts, since it seemed
dispensable for the immediate goal of my investigation.
3 It would be desirable for the perfection of number theory to find a practical method by which one should be
able to decide fairly quickly whether a given number is prime or not.
534 18. Primality testing
18.6. See Bach & Shallit (1996) for details on Pepin’s test, and Hardy & Wright (1985),
§2.5, for the example F5 . In fact, Pepin used 5 instead of 3 as his witness. It is widely
conjectured that no Fn > F4 is prime, but Wagstaff (1983) has conjectured that
eγ
#{p < x M p is prime} ≈ lnln x ≈ 2.57 lnln x,
ln 2
where γ = 0.5772156649 . . . is Euler’s constant. In particular, this would imply that there
are infinitely many Mersenne primes. The term “Mersenne number” was apparently coined
by Rouse Ball in 1892 (see Ball & Coxeter 1947, page 65: Mersenne’s Numbers ), and
“repunit” is from Beiler (1964), page 83.
Further notes. The largest twin primes known at the time of writing are 1 807 318 575 ·
298305 ± 1, with 29 603 decimal digits, discovered by Underbakke, Carmody, and Gallot.
Caldwell’s prime list http://www.utm.edu/research/primes regularly updates this
and many other prime records. These numbers have a very special form and can be proven
to be prime by deterministic methods which are far too slow for general numbers of this
size.
Exercises.
18.1 Show that a2 + b2 ≡ 0, 1, or 2 modulo 4 for all a, b ∈ Z.
18.2 Compute 21 000 005 mod 55. Hint: This needs virtually no calculation.
18.3 Which of the two integers 10200 +349 and 10200 +357 is probably prime and which is certainly
composite? You may use a computer algebra system to find this out, but you should not use routines
like isprime or ifactor. Warning: not every exponentiation routine is suited for solving this task.
18.4∗ You are to determine precisely the error probability of the Fermat test in a special case. Let
p 6= q be primes with p ≡ q ≡ 3 mod 4 and gcd(p − 1, q − 1) = 2, and N = pq.
(i) Prove that gcd(N − 1, p − 1) = 2, and conclude that {uN−1 : u ∈ Z× 2 ×
p } = {u : u ∈ Z p } and
prob(a N−1 ≡ 1 mod p) = 2/(p − 1) for a uniform random element a ∈ {1, . . ., p − 1}. Hint: Ex-
ercise 14.11.
(ii) Calculate the probability that the Fermat test outputs “possibly prime” on input N, assuming
that a is chosen from {1 ≤ c < N: gcd(c, N) = 1} uniformly at random in step 1. Compare your result
numerically to the estimate from Theorem 18.3 for p = 79 and q = 83.
18.7 Prove that for N = 3 215 031 751, the smallest strong witness is 11.
18.8 Find a 20 decimal digit prime. Explain how you obtained it and why you believe it is prime.
You may find functions such as M APLE’s isprime useful.
Exercises 535
18.14∗ Let N > 1 be an odd integer, λ(N) as in Exercise 18.13, and CN = {a ∈ Z× N:a
λ(N)/2 = ±1}.
×
(i) Prove that CN is a multiplicative subgroup of ZN .
(ii) Show that if N = pe for some e ≥ 1 and some prime p, then CN = Z× N . Hint: Exercise 9.40.
(iii) Prove the converse of (ii). Hint: CRT.
(iv) Recall that N is a perfect power if N = ml for some integers m, l > 1. Discuss whether the
following is a good primality testing algorithm: First check whether N is a perfect power. If it is not,
then output “probably prime” if aλ(N)/2 = ±1 for a randomly chosen a ∈ Z× N , and return “composite”
otherwise.
536 18. Primality testing
(i) The small primes modular determinant algorithm 5.10 and the small primes modular EEA 6.57
only require that we find a collection of primes p1 , . . ., pr ≤ x such that their product exceeds a given
bound C ∈ R>0 , and we took the first r ≈ log2 C primes for simplicity (Theorems 5.12 and 6.58),
so that x = pr ≈ (log2 C) ln log2 C. But in fact, ϑ(x) ≥ lnC is sufficient, which leads to the choice
x ≈ lnC, by the above, so that r = π(x) ≈ lnC/ lnlnC. Work out the details and show that the cost
of Algorithms 5.10 and 6.57 drops to O(n4 log(nB) loglog(nB) + n3 log2 (nB)) and O(n3 m log2 (nA))
word operations, respectively.
(ii) In Corollary 18.12 (ii), the requirement is slightly different: we need r primes such that
the product of each r/2 of them exceeds the discriminant bound C. Thus we may take x ≈ lnC
and r = 2π(x) ≈ 2 lnC/ lnlnC. Use this to improve the cost estimate of Corollary 18.12 (ii) to
O(γ log γ loglog γ) word operations.
18.22 Let p ∈ N be an odd prime.
(i) Prove that 4 divides p − 1 if −1 is a square modulo p. Hint: Lagrange’s theorem.
(ii) Prove the converse of (i). Hint: Consider a(p−1)/4 for a nonsquare a ∈ F×
p.
(iii) Conclude that the Legendre symbol ( −1
p ) is 1 if and only if p ≡ 1 mod 4.
18.23∗ (i) Show that the Jacobi symbol is multiplicative with respect to both arguments:
ab a b a a a
= , =
N N N MN M N
for all a, b, M, N ∈ N>0 with M, N ≥ 3 odd.
(ii) Prove that the law of quadratic reciprocity also holds for the Jacobi symbol: If a, N ∈ N are
coprime and odd, then ( Na ) and ( Na ) are equal unless and only unless a ≡ N ≡ 3 mod 4.
(iii) A special case of the law of quadratic reciprocity is that ( N2 ) = 1 if and only if N ≡ ±1 mod 8
for an odd prime N ∈ N. Prove that this also holds for the Jacobi symbol, where N ≥ 3 is an arbitrary
odd integer.
(iv) Show that ( Na ) = ( a rem
N
N
) for all a, N ∈ N≥1 with N ≥ 3 odd.
(v) Write an efficient algorithm that, given an odd integer N > 1 and a ∈ {1, . . ., N − 1}, computes
the Jacobi symbol ( Na ), and analyze its cost.
18.24∗ (Lehmann 1982) Let N ∈ N≥3 be odd, σ: Z× ×
N −→ ZN the power map σ(a) = a
(N−1)/2 , and
×
T = im(σ) ⊆ ZN .
(i) Show that T = {1, −1} if N is prime.
(ii) Prove that T 6= {1, −1} if N is not a prime power. Hint: Assume that −1 ∈ T and apply the
Chinese Remainder Theorem.
(iii) Show that T 6= {1, −1} if N = pe for a prime p ∈ N and e ∈ N≥2 . Hint: Lemma 18.1.
(iv) Prove that N is a Carmichael number if T = {1}.
(v) Consider the following algorithm.
A LGORITHM 18.13 Lehmann’s primality test.
Input: An odd integer N ≥ 3 and a parameter k ∈ N.
Output: Either “probably composite” or “probably prime”.
1. for i = 1, . . ., k do
2. choose ai ∈ {1, . . ., N − 1} uniformly at random
(N−1)/2
3. call the repeated squaring algorithm 4.8 to compute bi = ai rem N.
4. if {b1 , . . ., bk } 6= {1, −1} then return “probably composite” else return “probably prime”
Prove that the algorithm outputs “probably prime” with probability at least 1 − 21−k if N is prime,
and that it outputs “probably composite” with probability at least 1 − 2−k if N is composite.
538 18. Primality testing
(vi) Prove that Lehmann’s algorithm can be executed with O(k log N · M(log N)) word operations.
(vii) Discuss the following modification of step 4: if bi = −1 for 1 ≤ i ≤ k, then the algorithm
should return “probably prime” as well.
(viii) For each of the composite numbers N = 343, 561, 667, and 841, compute T and determine
exactly the error probability of Lehmann’s algorithm for k = 10 (you may assume that gcd(ai , N) = 1
for all i). Compare your results to the estimate from (v).
n
18.25∗ Let Fn = 22 + 1 be the nth Fermat number, for n ∈ N.
(i) Assume that Fn is prime. Show that 3 and 7 are nonsquares modulo Fn if n ≥ 1 and that 5 is a
nonsquare modulo Fn if n ≥ 2. Hint: Exercise 18.23.
(ii) Conclude that for n ≥ 1, Pepin’s (1877) test works correctly: Fn is prime if and only if
3(Fn −1)/2 ≡ −1 mod Fn .
(iii) Show that Pepin’s test can be performed with O(2n M(2n )) word operations.
n
18.26∗ Let n ∈ N≥2 , Fn = 22 + 1 the nth Fermat number, and p ∈ N a prime divisor of Fn . Prove
that 2n+2 | p − 1. Hint: Lagrange’s theorem and Exercise 18.23.
Problema, numeros primos a compositis dignoscendi,
hosque in factores suos primos resolvendi, ad gravissima
ac utilissima totius arithmeticae pertinere [. . . ] tam notum est,
ut de hac re copiose loqui superfluum foret. [. . . ] Praetereaque
scientiae dignitas requirere videtur, ut omnia subsidia ad solutionem
problematis tam elegantis ac celebris sedulo excolantur.1
Carl Friedrich Gauß (1801)
1 The problem of distinguishing prime numbers from composite numbers and of resolving the latter into their
prime factors is so well known to be one of the most important and useful in arithmetic [. . . ] that it is superfluous
to speak at length about this matter. [. . . ] Further, the dignity of the science itself seems to require that every
possible means be explored for the solution of such an elegant and celebrated problem.
2 Anton Felkel [. . .] had completed the manuscript of his table [of factors of integers] up to two million [. . .] ; the
parts that had been printed in Vienna with a government grant did not sell and were, unfortunately, used to make
cartridges in the war against the Turks!
3 The equation x2 − y2 = N is of paramount importance in the factorization problem.
19
Factoring integers
In this chapter, we present several of the algorithms listed in Table 19.1 to factor
an integer N of length n into its prime divisors. The running time of Lenstra’s
algorithm actually depends not on n, but mainly on the size of the second largest
prime factor of N. Some of the timing analyses are only heuristic, not rigorously
proven. We note that the input size is n ≈ log2 N/64 words.
method year time
trial division −∞ O∼ (2n/2 )
Pollard’s p − 1 method 1974 O∼ (2n/4 )
Pollard’s ρ method 1975 O∼ (2n/4 )
Pollard’s and Strassen’s method 1976 O∼ (2n/4 )
Morrison’s and Brillhart’s continued fractions 1975 exp(O∼ (n1/2 ))
Dixon’s random squares 1981 exp(O∼ (n1/2 ))
Lenstra’s elliptic curves 1987 exp(O∼ (n1/2 ))
number field sieve 1990 exp(O∼ (n1/3 ))
The reader will become convinced that a fair amount of mathematical ingenuity
has been spent on this problem, and that modern methods can attack surprisingly
large numbers. But in comparison to the striking success in factoring polynomials
(say, of degree 1 000 000 over F2 ), the current records, still under 300 digits, are
disappointingly small. This is a manifestation of the practical relevance of poly-
nomial time.
In Chapter 20, we will see how this disappointment has been turned around to
major progress in another area: the assumed difficulty of factoring is important for
the security of some cryptosystems.
541
542 19. Factoring integers
The elliptic curve method has been successful in finding some of the “most
wanted” factorizations of the Cunningham project, in particular for some Fermat
numbers. Table 19.2 shows the history of factorizations of Fermat numbers Fn ;
pk stands of a prime number with k decimal digits. Richard Brent (1999) reports
on two factorizations that he calculated:
F10 = 45 592 577 · 6 487 031 809 ·
4 659 775 785 220 018 543 264 560 743 076 778 192 897· p252 ,
F11 = 319 489 · 974 849 · 167 988 556 341 760 475 137 · 3 560 841 906 445 833 920 513· p564 ,
He factored the 617-digit number F11 in 1988, and F10 (with 309 decimal digits)
in 1995; the former was easier for his elliptic curve software because its second-
largest prime divisor has 22 digits vs. 40 digits for F10 and it is this second-largest
divisor that determines the running time of the elliptic curve algorithm. Numbers
of this size are typically outside the reach of modern factorization software. The
next Fermat number factors as
F12 = 114 689 · 26 017 793 · 63 766 529 · 190 274 191 361 · 1 256 132 134 125 569 · c,
1 http://www.cerias.purdue.edu/homes/ssw/cun/index.html
19.2. Trial division 543
To find all prime factors, we divide out p as often as possible and continue as
illustrated in Figure 19.3. When calling the algorithm again (with some larger
value of b in case of failure), we may of course use that the input has no prime
factors below p. This procedure will terminate when p is the second largest prime
factor of N.
544 19. Factoring integers
extract largest
possible root found
factors
For N ∈ N, we let S1 (N) denote the largest prime divisor of N, and S2 (N) the
second largest prime divisor of N. Thus S2 (N) < N 1/2 . The number of steps
required by trial division is S2 (N)(log N)O(1) . For random integers N,
prob(S1 (N) > N 0.85 ) ≈ 0.20, prob(S2 (N) > N 0.30 ) ≈ 0.20.
Thus, the number of steps needed for the trial division algorithm is O∼ (N 0.30 )
“most of the time”.
c2 ! = ∏ f (ic).
0≤i<c
1. c ←− ⌈b1/2 ⌉
call Algorithm 10.3 to compute the coefficients of f = ∏ (x + j) ∈ ZN [x]
1≤ j≤c
4. return min{kc + 1 ≤ d ≤ kc + c : d | N}
T HEOREM 19.3.
Algorithm 19.2 works correctly and uses O(M(b1/2 )M(log N)(log b + loglog N))
word operations and space for O(b1/2 log N) words.
P ROOF. For 0 ≤ i < c, a prime divisor p of N divides F(ic), and hence also
gcd(gi , N) = gcd(F(ic) rem N, N), if and only if p divides some number in the
interval {ic + 1, . . . , ic + c}, and the correctness follows.
By Lemma 10.4 and Corollary 10.8, the cost for steps 1 and 2 is O(M(c) log c)
additions and multiplications in ZN . Step 3 takes O(c M(log N) loglog N) word
operations, as noted in the end of Section 11.1, and step 4 takes O(c M(log N))
word operations, by Theorem 9.8. The cost for one addition or multiplication in ZN
is O(M(log N)), by Corollary 9.9, and we get a total cost of O(M(b1/2 )M(log N) ·
(log b + loglog N)). We have to store O(b1/2 ) integers of length O(log N). ✷
C OROLLARY 19.4.
Using Algorithm 19.2, we can completely factor N with
O M(S2 (N)1/2 )M(log N) log N or O∼ (N 1/4 )
P ROOF. Let s be the number of choices until a collision occurs, that is, two iden-
tical balls are chosen. This is a random variable. For j ≥ 2, we have
1 i−1
prob(s ≥ j) = j−1 ∏ (p − (i − 1)) = ∏ 1 −
p 1≤i< j 1≤i< j p
2
≤ ∏ e−(i−1)/p = e−( j−1)( j−2)/2p ≤ e−( j−2) /2p ,
1≤i< j
Floyd’s cycle detection trick. Given an integer x0 ∈ {0, . . . , p−1} and a function
f : {0, . . . , p − 1} −→ {0, . . . , p − 1}, we examine the sequence x0 , x1 , . . . defined by
xi+1 = f (xi ) for i ≥ 0. This is an infinite sequence from a finite set, so that at
some point the values repeat. This results in a cycle of some length l > 0 such that
xi = xi+l for all i ≥ t, for some t ∈ N. We may assume that l and t are minimal with
that property. In Figure 19.4, we see an example with t = 3 and l = 7.
An obvious method to find i 6= j such that xi = x j is to write down the sequence
until a value repeats itself, but this requires space O(t +l). The following algorithm
uses only constant space. The idea of Floyd’s 1-step/2-step cycle detection method
19.4. Pollard’s rho method 547
x5
x4
x6
x3 = x10
x7
x9
x8
x2
x1
x0
is to use a second sequence (yi )i∈N that iterates f with double speed, so that yi = x2i
for all i, and to store only the current values of xi and yi . Intuitively, it should be
clear that the “faster” sequence “overtakes” the slower one for some i, and then we
have x2i = yi = xi .
1. y0 ←− x0 , i ←− 0
3. return i
The following lemma says that the number of steps until the first collision xi = yi
in Floyd’s method occurs is at most the number of steps until the first collision
xi = x j with i < j happens.
548 19. Factoring integers
L EMMA 19.7. With t and l as above, Algorithm 19.6 halts after at most t +l steps.
P ROOF. Since yi = x2i for all i, we have xi = yi if and only if i ≥ t and l | (2i−i) = i,
and the smallest positive such index is i = t + (−t rem l) < t + l if t > 0, and i = l
if t = 0. ✷
2. repeat
2
3. i ←− i + 1, xi ←− xi−1 + 1 rem N, yi ←− (y2i−1 + 1)2 + 1 rem N
4. g ←− gcd(xi − yi , N)
if 1 < g < N then return g
else if g = N then return “failure”
T HEOREM 19.9.
Let N ∈ N be composite, p its smallest prime factor, and f (x) = x2 + 1. Under
the assumption that the sequence ( f i (x0 ))i∈N behaves modulo p like a random se-
quence, the expected running time of Pollard’s algorithm for finding the smallest
√
prime factor p of N is O( p M(log N) loglog N). By applying the algorithm re-
cursively, N can be completely factored in expected time S2 (N)1/2 O∼ (log2 N), or
O∼ (N 1/4 ).
i xi mod N xi mod 41
i xi mod N xi mod 41
0 631 16
6 40 816 21
1 69 670 11
7 80 802 32
2 28 986 40
8 20 459 0
3 69 907 2
9 71 874 1
4 13 166 5
10 6685 2
5 64 027 26
The iteration modulo 41 is illustrated in Figure 19.4; the algorithm’s name derives
from the similarity to the Greek letter ρ. It leads to the factor gcd(x3 −x10 , N) = 41.
When we execute the algorithm, only the values modulo N are known; the values
modulo 41 are included for our understanding. The algorithm calculates in tandem
xi and yi = x2i and performs the gcd test each time. We have t = 3, l = 7, and
t + (−t rem l) = 7, and in fact, after seven 2-steps the algorithm catches up with
the 1-steps:
N = s2 − t 2 = (s + t)(s − t),
2 2
a+b a−b
N = a·b = −
2 2
describe a bijection between factorizations of N and representations of N as a dif-
ference of
√two squares.
√ This immediately suggests a crude factorization algorithm:
for t = ⌈ N⌉, ⌈ N⌉ + 1, . . . , check whether t 2 − N is a perfect square. If we find
such a square, then we can factor N. This algorithm will work well if N = ab with
|a − b| small, since then the running time is dependent
√ on |a − b|. This was already
clear to Fermat; he took N = 2 027 651 281, so that N ≈ 45 029, and found
E XAMPLE 19.11. Let N = 2183. Suppose that we have found the system of con-
gruences
Then we obtain (453 · 1 014 · 209)2 ≡ 212 mod N, or 6872 ≡ 212 mod N. This
yields the factors 37 = gcd(687 − 21, N) and 59 = gcd(687 + 21, N); in fact N =
37 · 59 is the prime factorization of N. ✸
2 1
prob{s ≡ ±t mod N} = ≤ .
2r 2
In Example 19.11, with B = {2, 3, 5, 7}, we have ε1 = (0, 0, 0, 1), ε2 = (0, 1, 0, 0),
ε3 = (0, 1, 0, 1) and ε1 + ε2 + ε3 = 0 in F24 . Furthermore γ1 = γ3 = 0, γ2 = γ4 = 1,
s = 453 · 1 014 · 209, and t = 20 · 31 · 50 · 71 .
Here is the resulting algorithm.
4. a ←− b2 rem N
{ factor a over {p1 , . . . , ph } }
for i = 1, . . . , h do
552 19. Factoring integers
5. { determine multiplicity of pi in a }
αi ←− 0
a
while pi divides a do a ←− , αi ←− αi + 1
pi
7. until #A = h + 1
8. find distinct pairs (b1 , α(1) ), . . . , (bl , α(l) ) ∈ A with α(1) +· · ·+ α(l) ≡ 0 mod 2
in F2h , for some l ≥ 1, by solving an (h + 1) × h system of linear equations
over F2
1
9. (γ1 , . . . , γh ) ←− (α(1) + · · · + α(l) )
2 γ
s ←− ∏ bi , t ←− ∏ p j j , g ←− gcd(s + t, N)
1≤i≤l 1≤ j≤h
if g < N then return g else return “failure”
We let n = log N. Using the sieve of Eratosthenes, the cost for setting up the
factor base in step 1 is O(h log2 h loglog h) word operations, by Theorem 18.10, and
the cost for checking divisibility is O(h · M(n)). The cost for one iteration of the
loop 2 is O(M(n) log n) word operations for the gcd, O(M(n)) word operations to
compute b2 rem N, and O((h + n)M(n)) operations for trial division by all primes
p1 , . . . , ph to check smoothness. (The check can actually be performed faster with
a modification of the Pollard and Strassen algorithm 19.2.) If k is the number of
iterations of the loop 2, then the total cost of the loop is O(k(h + n)M(n)) word
operations. The cost of solving the system of linear equations over F2 in step 8 is
O(h3 ) word operations. The cost of all other steps is dominated by these estimates,
and we obtain a total cost of
word operations.
In practice, √−1 is included in B and the numbers b are chosen randomly in
2
the vicinity
√ of N, because the least absolute residue of b modulo N is then only
about O( N) and more likely to have all prime factors less than B than an arbitrary
number up to N. For our arguments below, however, we need the assumption that
the b’s are uniform random numbers between 1 and N − 1.
Our goal now is to estimate the expected number k of iterations, and to determine
the right choice for B, given just N. For given x, y ∈ R>2 , we let
The numbers in Ψ (x, y), all of whose prime factors are not greater than y, are called
y -smooth. We have
b is a B-number ⇐⇒ b2 rem N ∈ Ψ (N, B).
Clearly the crux of the problem is to choose B wisely: if B is too small, then B-
numbers are rare and take a long time to find, and if B is too large, then it takes a
long time to test a prospective B-number, and the linear system is large.
As a warmup exercise, we estimate roughly the probability that a random integer
a ∈ {1, . . . , x} is y-smooth, with y = B. We put u = ln(x)/ln(y), so that y = x1/u ,
and v = ⌊u⌋, and let (a1 , a2 , . . . , av ) ∈ {p1 , . . . , ph }v and a = a1 a2 · · · av . (ln is the
natural logarithm.) Then a ≤ Bv ≤ yu = x, hence a ∈ Ψ (x, y). Each a comes from at
most v! vectors in {p1 , . . . , ph }v , and hence we have the approximate inequalities
v v u
hv h y −v y −u
ψ (x, y) ≥ ≥ & ·v ≈ · u−u = x(u ln y) ,
v! v ln y ln y
by the prime number theorem 18.7 which says that h ≈ y/ ln y. So for a random
positive integer a ≤ x, we have
ψ (x, y) −u
prob{a is y-smooth} = & (u ln y) .
x
We state without proof that for reasonably small u, the true order of this proba-
bility, called Dickman’s ρ-function, is u−u for large enough y. Although we will
not use this fact, it is comforting to know that our coarse estimate is not too far off.
T HEOREM 19.13.
Let u: N −→ R>1 be an increasing function with u(x) ∈ O(log x/ loglog x). Then
the probability that a random integer in {1, . . . , ⌊x⌋} is x1/u -smooth satisfies
ψ (x, x1/u )
= u−u(1+o(1)) .
x
Here, o(1) is shorthand for a function which tends to zero as u approaches in-
finity. The above estimates apply to random values a. We now prove a similar
result about b2 rem N for random values b. Then the expected number of trials
necessary to find a single B-number is at most (u ln y)u (or, in fact, at most uu ).
A different argument is in Exercise 19.10.
h2r
#{b ∈ N: 1 ≤ b < N and b2 rem N ∈ Ψ (N, ph )} ≥ . (5)
(2r)!
554 19. Factoring integers
P ROOF. The idea of the proof is to adapt our warmup strategy to this situation.
So we consider power products b of p1 , . . . , ph with exactly r factors. The square
of such a b is smooth, and therefore b is clearly in the set S on the left hand
side of (5). But there are not enough of these numbers. It would be sufficient
if the product of any two b’s, rather than just the squares, was actually a square
modulo N. This looks implausible at first. But consider a prime factor q of N.
Modulo q, half of the numbers are squares (Lemma 14.7), and we have not only
“square · square = square”, but also “nonsquare · nonsquare = square” (Exercise
14.8). The same actually holds modulo a power of q. The proof will produce
sufficiently many numbers in S by partitioning the set of all b’s as above according
to their square/nonsquare character modulo all the prime factors of N. Then when
we take two b’s that are distinct but have the same character, their product will
actually be a square modulo all q’s, and therefore modulo N. The following proof
makes this precise. For a first understanding, the reader may want to assume that
N = q1 q2 is the product of two distinct primes.
To begin the proof, we let N = ql11 · · · qtlt be the prime factorization of N. The
quadratic character χi = χqli on Z×li is defined as follows:
i qi
1 if ∃b ∈ N a ≡ b2 mod qlii ,
χi (a mod qlii ) =
−1 otherwise.
Relatives of this character have played a role (implicitly) in equal-degree factor-
ization (Section 14.3) and primality testing (Chapter 18), then called the Jacobi
symbol. The map χi is a group homomorphism. Putting all these characters to-
gether, we get
t
χ: Z×
N −→ {1, −1} = G,
a mod N 7−→ χ1 (a mod ql11 ), . . . , χt (a mod qtlt ) .
We let
be the set of ph -smooth integers below x with exactly s (not necessarily distinct)
prime factors.√ By assumption, we have a mod N ∈ Z× N for all a ∈ Ts (x). Now we
t
partition Tr ( N) into 2 sets Ug for g ∈ G:
√
Ug = {a ∈ Tr ( N): χ(a mod N) = g}.
We denote by V the image of the multiplication map
[
µ: (Ug ×Ug ) −→ N
g∈G
with µ(b, c) = bc rem N. Since χ(bc mod N) = (1, . . . , 1) for all b, c ∈ Ug and
g ∈ G, we have V ⊆ Q. Furthermore, V ⊆ T2r (N), so that V ⊆ T2r (N) ∩ Q.
Every element in T2r (N) ∩ Q has exactly 2t square roots, and these are all in S, so
S
that #S ≥ 2t · #(T2r (N)∩ Q). How many elements (b, c) ∈ g∈G Ug ×Ug are mapped
√
by µ to the same a ∈ V ? Since b, c ≤ N and bc ≡ a mod N, we then actually have
bc = a. Thus we have to split the2r prime factors of a into two halves to make up
b and c, and there are at most 2rr = (2r)!/(r!)2 ways of doing this. Thus
[
#V · (2r)!/(r!)2 ≥ #( Ug ×Ug ) = ∑ (#Ug )2 .
g∈G g∈G
The Cauchy-Schwarz inequality (Exercise 16.10) says that for any two vectors
x = (x1 , . . . , xn ), y = (y1 , . . . , yn ) ∈ R n we have
2
2 2 2 2 2
x
∑ i ∑ i · y = ||x||2 · ||y||2 ≥ x ⋆ y = ∑ xi yi .
1≤i≤n 1≤i≤n 1≤i≤n
Step 1 of Algorithm 19.12 guarantees that N is not divisible by any of the primes
p1 , . . . , ph . Then the expected number of trials to find a single B-number is at most
−1
#{B-numbers} N N(2r)!
= ≤
N #{B-numbers} h2r
N N(ln B)2r
(2r)! < (2r)2r = n2r .
h2r B2r
T HEOREM 19.15.
Dixon’s random
√ squares method factors an integer N with an expected number of
O∼ (L(N)2 2 ) word operations.
Variants of this algorithm are used for factoring large integers, and many practi-
cal improvements to it have been made. We only mention two. The first one notes
that, since a number below N has at most log2 N factors, each exponent vector (1)
has at most log2 N nonzero entries, the matrix of the linear system in step 8 is
sparse, and we can use a variant of Wiedemann’s algorithm (Section 12.4) to solve
it in O∼ (h2 ) steps. In fact, Wiedemann (1986) invented his algorithm specifically
for this approach. However, this does not decrease the cost estimate of Theo-
rem 19.15.
19.6. Pollard’s p − 1 method 557
2 2
1 1
–2 –1 0 1 2 –2 –1 0 1 2
–1 –1
–2 –2
F IGURE 19.5: The elliptic curve y2 = x3 − x over the real numbers (left diagram), and the
elliptic curves y2 = x3 − x + b for b = 0, 1/10, 2/10, 3/10, 4/10, 5/10.
random squares method, but instead of L(N) we have L(p), where p is the second
largest prime factor of N. Thus it is faster than Dixon’s method when N = pq is
the product of two primes of substantially different sizes, say 50 and 100 digits. In
Section 19.1, we have highlighted some of the successes of this method.
Elliptic Curves. The basic approach in the elliptic curve method to factor N is as
follows. One prescribes a certain sequence of computations modulo N. A division
by w ∈ Z in this sequence can only be executed if gcd(w, N) = 1. Thus at each
division step, we either continue the computation or we are lucky—gcd(w, N) is
not trivial and we have found a divisor of N. This is sometimes called the pretend
field technique. Calculating a multiple of a random point on a random elliptic
curve leads to such a sequence of computations. What makes this work is that we
will be lucky with reasonably large probability.
The elliptic curve factoring method corresponds to choosing randomly a group
G from a set of elliptic curve groups. Lenstra (1987) showed that with large enough
probability at least one curve will have smooth order.
We start by defining elliptic curves and stating some of their properties. They
inhabit the realm of algebraic geometry , one of the richest and deepest areas of
mathematics. In this text, we cannot but scratch the surface of this beautiful theory.
We have to rely on several results whose proof is beyond the scope of this text.
3
y
2 S
Q 1
P
–2 –1 1 2 x
–1
–2 R
–3
F IGURE 19.6: Adding two points P with x = −0.9 (red) and Q with x = −0.5 (green) on
the elliptic curve y2 = x3 − x. The point R = P + Q (blue) is the negative of the intersection
point S (black) of the two lines with the curve.
The reader may imagine that O lies beyond the horizon in the direction of the
y-axis (up and down), and that any two vertical lines “intersect” at O. Projective
geometry provides a rigorous framework for these notions.
An elliptic curve E is nonsingular (or smooth) in the geometric sense, as fol-
lows. Let f = y2 − (x3 + ax + b) ∈ F[x, y], so that E = { f = 0} ∪ {O}. For
(u, v) ∈ E \ {O}, we have
∂f ∂f
(u, v), (u, v) = (−3u2 − a, 2v),
∂x ∂y
Since a, b, r, s are all fixed, this is a cubic equation for u. In the case of a vertical
line L = {(u, v): v ∈ F}, where u ∈ F is fixed, one of the points is O.
The group structure. The fundamental property that makes elliptic curves in-
teresting for factorization is that they have a group structure in a natural way. We
define the group operation as follows. The negative of a point P = (u, v) ∈ E is its
mirror image −P = (u, −v) upon reflection at the x-axis, and −O = O. When we
intersect the line through P and Q with E, we get three points, say {P, Q, S}. Then
R = P + Q = −S
P + O = −(−P) = P
(iii) Q = −P. We take again the vertical line through P and Q and obtain
P + (−P) = −O = O.
It turns out that these definitions make E into a commutative group. The second
special case above shows that O is the neutral element of E, and the third case says
that the inverse of a point P is its negative −P. As usual, for k ∈ Z and P ∈ E we
will write kP for adding P (respectively −P if k < 0) k times (−k times if k < 0)
to itself, and 0P = O.
We now derive the rational expressions for addition on an elliptic curve E. Sup-
pose that P = (x1 , y1 ), Q = (x2 , y2 ), and x1 6= x2 . Then R = (x3 , y3 ) = P + Q ∈
E \ {O}. The line through P and Q has the equation y = αx + β , where α =
(y2 − y1 )/(x2 − x1 ) and β = y1 − αx1 . Let S = (x3 , −y3 ) be the third intersection
point of this line with the curve. Then (αx3 + β )2 = x3 3 + ax3 + b. Since x1 , x2 are
19.7. Lenstra’s elliptic curve method 561
the two other roots of the cubic equation (u3 + au + b) − (αu + β )2 = 0, we have
x1 + x2 + x3 = α2 . It follows that
y2 − y1 2 y2 − y1
x3 = − x1 − x2 , y3 = −y1 + · (x1 − x3 ). (9)
x2 − x1 x2 − x1
Thus, the coefficients of the sum of two distinct points are given by rational func-
tions of the input coefficients. We note that these formulas do not explicitly use the
Weierstraß coefficients of E, which are determined in fact by the two points on it.
A similar formula holds for doubling a point (where R = 2P, x1 = x2 , and y1 = y2 ;
see Exercise 19.15): we have
2 2
3x1 + a 3x2 + a
x3 = − 2x1 , y3 = −y1 + 1 · (x1 − x3 ), (10)
2y1 2y1
if y1 6= 0, and 2P = O if y1 = 0.
The curve E with this operation is a commutative group. We have already
checked all required properties, except associativity. The latter is not hard to check
on a computer algebra system (Exercise 19.17).
The size of an elliptic curve. Our intuition so far has been based on the real
numbers. But for the intended application we have to consider elliptic curves over
finite fields. Our first task is to determine the size of such an elliptic curve, that is,
to estimate the number of points on it. The following estimate is easy and crude.
T HEOREM 19.19.
Let E be an elliptic curve over the finite field Fq of characteristic greater than three.
Then #E ≤ 2q + 1.
P ROOF. For each of the q possible values for u, there are at most two possible
values for v such that v2 = u3 + au + b, corresponding to the two square roots of
u3 + au + b. Adding the point at infinity gives the required estimate. ✷
One reason to think that this is a crude estimate is that, pretending that the value
of u3 + au + b varies randomly as u ranges over Fq , we should expect that for about
half of the u’s there would be two solutions v for the equation, and no solution for
the other half. In other words, u3 + au + b should be a square about half of the
time. Random elements have this property by Lemma 14.7. More formally, we
consider the quadratic character χ : F× q −→ {1, 0, −1} defined by
1 if c is a square,
χ(c) = 0 if c = 0,
−1 otherwise.
562 19. Factoring integers
For q prime, χ(c) = ( qc ) is called the Legendre symbol (Section 18.5), and for all
c ∈ Fq ,
#{v ∈ Fq : v2 = c} = 1 + χ(c).
From this we conclude that
If χ(u3 + au + b) was a uniformly distributed random variable, then the sum would
behave like a random walk on the line. After q steps of such a random walk, we
√
expect to be about q steps away from the origin (Exercise 19.18). Of course this
is not at all a random process, but the analogy provides some intuitive motivation
for the following result.
E XAMPLE 19.21.√ Let q = 7. By the Hasse bound, each elliptic curve E over F7
has |#E − 8| ≤ 2 7, so that 3 ≤ #E ≤ 13. Table 19.7 gives the orders of all 42
elliptic curves over F7 .
n 3 4 5 6 7 8 9 10 11 12 13
#{E: #E = n} 1 4 3 6 4 6 4 6 3 4 1
(0, 0), (1, 0), (4, 2), (4, 5), (5, 1), (5, 6), (6, 0), O.
This group is generated by the two elements (4, 2) of order 4 and (0, 0) of order 2,
and hence is isomorphic to Z4 × Z2 .
Another example is the curve E ∗ with the equation y2 = x3 + x, comprising the
eight points
(0, 0), (1, 3), (1, 4), (3, 3), (3, 4), (5, 2), (5, 5), O.
E ∗ is cyclic and generated, for example, by (3, 3). Figure 19.8 illustrates the group
structures of E and E ∗ . ✸
(4, 2)
(1, 0)
O
(4, 5) (3, 3) (1, 4) (5, 5)
O (0, 0)
(0, 0) (6, 0)
(5, 6)
F IGURE 19.8: Structure of the elliptic curve groups E (left) and E ∗ (right) from Example
19.21. E is generated by (4, 2) (red) and (0, 0) (green), and E ∗ is generated by (3, 3) (red).
There is a colored arrow from a point P to a point Q if Q − P is the generator of that color.
The elliptic curve algorithm. We first state Lenstra’s algorithm to factor N, and
then prove some of its properties.
3. for i = 1, . . . , h do √
ei ←− ⌊log pi (C + 2 C + 1)⌋
for j = 0, . . . , ei − 1 do
{ Loop invariants: t = pij ∏ per r and Q = tP }
1≤r<i
The “elliptic curve” in step 2 is in quotes because the proper definition for a
composite N is more complicated. All we need here is that for each prime factor p
of N, E mod p is an elliptic curve in the proper sense. In particular, the equations
(9) and (10) do not make E into a group. This is plausible since some denominator
might be nonzero but not invertible, so that the expressions might not be well-
defined modulo N. The point is that, until a divisor is found, they give the group
structure on the reduction E p modulo any prime divisor p of N.
We are going to show that successful termination eventually occurs if N has a
prime factor below C. (The order of computation, from smaller to larger prime
factors, might not be essential for the validity of the algorithm, but is required in
the proof given below.)
Let p be a prime divisor of N. Then p does not divide 4a3 + 27b2 , since other-
wise the choice is (successfully or unsuccessfully) abandoned in step 1. We denote
by E p the reduction of E modulo p, that is, the elliptic curve over Z p with Weier-
straß coefficients a, b modulo p. To P ∈ E corresponds Pp ∈ E p , just by reducing
the coefficients modulo p. Moreover, we let O p , the point at infinity on E p , cor-
respond to the point at infinity O of E. Then Pp 6= O p for all P ∈ E \ {0}, and
hence
Pp = O p if and only if P = O. (11)
Then, until the divisor p is found (so that p | gcd(w, N) in step 4), the com-
putation in the algorithm can be considered as implementing arithmetic on E p in
the sense that each partial result Q = tP on E gives, modulo p, the partial result
Q p = tPp on E p ; in other words, tPp = (tP) p . The lucky event that provides a fac-
torization occurs when we reach a multiple of the order of Pp on E p but not of Pq
on Eq , for two prime divisors p, q of N. We had a similar situation in Pollard’s
p − 1 method, with the elliptic curve replaced by the group of units.
L EMMA 19.23. Suppose that (E, P) is chosen, p, q are distinct prime divisors
of N , l is the largest prime factor of the order of Pp in the group E p , p ≤ C, #E p is
B-smooth, and l ∤ #Eq . Then the algorithm factors N .
P ROOF. We let k = ∏1≤r≤h per r , with er as in step 3 for 1 ≤ r ≤ h. The loop in-
variants are easily checked by induction on i and j. Since #E p is B-smooth and
p ≤ C, the Hasse bound implies that #E p | k. Let d be the order of Pp in E p . Then
d | #E p , and hence l ≤ B and d | k. Let pi = l and e be the exponent of l in d, so
that 1 ≤ e ≤ ei . When j = e − 1, then
the result could only be O. We show that in fact it terminates by finding a divisor
before reaching this situation.
Assume to the contrary that lQ = O is computed in step 4 by the algorithm.
Since this computation also implements arithmetic on Eq , we have computed lQq =
(l tP)q = Oq . But then, since l does not divide #Eq or the order of Pq , the point
Qq = tPq is already Oq . It then follows that Q = O by (11) and hence Q p = O p ,
a contradiction. ✷
We now turn to the analysis of the probability that the assumptions in this lemma
are satisfied. We note that prob(l ∤ #Eq ) is almost 1 (see Notes 19.7), so we only
consider the probability of the randomly chosen parameters to produce an elliptic
curve E p with #E p being B-smooth. This is basically settled by the following result
of Lenstra’s, whose proof is outside the scope of this text.
T HEOREM 19.24.
There exists a c ∈ R>0 with the following property. Let p be prime, S ⊆ N with
√ √
S ⊆ (p + 1 − p, p + 1 + p) and #S ≥ 3, and a, b ∈ F p chosen at random. Let
E p = {(u, v) : v2 = u3 + au + b} ∪ {O}
be an elliptic curve over F p . Then
c · #S
prob{#E p ∈ S} ≥ √ .
p log p
We note that S is taken from the middle half of the range given by the Hasse
bound; we have S ⊆ {6, 7, 8, 9, 10} for p = 7. Thus the sizes of elliptic curves
are roughly equally distributed in this middle half. Taking the set of B-smooth
numbers for S and using Lemma 19.23, we have the following consequence.
C OROLLARY 19.25.
There exists a c ∈ R>0 with the following property. Let p ≤ C be a prime divisor
of N , and
√ √
σ = #{B-smooth numbers in (p + 1 − p, p + 1 + p)}
√ √
= ψ (p + 1 + p, B) − ψ (p + 1 − p, B),
where ψ is the “number of smooth numbers” function defined in (4). If σ ≥ 3, then
the number M of triples (a, u, v) ∈ {0, . . . , N − 1}3 for which the algorithm factors
N satisfies
M cσ
3
≥√ .
N p log p
566 19. Factoring integers
How many trials of the algorithm are necessary for successful factoring with
√
high probability? We let s = σ /(2 p) denote the probability for a random number
√ √
in the range (p + 1 − p, p + 1 + p) to be B-smooth. If we run the algorithm
repeatedly, say m times, then the failure probability is at most
m m m
M sc sc
1− 3 ≤ 1− ≤ 1− ≤ e−msc/ lnC ≤ ε,
N ln p lnC
C ONJECTURE 19.26. For positive real numbers x, u, and an integer d chosen uni-
√ √
formly at random from the interval (x − x, x + x), we have
ln p ln p
ln(uu ) + ln B = · ln + ln B. (13)
ln B ln B
Setting √ √
B = e (ln p·lnln p)/2 = L(p)1/ 2 , (14)
with the function L defined in (8), we have
√ 2 ln p 1/2
ln p 2 ln p
= = .
ln B (ln p · lnln p)1/2 lnln p
Notes 567
An important variant of the quadratic sieve, the multiple polynomial quadratic sieve,
is practically useful for distributed computation on a network of workstations (Caron &
Silverman 1988). See Silverman (1987) and Pomerance (1990) for an overview.
19.6. The p − 1 method is from Pollard (1974).
19.7. Elliptic curves and the role of the “point at infinity” are best understood in the
framework of projective geometry. The projective plane P 2 over F consists of all triples
(u : v : w) with u, v, w ∈ F 3 , not all zero, where we identify two such triples if they are
multiples of each other. We may also regard (u : v : w) as the line in F 3 through (u, v, w)
and the origin. The projective curve in P 2 corresponding to an elliptic curve E given by
y2 = x3 + ax + b is
Ẽ = {(U : V : W ) ∈ P 2 : V 2W = U 3 + aUW 2 + bW 3 },
568 19. Factoring integers
modulo 2 to find squares.) Already Lehmer & Powers (1931) had used this expansion to
√ squares that are congruent modulo N. Pomerance (1982) exhibits variants that use
find two
L(N) 3/2+o(1) word operations, under some unproven hypotheses. Further discussions are
in Pomerance & Wagstaff (1983) and Williams & Wunderlich (1987). The origins of this
method can already be found in Legendre (1785), § XV. (In the Berkeley library copy that
we consulted, D. H. Lehmer has corrected a calculation error of Legendre’s.)
number field sieve by Lenstra, Lenstra, Manasse & Pollard (1990) runs in time
The q
exp(O( 3 log N(loglog N)2 )). It was the first general asymptotic progress (in terms of the
order of the exponent) since Dixon’s (1981) random squares method. Lenstra & Lenstra
(1993) give a status report. The original approach was designed for numbers of a spe-
cial form (as they occur in the Cunningham project), but newer versions apply to arbi-
trary numbers; see Dodson & Lenstra (1995) and Cowie, Dodson, Elkenbracht-Huizing,
Lenstra, Montgomery & Zayer (1996) about their efficiency. In 1999, it was used to break
the 211-digit repunit (10211 − 1)/9 into its two prime factors, with 93 and 118 digits.
As we have seen, the analyses of several factoring algorithms rely on unproven conjec-
tures. The current world records on rigorously proven upper bounds on integer factoring al-
gorithms are Pollard’s and Strassen’s O∼ (N 1/4 ) for deterministic methods and L(N)1+o(1),
due to Lenstra & Pomerance (1992), for probabilistic algorithms.
Exercises.
19.1−→ Prove that the quotient N of 2599 − 1 divided by its 23-digit prime factor
16 659 379 034 607 403 556 537 (15)
is composite. N has 159 decimal digits.
19.2∗ (Lenstra 1990) Consider the following special polynomial factorization task: input is a prime
p and f ∈ F p [x] of degree n and dividing x p − x, so that all monic irreducible factors of f in F p [x]
are linear and distinct. Adapt the Pollard and Strassen method to find a deterministic algorithm for
√
factoring f with O∼ (n p) operations in F p if p2 > n.
19.3 Factor the integer N = 23 802 996 783 967 using Pollard’s ρ method, and also with the Pollard
and Strassen method.
19.4 Let p be a prime. For a sequence u = (ui )i∈N ∈ Z pN let S(u) = min{i ∈ N: ∃ j < i u j = ui } be
the least index with a collision.
(i) For any u0 ∈ Z p , we define a sequence u = (ui )i∈N ∈ Z pN by ui = u2i−1 +1 if i ≥ 1, as in Pollard’s
algorithm 19.8. Determine the mean value (over the choices of u0 ) of S(u) for p = 167 and p = 179
by trying all possible initial values of u0 . Compare your result with the estimated expected value of
S(u) for random sequences from the proof of Theorem 19.5.
(ii) Determine the mean value of T (u) = min{i ∈ N>0 : ui = u2i }, with u and p as in (i), for all
possible values of u0 . Compare to your results of (i).
19.5 (Guy 1975) Let x0 = 2 and xi = x2i−1 + 1 for i ≥ 1. For p ∈ N, we let e(p) = min{i ∈ N≥1 :
xi ≡ x2i mod p}.
(i) Calculate e(p) for the primes p ≤ 11.
(ii) Calculate e(p) for the primes p ≤ 106 . You should find e(p) ≤ 3680 for all these p. (Guy
(1975) notes that e(p) seems to grow like (p ln p)1/2 .)
(iii) Let N be a number to be factored, run Pollard’s ρ method on it with initial value x0 = 2, and
assume that gcd(xi − x2i , N) = 1 for 1 ≤ i ≤ k. Show that e(p) > k for all prime divisors p of N.
(iv) Conclude that if the gcd in (iii) is trivial for 3680 steps, then N has no factor up to 106 .
570 19. Factoring integers
of Z× t
N into 2 subsets Tε of equal size.
If y ∈ Tε , then also all a computed in step 4 are in Tε . If Tε has its fair share of B-smooth numbers,
namely about σ · #Tε many, then the algorithm will work well with that choice of y. However, we do
not know that the smooth numbers are equally distributed over the 2t sets Tε . So the first question is
to show that a reasonable fraction of all y’s is sufficiently good.
S
(i) Let A = i∈I Bi be a partition of a finite set A into disjoint subsets of equal size k = #A/#I,
C ⊆ A, and s = #C/#A. Then for at least s · #I/2 indices i ∈ I we have #(Bi ∩C) ≥ sk/2.
(ii) Show that for a fraction at least σ/2 of the ε ∈ ±t , Tε contains a fraction at least σ/2 of B-
smooth numbers. Hint: Apply (i) to A = Z× N , C the B-smooth numbers, so that s = σ, and the partition
into the subsets Tε .
(iii) Analyze the success probability and the running time of the algorithm described above.
Exercises 571
19.11 Check that the curve E = {(x, y) ∈ F27 : y2 = x3 + x + 3} over F7 is nonsingular. Compute all
points on it, and verify that it is cyclic and generated by (4, 1).
19.13 Let E be an elliptic curve and P, Q ∈ E. Explain why P + Q = S, where S is the third inter-
section point of E with the line through P and Q (see Figure 19.6), is not a group operation.
19.14 Let F be a field and f = x3 + ax + b ∈ F[x].
(i) Check that r = res( f , f ′ ) = 4a3 + 27b2 .
(ii) Conclude that f is squarefree if and only if r 6= 0.
(iii) For which values of b does y2 = x3 − x + b not define an elliptic curve over F = R? Plot the
curves for all these values.
19.15 Let E = {(x, y) ∈ F 2 : y2 = x3 +ax+b} be an elliptic curve over a field F and P = (x1 , y1 ) ∈ E.
Determine the equation of the tangent to E through P (distinguish the two cases y1 = 0 and y1 6= 0),
and prove that the doubling formula (10) realizes the geometric description using the tangent line.
19.16 Show that an elliptic curve E has at most three points P of order 2, for which P 6= O and
2P = O.
19.17−→ You are to check associativity of the addition we defined on an elliptic curve E.
(i) Write a procedure add to calculate the sum of two distinct points, using (9).
(ii) Check that for three points P, Q, R,
is not zero.
(iii) What has gone wrong in (ii)? We have not used that the three points lie on the same curve. Cal-
culate the Weierstraß coefficients a, b from P and Q, set f = y23 − (x33 + ax3 + b), where R = (x3 , y3 ),
and check that ass ≡ 0 mod f . (You may have to simplify and take numerators at the appropriate
place.)
(iv) We now have associativity at three “generic” points P, Q, R. Check associativity when one of
them is O.
(v) It remains to check the cases where two points coincide, say P = Q or P + Q = R, so that (9) is
not applicable. You have two ways of doing this: writing a little program for these cases, or arguing
by continuity. The latter requires some algebraic geometry.
19.18∗∗ (i) Prove that ∑0≤k<n 2n k = (4n − 2n
n )/2 and ∑0≤k<n
2n−1
k = 4n−1 , for all posi-
tive integers n.
(ii) Let n ∈ N>0 , Xi for 1 ≤ i ≤ 2n be a collection of independent random variables which take
on each of the two values 1 and −1 with probability 1/2, and X = ∑1≤i≤2n Xi be a random walk of
length 2n. Prove that prob(X = 2(n − k)) = prob(X = −2(n − k)) = 2n k 4
−n for 0 ≤ k ≤ n.
(iii) Show that E(X) = 0 and E(|X|) = 2n 2n n 4 .
−n
√
(iv) Use Stirling’s formula n! ∈ 2πn(n/e)n (1 + O(n−1 )) (see Graham, Knuth & Patashnik 1994)
to show that E(|X|) ∈ 2π −1/2 n1/2 + O(n−1/2 ).
(v) Prove the same formulas as in (iii) when there are 2n − 1 instead of 2n random variables.
19.19−→ Program Lenstra’s algorithm 19.22, and use it to factor the number N from Exercise 19.3
with B = 40 and C = 12 000.
Real mathematics has no effects on war. No one has yet discovered any
warlike purpose to be served by the theory of numbers or relativity;
and it seems very unlikely that anyone will do so for many years.
Godfrey Harold Hardy (1940)
“Right. So I have a translation key and you have a signature key and all
the communication from you to me needs both
those keys to encode and decode it properly. But if I want
to send a message back, I can’t use those same keys—
I need my signature key and your translation key.”
“And Joe has a different translation key and when I send
him a message I have to use his key. And that’s how
everybody is approaching this, and doing it that way has
the kinds of problems we’re sitting here to solve.”
Philip Friedman (1996)
1 Pure number theory is that part of mathematics for which up to now no application has ever been found.
20
Application: Public key cryptography
This chapter presents one of the most interesting applications of the ideas from
complexity theory and the algorithms from computer algebra: modern cryptog-
raphy. After an introduction to the problem, we present six cryptographic algo-
rithms: the famous RSA scheme, the Diffie-Hellman key exchange, two crypto-
systems by ElGamal and by Rabin, and systems based on elliptic curves and short
vectors in lattices.
It is satisfying to see how many of the computer algebra methods discussed in
this text, certainly designed without this application in mind, have been useful for
cryptography.
20.1. Cryptosystems
The scenario in this chapter is as follows. Bob wants to send a message to Alice in
such a way that an eavesdropper Eve1 listening to the transmission channel cannot
understand the message. This is done by enciphering the message so that only
Alice, possessing the right key, can decipher it, but Eve, having no access to the
key, has no chance to recover the message.
Bob Alice
• ✲•
✻
•
Eve
The following are some of the ciphers that have been used in history.
◦ The Caesar cipher, which simply permutes the alphabet. The classical Caesar
cipher used the cyclic shift by three letters A 7−→ D, B 7−→ E, C 7−→ F, . . .,
Y 7−→ B, Z 7−→ C. For example, the word “CAESAR” is then enciphered as
“FDHVDU”. This cryptosystem is trivial to break: there are only 26 possibili-
ties to try. More generally, one can use any of the 26! ≈ 4 · 1026 permutations
1 Alice, Bob, and Eve are the leading characters of modern cryptography.
573
574 20. Application: Public key cryptography
❄ transmitted ❄
plaintext ✲ ciphertext ✲ decrypted text
x y = ε(x) δ(y)
encryption ε decryption δ
Diffie & Hellman (1976) made a revolutionary proposal which has since then
been known as public key cryptography. The idea is to have two different keys
K and S for encryption and decryption, respectively, such that both encryption and
decryption are “easy”, but decryption without knowledge of S is “hard”. Here
“easy” means polynomial time, preferably almost linear or quadratic time in the
message length. Figure 20.1 illustrates the situation. The name “public key cryp-
tography” comes from the fact that the encryption key K may be publicly available.
Since we want x = δ (y) = δ (ε(x)), δ is an inverse of ε. A function that is “easy” but
its inverse is “hard” to compute without additional knowledge, like the encryption
function in a public key cryptosystem, is called a trapdoor function. The keys
K and S are called public key and private key, respectively. With such an asym-
metric cryptosystem, n public-private key pairs are sufficient to permit secure
communication among any two of n parties.
576 20. Application: Public key cryptography
A cryptosystem is certainly broken when the private key is easy to find, but
an appropriate notion of breaking a code is much more generous: a system is
considered broken if there exists a Boolean predicate B(x)—say, the parity of x
if x is an integer—and a polynomial-time probabilistic algorithm which takes y =
ε(x) as input and has a slightly better capability of predicting B(x) than a random
guess. Otherwise, the system is semantically secure; this is only possible for
probabilistic encryption schemes, and the precise definition is a bit tricky.
There are several possibilities to make precise what “hard” means. Here is a list
of some, ordered in increasing desirability.
◦ The inventor of the cryptosystem does not know of any polynomial time algo-
rithm.
◦ Nobody knows of a polynomial time algorithm.
◦ Whoever breaks the system will probably in turn have solved a well-studied
“hard” problem.
◦ Whoever breaks the system has in turn solved a well-studied “hard” problem.
◦ Whoever breaks the system has in turn solved an NP –complete problem (Sec-
tion 25.8).
◦ There is provably no (probabilistic) polynomial-time algorithm, as we have
stipulated above.
At present, nobody knows of a cryptosystem fulfilling any of the last three require-
ments. However, it was a major conceptual breakthrough of the Diffie & Hellman
proposal that the hitherto elusive notion of a “hard-to-break cipher” should be
studied within the well-established framework of computational complexity.
Some of the modern proposals for cryptosystems have already been broken.
Merkle & Hellman (1978) suggested a cryptosystem based on the subset sum
problem. This system and several variants were broken using a basis reduction al-
gorithm (Section 17.1). Another cipher proposed by Cade in 1985 (see Cade 1987)
was based on the assumed hardness of the functional decomposition problem for
polynomials: Given a polynomial f over a field F of degree n, decide if there exist
polynomials g, h ∈ F[x] of degree at least 2 such that f = g ◦ h = g(h), and if so,
compute such g and h. The system was broken by Kozen & Landau (1989), who
gave an algorithm for the problem with running time O(n3 ). Beyond our fairly sim-
ple scenario, modern cryptography studies many other tasks: electronic signatures
and message authentication, multi-party communication, electronic cash, etc.
We now present some modern public key cryptosystems.
hardness of factoring integers. The idea is that Alice randomly chooses two large
(say 150-digit) primes p 6= q, and sets N = pq. Anybody who can factor N can
break the system; ideally, we would also like the converse to be true, since numbers
N with more than about 160 decimal digits seem out of the range of current integer
factorization software (see the Notes and Chapter 19). Messages are encoded as
sequences of elements of ZN = {0, . . . , N −1}. If, for example, we use the standard
alphabet Σ = {A, . . . , Z} of cardinality #Σ = 26, then messages of up to 212 =
⌊log26 10300 ⌋ letters can be uniquely represented by a single element of ZN , using
the 26-adic representation. For example, the message “CAESAR” is encoded as
If Alice wants to receive messages from Bob, she chooses e ∈ {2, . . . , ϕ(N) − 2}
with gcd(e, ϕ(N)) = 1 at random, where ϕ is Euler’s totient function (Section 4.2)
and ϕ(N) = #Z× N = (p − 1)(q − 1). (She can also fix e, say e = 3.) Then she
computes d ∈ {2, . . . , ϕ(N) − 2} with de ≡ 1 mod ϕ(N), using the Extended Eu-
clidean Algorithm (Theorem 4.1), publishes the pair K = (N, e) as her public key,
and keeps her private key S = (N, d) as well as p, q secret (the latter may even be
discarded). The encryption and decryption functions ε, δ : Z× ×
N −→ ZN are defined
e d ×
by ε(x) = x and δ (y) = y . To send a message x ∈ ZN to Alice, Bob looks up her
public key, computes y = ε(x), and sends this to Alice, who computes δ (y), using
her private key. Then, with u ∈ Z such that de − 1 = u · ϕ(N), we have
since xϕ(N) = 1 by Euler’s theorem (Section 18.1). Although the latter is only valid
if gcd(x, N) = 1, actually (δ ◦ ε)(x) = x is true for all x (Exercise 20.5). However,
values of x that are not coprime to N lead to the factorization of N and thus to a
break of the cryptosystem. Fortunately, if p and q are large and we assume that
many or all messages x are likely to occur, then this will practically never happen.
We recall that a polynomial-time reduction from one problem X to another
one Y is a polynomial-time algorithm for X making calls to a subroutine for Y . If
polynomial-time reductions exist in both directions, then X and Y are polynomial-
time equivalent (see Section 25.8). The following theorem is proven in Exercise
20.6.
T HEOREM 20.1.
The following three problems are polynomial-time equivalent:
(i) factoring N ,
(ii) computing ϕ(N),
(iii) computing d ∈ N with de ≡ 1 mod ϕ(N) from K = (N, e).
578 20. Application: Public key cryptography
Unfortunately, the theorem does not say that breaking the system means that
one can factor integers efficiently, since there might be a successful attack that
does not compute the private key at all.
The RSA scheme can also be used for authentication, where the sender of a
message has to prove that he actually is the originator. This is also called a digital
signature. If Bob wants to send a signed message x to Alice, he computes y = δ (x)
using his own private key, and sends this to Alice, who looks up Bob’s public key
and recovers x = ε(y). Since only Bob is assumed to know his private key, no
forger would have been able to produce y, and Alice is convinced that the message
originated from Bob. Instead of the whole message x, Bob might just sign a short
digest of x obtained with a cryptographic hash function.
The authentication scheme may even be used in conjunction with the encryption
scheme to ensure privacy. If εA , δA and εB , δB are Alice’s and Bob’s encryption and
decryption functions, respectively, and Bob wants to send a signed message x to
Alice that no one else can decipher, he computes y = εA (δB (x)), and sends this to
Alice, who first decrypts δA (y) = δB (x) and then x = εB (δA (y)), at the same time
assuring herself that the message originates from Bob.
Both parties may use gab as a common key for further communication with a sym-
metric cryptosystem. In this context, the following problems play a central role.
20.4. The ElGamal cryptosystem 579
receive messages from Bob, Alice randomly chooses S = b ∈ Zq−1 as her private
key and publishes K = (q, g, gb ). If Bob wants to send a message x to Alice,
he looks up her public key, randomly chooses k ∈ Zq−1 , computes gk and xgkb ,
and sends y = (u, v) = (gk , xgkb ) to Alice, who computes the original message as
x = v/ub . Computing x from y without knowing S is polynomial-time equivalent
to the Diffie-Hellman Problem.
A practical problem in implementing the Diffie-Hellman scheme or the ElGamal
3
system is that exponentiation in F× q is theoretically easy (O(n ) word operations for
n
q = 2 using classical arithmetic), but not fast enough to achieve high throughput.
One can, however, achieve time O∼ (n2 ).
Remainder Algorithm. There are various tricks to deal with the choice among the
four different answers computed by Alice.
However, the system’s use as a signature scheme is vulnerable to an active at-
tack: if Eve chooses a random x and gets Alice to sign a message y ≡ x2 mod N,
by returning a square root z of y modulo N, then with probability 1/2, gcd(x −z, N)
will be a proper factor of N. The system is not considered secure for this reason.
Notes. 20.1. The one-time pad is in Vernam (1926). Cryptographically strong pseudo-
random number generators, whose prediction is thought to be computationally hard, are
discussed in Lagarias (1990). An algorithm with time O∼ (n) for functional decomposition
is in von zur Gathen (1990a, 1990b); see Exercise 20.3.
20.2. The security of individual bits in the RSA scheme has been discussed by several
researchers; see Näslund (1998) and Håstad & Näslund (1998) for references. It is gener-
ally hard to predict, and even harder to predict the future. Nevertheless, Odlyzko (1995b)
extrapolates past progress and concludes that 1500 to 10 000 bits are needed for a number
(used in a cryptosystem) to be safe against factoring attempts. Attacks via basis reduction
on small RSA exponents and other cryptographic applications are discussed in Nguyen &
Stern (2001).
20.3. McCurley (1990) gives an overview on discrete logarithm algorithms. Maurer &
Wolf (1999) reduce DL to DH in some special cases.
20.4. ElGamal (1985) gives his cryptosystem. Fast exponentiation in finite fields F2n
can be achieved using Gauß periods, normal bases, and fast arithmetic (von zur Gathen
& Nöcker 1997, Gao, von zur Gathen & Panario 1998, Gao, von zur Gathen, Panario &
Shoup 2000).
20.6. Public key cryptosystems based on elliptic curves were invented by Miller (1986)
and Koblitz (1987b). Menezes (1993) and Blake, Seroussi & Smart (1999) present com-
prehensive treatments.
Exercises.
20.1 As in Section 20.1, we identify the letters A, B, C, . . ., Z with the elements 0, 1, 2, . . ., 25 of Z26 .
(i) The word “OAYBGFQD” is the result of an encryption with a Caesar cipher, which maps each
letter x ∈ Z26 to x + k, where k ∈ Z26 is the key. What are the cleartext and the key?
Exercises 581
(ii) The word “MLSELVY” is the ciphertext after encryption with the one-time pad using the key
“IAMAKEY”. Find the cleartext.
20.2−→ This exercise is about a variant of the following password encryption scheme suggested
by Purdy (1974), before the advent of public-key cryptography (Diffie & Hellman 1976). Let p =
264 − 59, which is the largest prime below our processor’s assumed word length 264 , encode a 13-
letter password w∗ over the 26-letter alphabet {A, B, . . ., Z} as a number w using 26-adic notation,
and consider w ∈ F p . This makes sense, since 2613 < p. Then w is encrypted as f (w) ∈ F p , where
24 24
f = x2 +17
+ a1 x2 +3
+ a2 x3 + a3 x2 + a4 x + a5 ∈ F p [x],
for some specific values a1 , . . ., a5 ∈ F p . The pairs (login-name, f (password)) are stored in a public
file. When a user logs on and types in her password w∗ , f (w) is calculated and checked against the
entry in the file.
(i) Let a1 = 2, a2 = 37, a3 = −42, a4 = 15, a5 = 7, and w∗ = RUMPELSTILTZK. Calculate w
and f (w).
(ii) How many arithmetic operations in F p are used to calculate f (w) from w?
(iii) Let v ∈ F p . The core of the algorithm in Exercise 14.20, which calculates {w ∈ F p : f (w) = v},
is the computation of x p rem f . Extrapolating the timings from Figure 9.10, you may assume that
one multiplication modulo f can be done in about one hour. Since f is sparse, the reduction modulo
f is inexpensive. How long does the computation of x p rem f take approximately? What do you
conclude about the security of this system (on today’s computers)?
20.3∗ (Kozen & Landau 1989, von zur Gathen 1990a) Let F be a field and f ∈ F[x] of degree n.
A functional decomposition of f is given by two polynomials g, h ∈ F[x] of degrees at least two
such that f = g ◦ h = g(h). If no such decomposition exists, then f is indecomposable. Obviously a
necessary condition for the existence of a decomposition is that n be composite.
(i) Let f = g ◦ h be a functional decomposition and c, d ∈ F with c 6= 0. Show that f = g(cx + d) ◦
(h − d)/c is also a functional decomposition. Find a functional decomposition f / lc( f ) = g∗ ◦ h∗ into
monic polynomials g∗ , h∗ ∈ F[x], with the same degrees as g, h, and such that h(0) = 0. We call such
a decomposition normal.
(ii) Let f = g ◦ h be a normal decomposition, r = deg g, s = deg h, and f ∗ = rev( f ) = xn f (x−1 )
and h∗ = rev(h) = xs h(x−1 ) the reversals of f and h, respectively. Prove that f ∗ ≡ (h∗ )r mod xs .
(iii) Let f = g1 ◦ h1 be another normal decomposition with r = deg g1 and s = deg h1 and assume
that r is coprime to char F. Prove that h = h1 and g = g1 . Hint: Uniqueness of Newton iteration
(Theorem 9.27).
(iv) Consider the following algorithm, which works even over rings.
A LGORITHM 20.4 Functional decomposition of polynomials.
Input: A monic polynomial f ∈ R[x] of degree n > 3 and a nontrivial divisor r of n, where R is a ring
(commutative, with 1) of characteristic coprime to r.
Output: Either a normal decomposition f = g ◦ h with g, h ∈ R[x] and deg g = r, or “no such decom-
position”.
1. f ∗ ←− rev( f ), s ←− n/r
{ compute rth root of f ∗ via Newton iteration }
call the Newton iteration algorithm 9.22 to compute h∗ ∈ R[x] of degree less than s with
h∗ (0) = 1 and (h∗ )r ≡ f ∗ mod xs
h ←− xs h∗ (x−1 )
2. call Algorithm 9.14 to compute the h-adic expansion f = hr + gr−1 hr−1 + · · · + g1 h + g0 of f ,
with gr−1 , . . ., g0 ∈ R[x] of degrees less than s
3. if gi ∈ R for all i then return g = xr + ∑0≤i<r gi xi and h
else return “no such decomposition”
582 20. Application: Public key cryptography
Prove that the algorithm works correctly, and show that it takes O(M(n) log r) additions and mul-
tiplications in R. What goes wrong if gcd(r, char R) > 1?
(v) Apply the algorithm to find a decomposition of f = x6 + x5 + 2x4 + 3x3 + 3x2 + x + 1 ∈ F5 [x].
20.4 Let N = 8051 = 97 · 83.
(i) The public key in a RSA cryptosystem is K = (N, e) = (8051, 3149). Find the corresponding
private key S = (N, d).
(ii) A message x has been encrypted using K, and the resulting ciphertext is 694. What is x?
20.5 Let p, q ∈ N be distinct primes, N = pq, K = (N, e) the public key, and S = (N, d) the private
key in a RSA cryptosystem, such that d, e ∈ N satisfy de ≡ 1 mod ϕ(N).
(i) In Section 20.2, we have assumed that messages x to be encrypted are coprime to N. Prove that
the RSA scheme also works if this condition is violated. Hint: Chinese Remainder Theorem.
(ii) Show that the intruder Eve, who has intercepted the ciphertext ε(x) but does not know the
private key S, can easily break the system if x is not coprime to N.
20.6∗ In this exercise, you are to prove Theorem 20.1. So let N = pq for two distinct primes p, q ∈ N.
(i) Show how to compute p, q from the knowledge of N and ϕ(N). Hint: Consider the quadratic
polynomial (x − p)(x − q) ∈ Z[x].
(ii) Suppose that you are given a black box which on input e ∈ N decides whether it is coprime
to ϕ(N), and if so, returns d ∈ {1, . . ., ϕ(N) − 1} such that de ≡ 1 mod ϕ(N). Give an algorithm
using this black box which computes ϕ(N) in time (log N)O(1) . Hint: Find a “small” e coprime to
ϕ(N).
20.7−→ (i) Program a procedure key generate that generates a pair (K, S) of keys for the RSA
cryptosystem, such that K = (N, e) is the public key, S = (N, d) is the private key, N is the product
of two random 100 bit prime numbers, e ∈ {2, . . .ϕ(N) − 2} is chosen uniformly at random, and d ∈
{2, . . ., ϕ(N) − 2} satisfies de ≡ 1 mod ϕ(N).
(ii) Design a coding for short strings of English words with at most 30 letters, including punc-
tuation marks, parentheses, and blanks, as integers between 0 and N − 1, and write corresponding
procedures encode and decode.
(iii) Write a procedure crypt for encrypting and decrypting with the RSA cryptosystem. Its argu-
ments should be a number in ZN and a key.
key generate
K S
☛ ❯
text x y = ε(x) x = δ(y) text
✲ encode ✲ crypt ✲ crypt ✲ decode ✲
(iv) Check your programs with sample messages of your choice, and produce some timings.
Research problems.
20.8 Reduce (in probabilistic polynomial time) factoring integers to breaking RSA (or some other
cryptosystem).
20.9 Reduce DL to DH in polynomial time.
Part V
Hilbert
David Hilbert (1862–1943) grew up in Königsberg, then capital of East Prussia
and now Kaliningrad in Russia, in an upper middle-class family; his father was a
judge. The town had been home to the philosopher Immanuel Kant, to Leonard
Euler, whose solution to the riddle of how to cross its seven bridges across the
river Pregel without re-using one became a starting point for graph theory and
topology, and to C. G. J. Jacobi.
After an unimpressive school career, he studied at the university to graduate
with his doctoral thesis on invariant theory in 1885. He worked in this area until
1893, proving among other things the Hilbert basis theorem saying that any ideal
in a polynomial ring (in finitely many variables over a field) is finitely generated
(Theorem 21.23), and introducing the Hilbert function of algebraic varieties.
Two further results from his “multivariate polynomial phase” are relevant to the
subject matter of this text: firstly Hilbert’s Nullstellensatz 1 (1890), which says
that if a polynomial g vanishes on the set of common roots of some multivariate
polynomials f1 , . . . , fs over C, then some power ge is in the ideal h f1 , . . . , fs i (see
Section 21.7). Secondly, Hilbert’s irreducibility theorem (1892), stating that for
an irreducible polynomial f ∈ Q[x, y], the univariate polynomial f (x, a) ∈ Q[x] is
irreducible for “most” a ∈ Z. This sounds useful for reducing bivariate to
univariate factorization. Unfortunately, no efficient versions of “most” are known,
but, fortunately, such versions are known for reducing from many to two variables
(Section 16.6).
Hilbert became a professor at the university of Göttingen in 1895. Under his
leadership and that of Felix Klein, its fame, established by Gauß, as a center for
mathematics kept growing. Among their famous colleagues were Hermann
Minkowski, Ernst Zermelo, Constantin Carathéodory, Emmy Noether, Hermann
Weyl, Carl Runge, Richard Courant, Edmund Landau, Alexander Ostrowski, Carl
Ludwig Siegel, and Bartel van der Waerden, who based his Modern Algebra
(1930b, 1931) on Emmy Noether’s Göttingen lectures.
Hilbert’s Zahlbericht 2, commissioned by the Deutsche Mathematiker -
Vereinigung 3, gave a rich overview of the state of algebraic number theory and led
him to a vast and elegant generalization of Gauß’ quadratic reciprocity law and to
the Hilbert class field theory .
His next area of work culminated in the booklet Grundlagen der Geometrie 4,
where he laid down the basic properties that a “nice” system of axioms should
have: soundness, completeness, and independence.
1 Nullstelle = root
2 Report on [the theory of] numbers
3 German Mathematical Society
4 Foundations of Geometry
586
Then came what turned out to be his most influential “work”: his talk on
August 8, 1900, at the International Congress of Mathematicians in Paris (Hilbert
1900). He began with: Wer von uns würde nicht gern den Schleier lüften, unter
dem die Zukunft verborgen liegt, um einen Blick zu werfen auf die bevor-
stehenden Fortschritte unserer Wissenschaft und in die Geheimnisse ihrer
Entwicklung während der künftigen Jahrhunderte!5, and ended with the list of the
23 Hilbert problems . As intended, this set of problems shaped the mathematics of
the next century, and those who contributed to a solution would be said to belong
to the “honors class” of mathematicians.
Hilbert liked lecturing,
and excelled at it. He usually
prepared only an outline of his
lecture and filled in the details in
front of the students—so he got
stuck and confused everybody
at times, but “a third of his
lectures were superb”. He was
Doktorvater to the impressive
number of 69 doctoral
students, and this Hilbert
school spread his approach to
mathematics around the world.
Hilbert could be funny
and entertaining at social events,
loved dancing, and was a
successful charmer of the ladies.
His unprejudiced and liberal
thinking led to a clash with
the German authorities when he
refused to sign, at the beginning
of World War I, a declaration
supporting the Kaiser and his
government. At the beginning
of the next German catastrophe,
the Nazis forced in 1933 almost
all Jewish professors out of their positions (and brutally worse was to come).
Constance Reid (1970) relates in her wonderful biography how the Nazi minister
of education said to Hilbert at a banquet in 1933 that mathematical life in
5 Who of us would not be glad to lift the veil behind which the future lies hidden, to cast a glance at the next
advances of our science and at the secrets of its development during future centuries!
587
Göttingen probably had not suffered from being freed of Jewish influence.
Hilbert’s reply: Jelitten? Das hat nicht jelitten, das jibt es nicht mehr.6
After work on the Dirichlet Principle, Waring’s Problem, the transcendence of e
and π , integral equations, Hilbert spaces (spectral theory ), calculus of variations,
and a less successful attempt at laying the foundations of modern physics, Hilbert
returned to logic and the foundations of mathematics in the 1920s. The 19th
century philosopher Emil du Bois-Reymond had pointed to the limits of our
understanding of nature: ignoramus et ignorabimus7 . Hilbert was strongly
opposed to this scepticism (in der Mathematik gibt es kein ignorabimus8 ) and set
himself the goal of formalizing mathematics in a symbolic way, as pioneered by
Gottlob Frege, and Bertrand Russell and Alfred North Whitehead. Alas, Hilbert’s
program was proved to be infeasible on this point by Kurt Gödel and Alan
Turing; see Section 14.6 for the interesting juxtaposition of Hilbert’s belief and a
precocious undecidability result in polynomial factorization by van der Waerden.
Although that particular goal of Hilbert’s turned out to be unattainable, the ideas
he introduced into proof theory and symbolic logic are alive and well today; see
Section 24.1 for a small example. In fact, modern programming languages
realize, in some sense, Hilbert’s program of formalizing mathematics and science.
In the last decade of Hilbert’s life, his health—including his mental
facilities—deteriorated, and he led a secluded life. He died in February 1943, of
the long-term effects of a fall. By then, the war had his country in its grip, and
only a miserable procession of a dozen people accompanied the great
mathematician on his last trip.
588
Tant que l’Algèbre et la Géométrie ont été séparées, leurs progrès
ont été lents et leurs usages bornés; mais lorsque ces deux sciences
se sont réunies, elles se sont prêté des forces mutuelles
et ont marché ensemble d’un pas rapide vers la perfection.1
Joseph Louis Lagrange (1795)
1 As long as algebra and geometry proceeded separately, their progress was slow and their application limited;
but when these two sciences joined forces, they mutually strengthened each other, and marched together at a rapid
pace toward perfection.
2 Actually the effort required to find this divisor will, in several cases, be so large as to discourage the most
intrepid Computer. [. . . ] In an undertaking that is as hard as elimination often is, it is not useless to multiply the
methods between which Computers can make their choice.
21
Gröbner bases
E XAMPLE 21.1. Figure 21.1 shows a very simple robot, one-armed with two
joints. The arm is fixed at one end with a joint to a point (say, the origin of the
Cartesian plane), and has another joint in the middle. The distance between the
two joints is 2, the joint between the two arms is in position (x, y), and the distance
from the second joint to the endpoint, at position (z, w), is 1. Furthermore, there is
591
592 21. Gröbner bases
Q P
S
A R B
F IGURE 21.2: The three medians AP, BQ, and CR of a triangle ABC intersect at the center
of gravity S.
and an answer to the question is either a quadruple (x, y, z, w) satisfying (1) and the
additional equation w = λz + µ, or a proof that no such quadruple exists. ✸
E XAMPLE 21.2. A well-known geometric theorem says that the three medians of
a triangle intersect at one point, the center of gravity of the triangle, and that the
intersection point trisects each median (Figure 21.2). We now formulate this as
21.1. Polynomial ideals 593
a problem about multivariate polynomials. Since the assumptions and the conclu-
sion of the theorem are invariant under translation, rotation, and scaling, we may
assume that two of the vertices of the triangle are A = (0, 0) and B = (1, 0), and the
third point is C = (x, y), with arbitrary x, y ∈ R. Then the midpoints of the three
edges BC, AC, and AB are P = ((x + 1)/2, y/2), Q = (x/2, y/2), and R = (1/2, 0),
respectively. We let S = (u, v) be the intersection point of the two medians AP
and BQ. (If y = 0, then these two lines coincide.) The condition that S lies on AP
is equivalent to saying that AS and AP have the same slope, so that
u x+1
= ,
v y
or, after clearing denominators,
f1 = uy − v(x + 1) = 0.
Similarly, the condition that S lies on BQ can be expressed as
f2 = (u − 1)y − v(x − 2) = 0.
The claims now are that S also lies on the third median CR, or
g1 = −2(u − x)y − (v − y)(1 − 2x) = −2uy − (v − y) + 2vx = 0,
and that S trisects each of the three medians, so that
(u, v) = AS = 2SP = (x + 1 − 2u, y − 2v),
(u − 1, v) = BS = 2SQ = (x − 2u, y − 2v),
(u − x, v − y) = CS = 2SR = (−2u + 1, −2v),
or equivalently,
g2 = 3u − x − 1 = 0 and g3 = 3v − y = 0.
A short computation shows that g1 = − f1 − f2 , so that g1 = 0 follows from f1 =
f2 = 0, which establishes that the three medians intersect indeed in S. We will
continue this example in Section 21.6. ✸
◦ Is V (I) 6= Ø?
◦ How “big” is V (I)?
◦ Ideal membership problem: given f ∈ R, is f ∈ I?
◦ Triviality: Is I = R?
g1 = − f1 − f2 ∈ h f1 , f2 i ⊆ R[u, v, x, y],
is the intersection of the circle V (x2 + y2 − 1) with the line V (y − 2) (see Fig-
ure 21.3), which is empty over R. If we regard f1 , f2 as polynomials in C[x, y] and
consider their variety over the complex numbers, then
√ √
V (I) = {(u, 2) ∈ C 2 : u2 = −3} = {( 3i, 2), (− 3i, 2)}
√
consists of two points, where i = −1 ∈ C.
✻y
V (y − 2)
V (x2 + y2 − 1)
✲
x
(ii) Let f = (y2 + 6)(x − 1) − y(x2 + 1), g = (x2 + 6)(y − 1) − x(y2 + 1), h =
(x − 5/2)2 + (y − 5/2)2 − 1/2 in C[x, y], and I = h f , gi. We have seen in Example
6.41 that V (I), the intersection of the two plane curves V ( f ) and V (g), consists of
the six points
( )
1 ± √15i 1 ∓ √15i
V (I) = (2, 2), (2, 3), (3, 2), (3, 3), , ⊆ C 2. (2)
2 2
21.2. Monomial orders and multivariate division with remainder 595
h f1 , . . . , fs i = hgcd( f1 , . . . , fs )i (3)
(Exercise 21.3), so that we may assume s = 1. Now we let f , g ∈ F[x] and divide f
by g with remainder, yielding q, r ∈ F[x] with f = qg + r and deg r < deg g. Then
f ∈ hgi ⇐⇒ r = 0, (4)
These conditions imply that < is asymmetric: ((α < β ) and (β < α)) is always
false (Exercise 21.7). A partial order is a total order (or simply order) if either
596 21. Gröbner bases
xα = x1α1 · · · xnαn ∈ R.
In all three examples, the variables (that is, the monomials of degree one) are
ordered as x1 ≻ x2 ≻ . . . ≻ xn−1 ≻ xn . “Graded” refers to the fact that the total
degree ∑ αi is the main criterion. In the case n = 1, we have ≺lex = ≺grlex = ≺grevlex .
Once we have a monomial order on R, we can sort terms of a polynomial ac-
cording to ≺.
E XAMPLE 21.5 (continued). Let f = 4xyz2 + 4x3 − 5y4 + 7xy2 z ∈ Q[x, y, z] (we
always identify x, y, z with x1 , x2 , x3 ). Then the orders of f with respect to ≺lex ,
≺grlex , and ≺grevlex are: 4x3 + 7xy2 z + 4xyz2 − 5y4 , 7xy2 z + 4xyz2 − 5y4 + 4x3 , and
−5y4 + 7xy2 z + 4xyz2 + 4x3 , respectively. ✸
T HEOREM 21.6.
≺lex , ≺grlex , and ≺grevlex , are monomial orders.
P ROOF. The proof is a simple check; we give some details only for ≺grevlex . We
omit the verification that ≺grevlex is a partial order. For each α, β ∈ N n with α 6= β ,
we have either ∑1≤i≤n αi < ∑1≤i≤n βi , or ∑1≤i≤n βi < ∑1≤i≤n αi , or ∑1≤i≤n αi =
∑1≤i≤n βi , and in the last case either the rightmost nonzero entry in α − β is positive
or the rightmost nonzero entry in β − α is positive. Thus ≺grevlex is total.
For condition (ii), we have
Our next goal is an algorithm for division with remainder in R. Given polyno-
mials f , f1 , . . . , fs ∈ R, we want to write f = q1 f1 + . . . + qs fs + r with q1 , . . . , qs , r
in R. Before stating the algorithm formally, we give some examples.
xy + 1 y + 1 xy + 1 y + 1
xy2 + 1 y xy2 + 1 xy
−(xy2 + y) −(xy2 + xy)
−y + 1 −1 −xy + 1 −x
−(−y − 1) −(−xy − x)
2 x+1
In the left hand table, division is performed as in the univariate case, with the
difference that we have two divisors instead of one. The quotient of the two lead-
ing terms that we get in each step is recorded in the column below the respec-
tive divisor. In the last line, 2 is not divisible by the leading term of f1 or f2 ,
21.2. Monomial orders and multivariate division with remainder 599
The following theorem implies the correctness of the algorithm; its proof is left
as Exercise 21.12.
600 21. Gröbner bases
T HEOREM 21.12.
Each time the algorithm passes through step 3, the following invariants hold.
(i) mdeg(p) 4 mdeg( f ) and f = p + q1 f1 + · · · + qs fs + r,
(ii) qi 6= 0 =⇒ mdeg(qi fi ) 4 mdeg( f ) for 1 ≤ i ≤ s,
(iii) no term in r is divisible by any lt( fi ).
This kind of division with remainder need not be unique: there may be a choice
for the value of i in step 3 when the leading term of f is divisible by more than one
lt( fi ). We have already encountered this in Example 21.9, and here is another one.
Our goal is now to find a special basis of an arbitrary ideal such that the remain-
der on division by that basis is unique and thus gives the correct answer to the ideal
membership problem, as in (4) for n = 1. At first sight, it is not clear whether such
a type of basis exists at all.
xβ ∈ I ⇐⇒ ∃α ∈ A xα | xβ .
L EMMA 21.16. Let I ⊆ R be a monomial ideal and f ∈ R. Then the following are
equivalent:
(i) f ∈ I ,
(ii) each term of f is in I ,
(iii) f is an F –linear combination of monomials in I .
For example, if I = hx3 , x2 yi ⊆ Q[x, y], then the lemma shows that 3x4 +5x2 y3 ∈ I
and 2x4 y + 7x2 6∈ I. The implication (i) =⇒ (ii) is false for some ideals, as shown
in Example 21.21 below.
C OROLLARY 21.17.
Two monomial ideals are identical if and only if they contain the same monomials.
602 21. Gröbner bases
P ROOF. Except for its last sentence, our proof is purely combinatorial, without
any algebra. The claim is trivial if A = Ø, and we may assume that A is nonempty.
We define a relation “≤” on N n by
α ≤ β ⇐⇒ αi ≤ βi for 1 ≤ i ≤ n,
For any α ∈ N n there are only finitely many β ∈ N n with β ≤ α (Exercise 21.13),
and hence there is no infinite descending chain of elements α(1) > α(2) > α(3) > · · ·
in N n . In particular, for any α ∈ A there is some minimal element β ∈ B such that
β ≤ α.
It remains to show that B is finite, which we prove by induction on n. If n = 1,
then < is a total order, and B consists of the unique smallest element of A. If
n ≥ 2, we let A∗ = {(α1 , . . . , αn−1 ) ∈ N n−1 : ∃αn ∈ N (α1 , . . . , αn ) ∈ A}. By the
induction hypothesis, the set B∗ of minimal elements of A∗ is finite. For each β =
(β1 , . . . , βn−1 ) ∈ B∗ , we choose some bβ ∈ N such that (β1 , . . . , βn−1 , bβ ) ∈ A, and
let b = max{bβ : β ∈ B∗ }. We claim that every (α1 , . . . , αn ) ∈ B has αn ≤ b. Let α =
(α1 , . . . , αn ) ∈ B. Then there exists some minimal element β = (β1 , . . . , βn−1 ) ∈ B∗
of A∗ such that β ≤ (α1 , . . . , αn−1 ). If αn > b, then
and α is not minimal. This proves the claim, and similarly we also find that all
other coordinates of minimal elements are bounded, which implies that there are
only finitely many of them.
Now (6) and the fact that α ≤ β ⇐⇒ xα | xβ imply that xA ⊆ hxB i, whence
hx i ⊆ hxB i, and the reverse inclusion follows trivially from B ⊆ A. ✷
A
E XAMPLE 21.19. Let n = 2 and A = {(α1 , α2 ) ∈ N 2 : 6α2 = α12 −7α1 +18}. Then
the set of minimal elements is B = {(0, 3), (1, 2), (3, 1)}, as can be seen from Fig-
ure 21.4, and hence hxA i = hy3 , xy2 , x3 yi. ✸
21.3. Monomial ideals and Hilbert’s basis theorem 603
α2
α1
C OROLLARY 21.20.
Let ≺ be a total order on N n such that
∀α, β , γ ∈ N α ≺ β =⇒ α + γ ≺ β + γ .
Then ≺ is a well-order if and only if α < 0 for all α ∈ N n .
P ROOF. We only prove “⇐=”; the reverse implication is Exercise 21.8. Let A ⊆
N n be nonempty, and I = hxA i ⊆ R. Then I is finitely generated, by Dickson’s
lemma, and
∃α1 , . . . , αs ∈ A I = hxα1 , . . . , xαs i.
We order them so that α1 ≺ α2 ≺ · · · ≺ αs , and claim that min≺ A = α1 . Let α ∈ A
be arbitrary. Since xα ∈ I, by Lemma 21.15 there exist i ≤ s and γ ∈ N n with
α = αi + γ . Thus α = αi + γ < α1 + γ < α1 + 0 = α1 , and hence α1 = min≺ A. ✷
Thus we can replace the condition (iii) in the definition of monomial orders by
(iii)’ ∀α ∈ N n α < 0.
For any subset G ⊆ R different from Ø and {0}, we let lt(G) = {lt(g): g ∈ G}.
If I ⊆ R is an ideal, then there is a finite subset G ⊆ I such that hlt(G)i = hlt(I)i,
by Dickson’s lemma. However, it can happen that a finite set G generates I but
hlt(G)i ( hlt(I)i, as in the following example.
604 21. Gröbner bases
Together with Dickson’s lemma, applied to hlt(I)i, and the fact that the zero
ideal {0} is generated by the zero polynomial, we obtain the following famous
result.
S
P ROOF. Let I = j≥1 I j . Then I is an ideal, which is finitely generated, by Hil-
bert’s basis theorem, say I = hg1 , . . . , gs i. With n = min{ j ≥ 1: g1 , . . . , gs ∈ I j }, we
then have In = In+1 = · · · = I. ✷
Lemma 21.22 says that any Gröbner basis G for I is in fact a basis of I in the
ring theoretic sense, which means that hGi = I. With the convention that hi =
hØi = {0}, Hilbert’s basis theorem implies the following.
C OROLLARY 21.26.
Every ideal I in R = F[x1 , . . . , xn ] has a Gröbner basis.
In Example 21.21, G is not a Gröbner basis for I, but {g, h, x2 , 2xy, −2y2 + x} is,
as we will see below.
We now want to show that division with remainder by a Gröbner basis is a valid
ideal membership test. Throughout this section, we assume some monomial order
on R.
(i) f − r ∈ I ,
P ROOF. Existence follows from Theorem 21.12. For the uniqueness, we suppose
that f = h1 + r1 = h2 + r2 with h1 , h2 ∈ I and no term of r1 or r2 divisible by any
of lt(G). Then r1 − r2 = h2 − h1 ∈ I, and lt(r1 − r2 ) is divisible by some lt(g) with
g ∈ G, by Lemma 21.15. Hence r1 − r2 = 0. ✷
f rem G = r ∈ R.
T HEOREM 21.28.
Let G be a Gröbner basis for the ideal I ⊆ R with respect to a monomial order ≺,
and f ∈ R. Then f ∈ I if and only if f rem G = 0.
Clearly S(h, g) = −S(g, h), and since xγ / lt(g), xγ / lt(h) ∈ R, we have S(g, h) ∈
hg, hi. In Example 21.21, we have α = (3, 0), β = (2, 1), γ = (3, 1), and
x3 y x3 y
S(g, h) = g − h = −x2 .
x3 x2 y
The following lemma says that when cancellation of leading terms occurs in a
linear combination of polynomials in G, it necessarily comes from S-polynomials.
f= ∑ ci xαi gi ∈ R, (8)
1≤i≤s
and hence mdeg(S(gi , g j )) 4 γi j , by Lemma 21.8. Since the leading terms in (7)
cancel, we have
g = f − c1 xδ−γ12 S(g1 , g2 )
α1 α2 αi δ −γ12 xγ12 xγ12
= c1 x g1 + c2 x g2 + ∑ ci x gi − c1 x g1 − g2
3≤i≤s lt(g1 ) lt(g2 )
= c1 (xα1 − xδ−mdeg(g1 ) )g1 + (c2 xα2 + c1 xδ−mdeg(g2 ) )g2 + ∑ ci xαi gi
3≤i≤s
α2 αi
= (c1 + c2 )x g2 + ∑ ci x gi ,
3≤i≤s
g= ∑ ci j xδ−γi j S(gi , g j ),
2≤i< j≤s
T HEOREM 21.31.
A finite set G = {g1 , . . . , gs } ⊆ R is a Gröbner basis of the ideal hGi if and only if
P ROOF. “=⇒” follows from Theorem 21.28, since S(gi , g j ) ∈ I = hGi for all i, j.
For the reverse direction, we let f ∈ I \ {0}, and have to show that lt( f ) ∈ hlt(G)i.
We write
f = ∑ qi gi , δ = max≺ {mdeg(qi gi ): 1 ≤ i ≤ s}, (11)
1≤i≤s
608 21. Gröbner bases
with all qi ∈ R. Then mdeg( f ) 4 δ . If strict inequality holds, then some cancella-
tion of leading terms occurs in (11), and
f∗ = ∑ lt(qi )gi
1≤i≤s
mdeg(qi gi )=δ
S( f1 , f3 ) rem ( f1 , f2 , f3 ) = −2xy = f4 ,
21.5. Buchberger’s algorithm 609
–1
0 z
y
0
–1
1 x
0 1
–1
1
S( f1 , f4 ) = y · f1 − (− x2 ) · f4 = −2xy2 = y · f4 ,
2
S( f2 , f3 ) = 1 · f2 − (−y) f3 = −2y2 + x.
1. G ←− { f1 , . . . , fs }
2. repeat
3. S ←− Ø
order the elements of G somehow as g1 , . . . , gt
for i = 1, . . . ,t − 1 and j = i + 1, . . . ,t do
4. r ←− S(gi , g j ) rem (g1 , . . . , gt )
if r 6= 0 then S ←− S ∪ {r}
5. if S = Ø then return G else G ←− G ∪ S
T HEOREM 21.34.
Algorithm 21.33 works correctly as specified.
P ROOF. First we show the correctness assuming that the procedure terminates. At
any stage of the algorithm, the set G in step 2 is a basis of I and f1 , . . . , fs ∈ G,
since this is true initially and only elements of I, namely the remainders of S-
polynomials of gi , g j ∈ I on division by elements of I, are added to G during the
algorithm. If the algorithm terminates, the remainders of all the S-polynomials on
division by G are zero, and G is a Gröbner basis by Theorem 21.31.
It remains to show that the algorithm terminates. If G and G∗ correspond to
successive passes through step 2, then G∗ ⊇ G and hlt(G∗ )i ⊇ hlt(G)i. Hence the
ideals hlt(G)i in successive passes through step 2 form an ascending chain, which
stabilizes by the ascending chain condition of Corollary 21.24. Thus, after a finite
number of steps we have hlt(G∗ )i = hlt(G)i. We claim that then G = G∗ . So let
g, h ∈ G, and r = S(g, h) rem G. Then r ∈ G∗ and either r = 0 or lt(r) ∈ hlt(G∗ )i =
hlt(G)i, and from the definition of the remainder we conclude that r = 0. ✷
C OROLLARY 21.35.
The following problems are solvable using Gröbner bases:
T HEOREM 21.38.
Every ideal has a unique reduced Gröbner basis.
P ROOF. We first show the existence. Repeatedly applying Lemma 21.36 if neces-
sary, we may start with a minimal Gröbner basis G = {g1 , . . . , gs }. For 1 ≤ i ≤ s,
we then set
hi = gi rem {h1 , . . . , hi−1 , gi+1 , . . . , gs }.
Induction on i proves that lt(g j ) = lt(h j ) and h j is reduced with respect to Gi =
{h1 , . . . , hi , gi+1 , . . . , gs } for 0 ≤ j ≤ i ≤ s, and finally Gs = {h1 , . . . , hs } is a reduced
Gröbner basis.
Now suppose that G and G∗ are reduced Gröbner bases of I. We claim that
lt(G) = lt(G∗ ). For g ∈ lt(G) ⊆ hlt(G)i = lt(I) = hlt(G∗ )i, there is some g∗ ∈ G∗
such that lt(g∗ ) | lt(g), by Lemma 21.15. By a symmetric argument, there exists
a g∗∗ ∈ G such that lt(g∗∗ ) | lt(g∗ ). Since G is minimal, we have lt(g) = lt(g∗ ) =
lt(g∗∗ ) ∈ lt(G∗ ), and lt(G) ⊆ lt(G∗ ). Similarly, lt(G∗ ) ⊆ lt(G), which proves the
claim.
For a given g ∈ G, let g∗ ∈ G∗ be such that lt(g) = lt(g∗ ). Both G and G∗
are reduced, and hence no monomial in g − g∗ ∈ I is divisible by any element of
lt(G) = lt(G∗ ). Thus g − g∗ = g − g∗ rem G = 0 since g − g∗ ∈ I, whence g ∈ G∗ ,
G ⊆ G∗ , and by a symmetric argument, also G∗ ⊆ G. ✷
At the beginning of this section, we saw how several polynomials may have
to be added to form a Gröbner basis. How many? In Section 21.7, we will learn
612 21. Gröbner bases
the rather devastating answer: sometimes doubly exponentially many, and their de-
grees may be doubly exponentially large (in the number of variables). It is not easy
to say how many steps Buchberger’s algorithm takes, but for such huge outputs it
uses at least exponential space.
Both Gaussian elimination and Euclid’s algorithm for gcds in F[x] are special
cases of Buchberger’s algorithm (see Exercise 21.24 for the former).
f1 = uy − vx − v, f2 = uy − vx + 2v − y
1
S( f1 , f3 ) rem ( f1 , f2 , f3 ) = uy2 − v2 x − v2 rem ( f1 , f2 , f3 ) = 0,
3
1
S( f2 , f3 ) rem ( f1 , f2 , f3 ) = uy2 − v2 x + 2v2 − vy rem ( f1 , f2 , f3 ) = 0,
3
21.6. Geometric applications 613
–1
0 z
y
0
–1
1 x
0 1
–1
1 1
f4 = f1 rem f3 = uy − xy − y, f3 rem f4 = f3 ,
3 3
Implicitization. Let f1 , . . . , fn ∈ F[t1 , . . . ,tm ], and suppose that the affine alge-
braic variety V ⊆ F n is given in parametrized form by
614 21. Gröbner bases
x1 = f1 (t1 , . . . ,tm ),
..
.
xn = fn (t1 , . . . ,tm ),
so that V is “explicitly” described as V = {a ∈ F n : ∃b ∈ F m a = ( f1 (b), . . . , fn (b))}.
The task is now to find polynomials g1 , . . . , gs ∈ F[x1 , . . . , xn ] such that V has the
“implicit” representation V = V (I), where I = hg1 , . . . , gs i. (More precisely, V (I)
will equal the “closure” of V .)
E XAMPLE 21.32 (continued). The twisted cubic C from Example 21.32 can be
parametrized by
x = t, y = t 2 , z = t 3 .
An implicitization for C is g1 = y − x2 , g2 = z − x3 . The curve is illustrated in
Figures 21.5 and 21.6 on pages 609 and 613, respectively. The latter corresponds
to the explicit representation of C (the plot was generated by letting the parameter
t run through the interval [−1, 1]), while the former depicts the implicit form as
the intersection of the two surfaces defined by g1 and g2 ; this picture is somehow
more informative. ✸
h(x, 2) = x2 − 5x + 6 = (x − 2)(x − 3) = 0,
for x, we find the two common zeroes (3, 2) and (3, 3) of f and g in C 2 . The
other four intersection points √
from (2) can be obtained in a similar fashion, by
substituting y = 2 or y = (1 ± 15i)/2 in h = p = 0 and solving for x.
616 21. Gröbner bases
T HEOREM 21.40.
The problem of finding a reduced Gröbner basis is EX PSPA CE -complete.
f= ∑ qi fi . (12)
1≤i≤s
Notes 617
She gave a doubly exponential bound on the degrees of these qi ’s; see also Mayr &
Meyer (1982). Mayr & Ritscher (2010) showed that the degrees of the polynomials
in a reduced Gröbner basis for an ideal in F[x1 , . . . , xn ] of dimension r are at most
d n−r 2r
2 +d , (13)
2
when deg fi ≤ d for all i. This bound does not depend on the number of poly-
nomials defining the ideal nor on their coefficients, depends polynomially on the
degree, exponentially on the codimension and doubly exponentially on the dimen-
sion. They also show a lower bound of a similar form.
If an ideal is such that the degrees in its reduced Gröbner basis come close to
the doubly exponential bound (13), one might think that the output cannot even be
written down in exponential space, and similarly for the certificate (12) of ideal
membership. However, the model of space-bounded computations is such that one
may take doubly exponential time to write a result of doubly exponential length
on a special output tape, all the while using only singly exponential work space
(Section 25.8).
Hilbert’s famous Nullstellensatz says the following. If F is algebraically closed
(say, F = C), f , f1 , . . . , fs ∈ F[x1 , . . . , xn ], and f (a) = 0 for all a ∈ F n with f1 (a) =
· · · = fs (a) = 0, then there exists e ∈ N with f e ∈ h f1 , . . . , fs i. In particular, the
variety V ( f1 , . . . , fs ) is empty if and only if 1 ∈ h f1 , . . . , fs i. If this is the case, then
1 will appear in any Gröbner basis of f1 , . . . , fs . This provides a test of whether
V ( f1 , . . . , fs ) is empty. For this particular instance of IM better results are available:
one can always choose e and the degrees in (12) to be simply exponential, and this
implies that the problem is in PSPA CE .
The worst-case cost of Buchberger’s algorithm is still unknown today, but the
important result of Theorem 21.40 completely settles the question of the “best”
worst-case cost of any algorithm for Gröbner bases, and provides a lower bound
for Buchberger’s. It gives rise to the pessimistic view that these methods for poly-
nomial ideals are not useful in practice, except for rather small cases.
However, it is not the full story. The inputs used for the lower bound are more
combinatorial than geometric in nature, while most of the problems that people
try to solve derive from geometric tasks. The algorithm of Kühnle & Mayr (1996)
uses essentially the same time for all polynomials of a given degree and number of
variables and thus is uniformly impractical, while one might hope that “natural”
geometric problems are easier to solve than “combinatorial” ones.
Notes. 21.1. The papers in Eisenbud & Robbiano (1993) present the state of the art at
that time. A good reference for this chapter is Cox, Little & O’Shea (1997), which we have
followed closely in our exposition. Cox, Little & O’Shea (1998) discuss more advanced
topics.
618 21. Gröbner bases
21.3. With the passage of time, the proof of Hilbert’s basis theorem has become quite
simple. But his 1890 paper was a milestone, solving this long–standing open question, and
furthermore introducing the Hilbert function of an ideal and showing that invariant rings
are finitely generated.
21.5. Buchberger (1965,1970,1976,1985,1987) explains his Gröbner basis method, gives
many references, and puts it in the context of more general questions about grammars and
term writing systems. Two further important contributions of Bruno Buchberger are the
founding of the Journal of Symbolic Computation in 1985 and of the Research Institute for
Symbolic Computation (RISC) in Linz, Austria.
21.6. Buchberger & Winkler (1998) contains a variety of tutorials on applications of Gröb-
ner bases. With slight modifications, the approach described in the text works for a rich
class of geometric theorems (see Cox, Little & O’Shea 1997, §6.4, and Wu 1994).
In Section 21.6, we found that g2 6∈ I and yg2 ∈ I. Thus we may conclude that g2 (x, y) =
0 if (x, y) ∈ V (I) and y 6= 0. This can be phrased as an ideal membership property via
Rabinowitsch’s trick (1930) of adding 1 − yz to I, where z is a new indeterminate. This
ensures that the value of y is nonzero, and g2 = 3z · f4 + g2 · (1 − yz) ∈ h f3 , f4 , 1 − yzi.
The reverse question of transforming an implicit representation of a variety into an ex-
plicit one has in general no solution; it can be solved only for the “rational varieties” of
genus zero. However, it can be solved “near a smooth point” in general, if we allow ap-
propriate power series for the fi ’s, as in the implicit function theorem of calculus. The
state of the art about algorithms on parametric varieties is presented in the twelve articles
of a Special Issue of the Journal of Symbolic Computation (Hoffman, Sendra & Winkler
1997).
It can be shown that for zero-dimensional ideals I ∈ F[x1 , . . . , xn ], so that V (I) is finite,
a Gröbner basis with respect to lexicographic order x1 ≺ x2 ≺ · · · ≺ xn always contains a
“triangular” subset g1 , . . . , gn , such that gi ∈ F[x1 , . . . , xi ] and lm(gi ) is a power of xi , for
1 ≤ i ≤ n (see, for example, Becker & Weispfenning (1993), Theorem 6.54, or Cox, Little
& O’Shea (1997), §3.1 and 3.2).
21.7. Yap (1991) gave an improvement of Mayr & Meyer’s result. Brownawell (1987)
and Kollár (1988) proved that one can always choose the Nullstellensatz exponent e to
be simply exponential; see also Amoroso (1989). Caniglia, Galligo & Heintz (1989),
Lakshman (1990), and Berenstein & Yger (1990) showed that in some important cases
the qi ’s in (12) have only singly exponential degree: for zero-dimensional varieties, and
for complete intersections.
Giusti (1984), Möller & Mora (1984), Bayer & Stillman (1988), and Dubé (1990)
proved upper bounds for the elements of a reduced Gröbner basis. Huynh (1986) showed
a lower bound on the number and degrees of polynomials in Gröbner bases. Mayr (1997)
gives a survey of complexity results, more references, and discusses applications such as
those in Section 24.2.
Bayer & Stillman (1988) considered an invariant m associated to any multivariate ideal,
called the Castelnuovo-Mumford regularity . This number seems to be fairly small for
many natural geometric problems, but is exponential in the number of variables for the
combinatorial problems of Mayr & Meyer (1982). Furthermore, Bayer & Stillman prove
that, after a generic change of coordinates, the polynomials in a Gröbner basis with respect
to the graded reverse lexicographic order ≺grevlex have degree at most m. This gives rise to
a bit of hope that the method might be able to deal successfully with interesting geometric
problems, and to a practical recommendation in favor of ≺grevlex .
Exercises 619
Almost all computer algebra systems contain some routines for Gröbner bases; Dave
Bayer’s system M ACAULAY focuses particularly on this problem, and S INGULAR is an-
other powerful package in this area. The research projects P OSSO and F RISCO of the Eu-
ropean Community have produced substantial software and a library of benchmark prob-
lems. Efficient algorithms and software are a highly active area of research. Three topics
of particular interest are modular algorithms (Traverso 1988), selection strategies for S-
polynomials (Giovini, Mora, Niesi, Robbiano & Traverso 1991), and conversion between
Gröbner bases with respect to different orders (Faugère, Gianni, Lazard & Mora 1993).
Finally, we mention that there are other methods of dealing with certain geometric prob-
lems, based on cylindrical algebraic decomposition (Collins 1975), elimination theory, also
using arithmetic circuits as a data structure (Chistov & Grigor’ev 1984, Caniglia, Galligo
& Heintz 1988, Fitchas, Galligo & Morgenstern 1990, Giusti & Heintz 1991), u-resultants
(Macaulay 1902, 1916, 1922, Canny 1987), and characteristic sets (Ritt 1950, Wu 1994,
Gallo & Mishra 1991).
The important subject of computational real algebraic geometry started with Tarski
(1948). Major progress was made by Collins (1975), and later by Ben-Or, Kozen & Reif
(1986), Fitchas, Galligo & Morgenstern (1987), Grigor’ev (1988), Canny (1988), Renegar
(1992a, 1992b, 1992c), and others. See the surveys of Heintz, Recio & Roy (1991) and
Renegar (1991) for references and applications; our cyclohexane example in Section 24.4
can be viewed as such an application.
Exercises.
21.1 Let F be a field and x, y indeterminates. Prove that the two ideals hx, yi and hgcd(x, y)i in
F[x, y] are distinct, and conclude that F[x, y] is not Euclidean. Hint: Exercise 3.17.
21.2 Let F be a field. Prove that the ideals I = hx + xy, y + xy, x2 , y2 i and J = hx, yi in F[x, y] are
identical. Your proof should also work if char F = 2. Hint: It is sufficient to prove that the generators
of each ideal belong to the other ideal.
21.3 Prove (3). Hint: Theorem 4.11.
21.4∗ Besides the usual Cartesian coordinates (u, v) with u, v ∈ R, we represent the points of the
plane by polar coordinates (r, ϕ) with r ∈ R and 0 ≤ ϕ < 2π. This representation is not unique;
for example, when ϕ < π then (r, ϕ) and (−r, ϕ + π) represent the same point. We obtain the polar
coordinates from the Cartesian ones by the formulas u = r cos ϕ, and v = r sin ϕ. Now consider the
curve C = {(r, ϕ) : 0 ≤ ϕ < 2π and r = sin 2ϕ} ⊆ R 2 , and let I = h(x2 + y2 )3 − 4x2 y2 i ⊆ R[x, y].
(i) Create a plot of C.
(ii) Using the addition formulas for sine and cosine, show that C ⊆ V (I).
(iii) Prove that also the reverse inclusion V (I) ⊆ C holds (be careful with the signs).
21.5∗ Let F be a field and n ∈ N. For a subset M ⊆ F n , we define the ideal of M by
using ≺=≺grlex with x ≺ y ≺ z. Compare your output to the Gröbner basis that M APLE computes
with a different order.
21.24∗ Let F be a field, n ∈ N, and A = (ai j )1≤i, j≤n ∈ F n×n a square matrix. Moreover, let GA =
{∑1≤ j≤n ai j x j : 1 ≤ i ≤ n} ⊆ F[x1 , . . ., xn ] be the set of linear polynomials corresponding to the rows
of A and IA = hGA i. Then V (GA ) = V (IA ) is equal to ker A, the set of solutions v ∈ F n of the linear
system Av = 0. Prove:
(i) ILA = IA if L ∈ F n×n is nonsingular.
(ii) Assume that there exists a nonsingular matrix L ∈ F n×n such that
Ir V
U = LA = ,
0 0
where r is the rank of A, Ir is the r × r identity matrix, and V ∈ F r×(n−r) (this means that no column
exchange is necessary when applying Gaussian elimination to A). Prove that GU is a reduced Gröbner
basis of IA with respect to any monomial order ≺ such that x1 ≻ x2 ≻ · · · ≻ xn .
(iii) What is the reduced Gröbner basis of IA if A is nonsingular, with respect to an arbitrary
monomial order?
21.25∗ You are to solve the following nonlinear optimization problem: Determine all maxima and
minima of the polynomial f = x2 y − 2xy + y + 1 on the unit circle S = {(u, v) ∈ R 2 : g(u, v) = 0},
where g = x2 + y2 − 1. In numerical analysis, such a problem is solved with the aid of Lagrange
multipliers: if ∇ f = ( fx , fy ) and ∇g = (gx , gy ) are the Jacobians of f and g, respectively, where
fx = ∂ f /∂x and fy , gx , gy , are defined analogously, then the equality ∇ f = λ∇g holds at a local
maximum or minimum of f on S for some λ ∈ R.
(i) Set up the system of polynomial equations
1 Beauty, I hear you ask; do not the Graces flee where integrals stretch forth their necks?
2 It may be said that the notions of differential quotient and integral, whose origin certainly goes back to
Archimedes, were essentially introduced into science by the investigations of Kepler, Descartes, Cavalieri, Fer-
mat, and Wallis. [. . . ] They had not yet noticed that differentiation and integration are inverse operations; this
capital discovery belongs to Newton and Leibniz.
22
Symbolic integration
623
624 22. Symbolic integration
L EMMA 22.2. In a differential algebra (R, D), the usual properties hold for all
f , g ∈ R:
(i) D(1) = 0,
(ii) D is R0 –linear: D(a f + bg) = aD( f ) + bD(g) for a, b ∈ R0 ,
f D( f )g − f D(g)
(iii) D = if g is a unit,
g g2
(iv) D( f n ) = n f n−1 D( f ) for n ≥ 1,
R R
(v) ( f D(g)) = f g − (D( f )g) (integration by parts).
E XAMPLE 22.3. (i) D(a) = 0 for all a ∈ R. This is the trivial derivative on R,
with R0 = R.
(ii) R = Q(x), D(x) = 1, and D(a) = 0 for all a ∈ Q. This gives the usual deriva-
tive: D(∑i fi xi ) = ∑i i fi xi−1 when all fi are rational numbers. Here, R0 = Q (Exer-
cise 22.4), and polynomials are easily integrated as
Z
fi
∑ fixi = ∑ i + 1 xi+1 . ✸
i i
L EMMA 22.4. The rational function 1/x ∈ Q(x) has no rational integral:
1
∀ f ∈ Q(x) f ′ 6= .
x
See Exercise 22.5 for a proof. The lemma motivates the need for domain exten-
sions when looking for integrals: the usual derivation on Q(x) is not surjective, so
that we need logarithms.
22.2. Hermite’s method 625
We note that log is in general a relation, not a function, since we may add an
arbitrary constant to f and get another integral of D(u)/u.
P ROOF. Splitting off the polynomial part is one division with remainder, taking
O(M(n)) operations in F. The squarefree decomposition of g can be computed us-
ing O(M(n) log n) operations, by Theorem 14.23. Using fast Chinese remaindering
(Section 10.3), the partial fraction decomposition (2) can again be computed with
O(M(n) log n) arithmetic operations (Exercise 10.18). Let di = deg gi for all i. To
analyze the cost of Hermite reduction, let 1 ≤ j ≤ i ≤ m. Then one Hermite step (3)
takes O(M(di ) log di ) operations for computing s and t, plus O(di ) operations for
updating hi, j−1 , in total O(i M(di ) log di ) operations per gi . Now
∑ i M(d i ) log di ≤ (log n)M ∑ i ≤ M(n) log n,
id
1≤i≤m 1≤i≤m
It is sufficient to use the fast Extended Euclidean Algorithm only once per gi to
compute s∗ ,t ∗ ∈ F[x] such that s∗ gi +t ∗ g′i = 1, and then for each j the polynomials
s,t can be obtained from s∗ ,t ∗ and hi j as described in Section 4.5, using only
22.3. The method of Lazard, Rioboo, Rothstein, and Trager 627
O(M(di )) arithmetic operations. This does not affect the asymptotic time bound
but is a practical improvement.
A different approach, due to Horowitz (1971), is the method of undetermined
coefficients. Splitting off the polynomial part if necessary, we may assume that
deg f < deg g. All denominators arising via (3) outside an integral divide the prod-
uct g2 g23 · · · gm
m−1
, and hence so does the denominator d in (1). Thus we may take
the latter polynomial as d, the squarefree part (Section 14.6) of g as b, and plug
a of degree deg b − 1 and c of degree deg g − deg b − 1 with unknown coefficients
into (1). This yields a linear system of equations for the coefficients of a and c,
which has a coefficient matrix with at most n rows and columns, and it can be
solved in time O(n3 ) using Gaussian elimination. Hermite reduction, however, is
asymptotically faster by nearly two orders of magnitude.
E XAMPLE 22.6 (continued). The integral in (iii) has been expressed without any
algebraic extension of the field of constants Q, while it is not clear how to do that
with the integral in (ii). In fact, from what we will prove below, it is impossible to
write the latter integral as a sum of logarithms with rational arguments. ✸
This example shows that it may be unwise to compute the integral using the
complete partial fraction decomposition. The following method computes the in-
tegral with as small an algebraic extension of the field of constants as possible.
(ii) The polynomial r = resx (b, a − yb′ ) ∈ F[y] splits over E in linear factors,
c1 , . . . , cl are precisely the distinct roots of r, and vi = gcd(b, a − ci b′ ) for
1 ≤ i ≤ l . Here, resx denotes the resultant with respect to the variable x
(Chapter 6).
a v′
= ∑ ci i ,
b 1≤i≤l vi
or equivalently,
a· ∏ vj = b · ∑ ci ui v′i ,
1≤ j≤l 1≤i≤l
where ui = ∏1≤ j≤l, j6=i v j . We claim that b = ∏1≤ j≤l v j and a = ∑1≤i≤l ci ui v′i .
Since a and b are coprime, b divides ∏1≤ j≤l v j . On the other hand, v j divides
b ∑1≤i≤l ci ui v′i and v j | ui for i 6= j, whence v j | b · c j u j v′j . But c j ∈ E is nonzero,
gcd(v j , u j ) = 1, and gcd(v j , v′j ) = 1, so that v j | b for 1 ≤ j ≤ l. By the relative
primality of the v j , we also have ∏ j v j | b. This implies that b = ∏1≤ j≤l v j , since b
and all the v j are monic, and a = ∑ ci ui v′i , as claimed.
Now Lemma 14.22 yields
′ v j if c = c j for some j ∈ {1, . . . , l},
gcd(b, a − cb ) =
1 otherwise,
by Lemma 6.25. Thus r splits over E, and {c1 , . . . , cl } are precisely the distinct
roots of r.
(ii) =⇒ (i): Let K be the splitting field of b over E, and λ1 , . . . , λn ∈ K pairwise
distinct with b = ∏1≤k≤n (x − λk ). Since b is squarefree, b′ (λk ) 6= 0 for 1 ≤ k ≤ n.
For c ∈ K, we have
for 1 ≤ k ≤ n. Both a and ∑1≤i≤l ci ui v′i have degrees less than n and interpolate the
same values at the n points λ1 , . . . , λn , and thus are equal. Hence
′ v′i 1 a
∑ ci log vi = ∑ vi = b · ∑ ci ui v′i = b . ✷
ci
1≤i≤l 1≤i≤l 1≤i≤l
Although Theorem 22.8 keeps the degree of the algebraic extension as small as
possible, it does not avoid gcd computations in such an algebraic extension. The
following observation, however, will lead to a purely rational algorithm.
(i) deg vi = e.
(ii) Let w(x, y) ∈ F(y)[x] denote the remainder of degree e in the monic Euclid-
ean Algorithm for b and a − yb′ in F(y)[x]. Then vi = w(x, ci ).
qi i+1
1. h ←− f rem g, ∑i qi xi ←− f quo g, U ←− ∑ x
i i+1
h hi j
3. compute the partial fraction decomposition = ∑ ∑ j , with hi j ∈
g 1≤i≤m 1≤ j≤i gi
F[x] such that deg hi j < deg gi for 1 ≤ j ≤ i ≤ m
4. { Hermite reduction }
V ←− 0
for i = 2, . . . , m do
for j = i, i − 1, . . . , 2 do
compute s,t ∈ F[x] such that sgi + tg′i = hi j and deg s, degt <
deg gi using Theorem 4.10
t t′
V ←− V − , hi, j−1 ←− hi, j−1 + s +
( j − 1)gij−1 j−1
5. W ←− 0
for i = 1, . . . , m do
6. { Lazard-Rioboo-Trager method }
a ←− hi1 , b ←− gi , r ←− resx (b, a − yb′ )
call Yun’s algorithm 14.21 to compute the squarefree decomposition
r = lc(r) ∏ ree of r
1≤e≤d
8. return U +V +W
left as is, without further evaluation (for example, by using the RootOf construct
in M APLE).
W= ∑ γ log(x − 1/2γ ),
r1 (γ )=0
√
and if we plug in the two zeroes ±1/2 2 ∈ R of r1 for γ , we arrive at the same
result as in Example 22.6. ✸
T HEOREM 22.11.
Algorithm 22.10 works correctly as specified. If f and g are of degree at most n,
its running time is O(n M(n) log n) or O∼ (n2 ) operations in F .
P ROOF. Correctness follows from the discussion preceding Theorem 22.7 and
from Theorems 22.8 and 22.9.
By Theorem 22.7, steps 1 through 4 take O(M(n) log n) operations. Let i ∈
{1, . . . , m} and di = deg gi . Exercise 6.12 implies that deg r = di , and the cost for
computing r is O(di M(di ) log di ), by Corollary 11.21. Within the same time bound,
we can in fact compute all the we with deg re > 0 in step 7, by Exercise 11.9, since
∑ e≤ ∑ e deg re = deg r = di .
1≤e≤d 1≤e≤d
deg re >0
Now ∑1≤i≤m di ≤ n, and the overall cost for the loop 5 is O(n M(n) log n) operations
in F. This dominates the cost for the other steps, and the claim follows. ✷
f ′ = (τ g)′ = τ ′ g + τ g′ = (τ ′ + στ )g,
and this equals g if and only if τ satisfies the first order differential equation
τ ′ + στ = 1. (4)
We note that only rational functions occur in (4). Thus we have eliminated
all hyperexponential elements and reduced the original task to a purely rational
problem. In what follows, we discuss how to solve the differential equation (4).
We write σ = a/b and τ = u/v, with nonzero polynomials a, b, u, v ∈ F[x] such
that b and v are monic and gcd(a, b) = gcd(u, v) = 1. Then (4) becomes
u′ v − uv′ au
τ ′ + στ = + = 1.
v2 bv
After multiplying by bv2 , we obtain the equivalent polynomial differential equation
Conversely, any solution u, v ∈ F[x] of (5) for given a, b ∈ F[x] yields a solution of
our hyperexponential integration problem by setting f = gu/v.
The algorithm proceeds in two phases. In the first phase, we find a multiple V
of any possible denominator v. Once we know v (or a multiple of it), then (5) is
just a system of linear equations in the coefficients of u. It is easily solved if we
can bound the degree of u; such a bound is calculated in Lemma 22.18 below.
For the first phase, we want to determine a suitable multiple of v. Let v0 , v1 ∈
F[x] be such that v = v0 ·gcd(v, v′ ) and v′ = v1 ·gcd(v, v′ ). Dividing (5) by gcd(v, v′ ),
we find
bu′ v0 − buv1 + auv0 = bvv0 . (6)
We see that v0 divides buv1 , and since gcd(u, v) = 1 = gcd(v0 , v1 ), it divides b.
Thus we can divide (6) by v0 and obtain
b
bu′ + a − v1 u = bv.
v0
Again, since v0 divides b and is coprime to u, we conclude that v0 divides a −
(b/v0 )v1 .
Now we let (h1 , . . . , hm ) be the squarefree decomposition of v, as defined in
Section 14.6, with m ∈ N≥1 and monic squarefree and pairwise coprime polyno-
mials h1 , . . . , hm ∈ F[x] such that v = h1 h22 · · · hm
m and hm 6= 1. Then v0 = h1 · · · hm
and v1 = ∑1≤i≤m ih′i v0 /hi , by Exercise 14.26. Letting 1 ≤ i ≤ m and computing
modulo hi , we find
b b ′ v0 b ′ b ′ b ′
v1 ≡ · ihi = i hi ≡ i h+ hi = ib′ mod hi .
v0 v0 hi hi hi i hi
Now hi divides b, by the above, and both left hand summands in
b b
a − v1 + ′
v1 − ib = a − ib′ ,
v0 v0
so that hi divides gcd(b, a − ib′ ), for 1 ≤ i ≤ m. This leads to the following algo-
rithm for computing a multiple of v.
We note that the resultant in step 1 is the same as in algorithm 22.10. However,
here we do not need its complete factorization into irreducible polynomials, but
only its positive integral roots.
T HEOREM 22.15.
Algorithm 22.14 works correctly as specified. More precisely, if u, v are coprime
polynomials in F[x] solving (5), v 6= 0 is monic, and (h1 , . . . , hm ) is the squarefree
decomposition of v, then m ≤ d and hi divides Hi for 1 ≤ i ≤ m.
P ROOF. We may assume that deg v ≥ 1. We have deg hm > 0, by the definition of
the squarefree decomposition. By the discussion preceding the theorem, hi divides
gcd(b, a − ib′ ) for all i. In particular, this implies that gcd(b, a − mb′ ) is noncon-
stant, and hence R(m) = resx (b, a − mb′ ) = 0. Thus m ≤ d and hi | Hi for 1 ≤ i ≤ m.
m m+1
Finally, v = h1 h22 · · · hm 2 d
m divides H1 H2 · · · Hm Hm+1 · · · Hd = V . ✷
We note that it is sufficient to perform the loop in step 2 only for those i that
are roots of the resultant R. Moreover, it is somewhat more efficient to remove Hi
from b and a − ib′ in step 2; see Exercise 22.11.
H1 = gcd(b, a − b′ ) = gcd(x2 + x, x2 + 2x + 1) = x + 1,
H2 = gcd(b, a − 2b′ ) = gcd(x2 + x, x2 ) = x,
The following example shows that d may be exponentially large in the input
size.
636 22. Symbolic integration
g′ x + n
= ,
g x
L EMMA 22.18. Let r, s,t,U ∈ F[x] satisfy (8), with r,U nonzero and r monic, let
m = max{deg r − 1, deg s}, and let δ ∈ F be the coefficient of xm in s. (As usual,
δ = 0 if m < 0 or deg s < m.) Moreover, let
degt − m if deg r − 1 < deg s or δ 6∈ N \ {0, 1, . . . , degt − m},
e=
δ otherwise.
(i) Either degU = degt − m, or else degU = δ > degt − m and deg r − 1 ≥ deg s.
In particular, degU ≤ e.
We recall that the zero polynomial has degree −∞; thus degt − m is to be inter-
preted as −∞ if t = 0. We have N ⊆ Q ⊆ F, so that any integer is also an element
of F.
P ROOF. We compare the degrees and the top coefficients in (8). Firstly, we have
degt ≤ max{deg(rU ′ ), deg(sU)}
≤ max{deg r + degU − 1, deg s + degU} = m + degU.
Let γ ∈ F denote the coefficient of xm+1 in r. Then the coefficient of xm+degU
in rU ′ is γ lc(U) degU, and the coefficient of xm+degU in sU is δ lc(U). Thus the
coefficient of xm+degU in t is (γ degU − δ ) lc(U), and degt < m + degU if and only
if this coefficient vanishes.
If deg r − 1 < deg s, then γ = 0 and δ = lc(s) 6= 0, and hence degU = degt − m.
Otherwise, we have γ = lc(r) = 1. We conclude that degU ≥ degt − m, with strict
inequality if and only if deg r − 1 ≥ deg s and degU = δ . This proves (i), (ii), and
(iii).
To show (iv), we assume that U ∗ ∈ F[x] is another solution of (8). Then the
difference U −U ∗ satisfies the homogeneous equation r(U −U ∗ )′ −s(U −U ∗ ) = 0,
and the claim follows from (iii). ✷
Thus we can (almost) determine degU from the known polynomials r, s and
t = rV , namely degU = e = degt − m if deg r − 1 < deg s, and degU ≤ e =
max({degt − m, δ } ∩ Z) if deg r − 1 ≥ deg s. If the bound e is nonnegative and
if deg r − 1 < deg s or degt − m 6= δ , we set up the system of linear equations
equivalent to (8) and solve it for the unknown coefficients of U. If the system has
a solution, then τ = U/V satisfies (4), and gU/V is a hyperexponential integral
of g. Otherwise, or if e < 0, or if deg r − 1 ≥ deg s and degt − m = δ , then we know
that (4) has no rational solution τ ∈ F(x), and hence g has no hyperexponential
integral.
bV bV ′ − aV
2. h ←− gcd(bV, bV ′ − aV ), r ←− , s ←− , t ←− r ·V
h h
3. m ←− max{deg r − 1, deg s}
let δ be the coefficient of xm in s
if deg r − 1 < deg s or δ 6∈ N then e ←− degt − m
else if degt − m = δ then return “unsolvable”
else e ←− max{degt − m, δ }
if e < 0 then return “unsolvable”
4. solve the linear system corresponding to (8) for the unknown coefficients
U0 , . . . ,Ue ∈ F of U of degree at most e
if the system is unsolvable then return “unsolvable”
else U ←− Ue xe + · · · +U1 x +U0
U V
5. return and
gcd(U,V ) gcd(U,V )
The solution space of the system of linear equations in step 4 is either empty, or
has precisely one element, or turns out to be one-dimensional (Exercise 22.13). In
the latter case, we preferably take a solution leading to a numerator U of smallest
degree. The coefficient matrix is triangular, so that the system is particularly easy
to solve without Gaussian elimination, simply by back substitution, taking O(e2 )
operations in F. At most one diagonal element is zero, and this occurs only if
deg r − 1 ≥ deg s and δ ∈ N, by Lemma 22.18 (iii).
Exercise 22.12 shows that we may even obtain gcd(r,t) = 1 in step 2, by appro-
priately dividing out common factors, and perform steps 3 through 5 for a divisor
of U. This may further reduce the size of the system in step 4.
We now give some examples.
U ′ +U = xn . (9)
We have m = max{deg r − 1, deg s} = 0 > deg r − 1, so that we are in the first case
of Lemma 22.18, and the degree bound in step 3 is e = degt − m = n. In step 4, we
let U = Un xn + · · · +U1 x +U0 , with undetermined coefficients Un , . . . ,U0 . Plugging
this into (9), we obtain the system of linear equations
This system has a unique solution, and it satisfies U0 6= 0. Finally, the algorithm
returns u = U and v = V in step 5.
22.4. Hyperexponential integration: Almkvist & Zeilberger’s algorithm 639
Notes. Historically, the foundations of symbolic integration were laid by Joseph Liou-
ville (1833a, 1833b, 1835). Ritt (1948) invented the notion of a differential algebra, which
is the appropriate framework for the integration problem. A more general method was
presented by Risch (1969, 1970), and variants of his algorithm are implemented today in
almost any computer algebra system. They employ suitably modified versions of Hermite’s
and Rothstein’s and Trager’s methods.
Richardson (1968) and Caviness (1970) showed that a sufficiently general version of the
integration problem is unsolvable. Already when we just consider real functions built up
from the constant 1, a single variable, the four arithmetic operations, and the sine function,
then determining whether the definite integral (from −∞ to ∞) of such an expression exists
is undecidable, and similarly for the existence of indefinite integrals as we considered in
this chapter (Matiyasevich 1993, §9.4).
In spite of this fundamental limitation, symbolic integration and, more generally, the
symbolic solution of ordinary differential equations, is a highly active area of research.
Among its goals are algorithms for a wider range of problems, and better algorithms for
special types of problems. Bronstein (1997) gives a nice overview.
22.1. A project for OCR-reading integral tables is described in Berman & Fateman (1994).
22.2. Most undergraduate calculus textbooks contain an integration algorithm for rational
functions by factoring the denominator into linear polynomials over the complex numbers
(or at most quadratic polynomials over the real numbers) and performing a complete partial
fraction decomposition. For rational functions with only simple poles, this algorithm first
appears in Johann Bernoulli (1703). For symbolic computation, this approach is inefficient
since it involves polynomial factorization and computation with algebraic numbers, and
most computer algebra systems implement the algorithms described in this chapter.
In fact, on the pages just preceding Bernoulli’s article, Leibniz (1703) goes a step further.
He also computes the integral of a rational function by partial fraction decomposition if the
denominator is a product of distinct linear factors. But then he also gives the decomposition
in several cases where the denominator is not squarefree, for example,
1 1 1 1 1 1
= 4− 2 3+ 3 2− 4 + 4 ,
h4 l ωh ω h ω h ω h ω l
where h = x + a, l = x + b, and ω = b − a, similarly for 1/h4 l 3 , and a general formula
for 1/ht l s . For those terms, interveniunt etiam Hyperboloidum quadraturæ, quales sunt,
1 1 1
quarum ordinatæ sunt xx , x3 , x4 , &c,1 which are calculated by the usual rules. Here we
have the essential ingredients of Hermite’s method, 170 years before Hermite!
Ostrogradsky (1845) shows that for coprime f , g ∈ F[x] with deg f < deg g, there exist
unique polynomials a, c ∈ F[x] such that (1) holds, deg a < deg b, and deg c < deg d, where
b is the squarefree part of g and d = g/b, and presents an algorithm for computing a and c.
The algorithm described in Section 22.2 is from Hermite (1872). Theorem 22.7 appears in
Yun (1977a). Gerhard (2001a) gives fast modular algorithms for Hermite reduction.
22.3. Theorem 22.8 is from Rothstein (1976, 1977) and Trager (1976). Theorem 22.9 is
from Lazard & Rioboo (1990). Independently, Trager implemented the resulting algorithm
in S CRATCHPAD, but did not publish it. Mulders (1997) describes an error in software
implementations of the Lazard-Rioboo-Trager method.
1 furthermore enter the integrals of the hyperbolas, whose function values are x−2 , x−3 , x−4 , etc.
Exercises 641
Gerhard (2001a) presents a modular variant of Algorithm 22.10. If f , g ∈ Z[x] and their
coefficients are absolutely bounded by A ∈ N, then this algorithm takes O∼ (n5 + n4 log A)
word operations.
22.4. Algorithm 22.19 is from Almkvist & Zeilberger (1990). It is the analog of Gosper’s
(1978) algorithm for hypergeometric summation, which we discuss in Section 23.4. The
method of Almkvist & Zeilberger for determining a multiple of the denominator is de-
scribed in Exercise 22.11.
Equation (4) is a special case of the Risch differential equation : given elements σ, ρ in
a differential field K, determine τ ∈ K satisfying Dτ + στ = ρ. Equation (4) corresponds
to the case K = F(x), ρ = 1, and D = ′ . The more general equation plays a significant
role in Risch’s (1969, 1970) algorithm. Other algorithms for solving the Risch differ-
ential equation are given by Rothstein (1976, 1977), Kaltofen (1984), Davenport (1986),
and Bronstein (1990, 1991, 1997). Algorithms computing rational solutions of linear dif-
ferential equations of higher order are given by Abramov (1989a, 1989b), Abramov &
Kvashenko (1991), Bronstein (1992), Abramov, Bronstein & Petkovšek (1995), and Bron-
stein & Fredet (1999). The algorithms of Singer (1991), Petkovšek & Salvy (1993), and
Pflügel (1997), for example, find more general solutions of higher order equations.
The idea of finding polynomial solutions of linear differential equations by first de-
termining a degree bound and then solving a system of linear equations is known as
the method of undetermined coefficients and goes back to Newton (1691/92). Gerhard
(2001b), Chapter 9, presents several asymptotically fast methods for first order equations.
In practice, one would compute all integral roots of the resultant R in step 1 of Algo-
rithm 22.14, using Corollary 11.21 and Theorem 15.21, and then iterate the loop in step 2
only for those i that are roots of the resultant. Gerhard (2001b), Section 8.1 and Chapter 10,
gives a cost analysis of modular variants of Algorithms 22.14 and 22.19, respectively, in
terms of word operations.
Whether the output of Algorithm 22.14 is exponential in the input size depends on what
we regard as input. For example, if we consider hyperexponential functions of the form
g = r1 exp(r2 ) with r1 , r2 ∈ Q(x), then the result returned by Algorithm 22.14 is polynomial
in the degrees of the numerators and denominators of r1 and r2 (Theorem 10.16 in Gerhard
2001b). If we think of this algorithm as the first step of an integration algorithm, then it is
natural to regard g—and not the logarithmic derivative g′ /g—as input. If we represent g by
storing the rational functions r1 and r2 in a dense format as quotients of polynomials, then
the output of Algorithm 22.14 is polynomial in the input size. However, if we represent g
in a sparse format, e.g., by an “expression tree”, or if we consider the logarithmic derivative
g′ /g as input, then Example 22.17 shows that the output may be exponential in this input
size. On the other hand, Algorithm 22.14 may also be regarded as the first step of a method
for solving the linear differential equation (4), and then it is natural to consider σ = g′ /g
as the input. In fact, for a higher order linear differential equation with rational function
coefficients, the degrees of the rational solutions are in general exponential in the size of
the coefficients of the differential equation. Similar remarks also apply to the degree of the
numerator in Algorithm 22.19.
Exercises.
22.1 Let (R, D) be a differential algebra. Show that R0 is in fact a subring of R, and a subfield if R
is a field.
642 22. Symbolic integration
22.9 What is the leading coefficient of the resultant r in Theorem 22.8? Hint: Prove that it is the
constant coefficient of resx (ay − b′ , b).
22.10−→ Trace Algorithm 22.10 on computing the integral of
x9
f= ∈ Q(x).
x7 + 3 x6 − 5 x5 − 23 x4 − 8 x3 + 40 x2 + 48 x + 16
22.11 Let F be a field of characteristic zero and a, b ∈ F[x] nonzero and coprime.
(i) Let γ ∈ F and p ∈ F[x] be an irreducible factor of gcd(b, a − γb′ ). Prove that p2 ∤ b, and
conclude that the gcd is squarefree.
(ii) Show that gcd(b, a − γ1 b′ ) and gcd(b, a − γ2 b′ ) are coprime if γ1 , γ2 ∈ F are distinct.
(iii) Consider the following variant of Algorithm 22.14.
A LGORITHM 22.22 Almkvist & Zeilberger’s multiple of integration denominator.
Input: Relative prime polynomials a, b ∈ F[x] with b 6= 0 monic.
Output: A monic polynomial V ∈ F[x] such that for any coprime u, v ∈ F[x], equation (5) implies that
v divides V .
1. R ←− resx (b, a − yb′ ), d ←− max{i ∈ N: i = 0 or R(i) = 0}
if d = 0 then return 1
2. a0 ←− a, b0 ←− b
for i = 1, . . ., d do
ai−1 − b′i−1 bi−1
Hi ←− gcd(bi−1 , ai−1 − b′i−1 ), ai ←− , bi ←−
Hi Hi
3. return H1 H22 · · ·Hdd
Show that Hi = gcd(b, a − ib′ ) for all i and conclude that the algorithm returns the same result as
Algorithm 22.14.
(iv) Trace Algorithm 22.22 on the input from Example 22.16.
22.12 Let F be a field of characteristic zero and r, s,t,U ∈ F[x] with rU ′ − sU = t and gcd(r, s) = 1.
Suppose that deg gcd(r,t) ≥ 1, and reduce this differential equation for U to a differential equation
for a proper divisor U ∗ of U, with coefficients r, s∗ , and t ∗ = t/ gcd(r,t).
22.13 Let F be a field of characteristic zero and r, s,t ∈ F[x] such that r is nonzero and monic.
(i) Let S = {H ∈ F[x]: rH ′ − sH = 0} and H1 , H2 ∈ S \ {0}. Show that there is a nonzero constant
c ∈ F such that H1 = cH2 . Hint: Lemma 22.18.
(ii) Prove that either S = {0} or there is a unique monic polynomial H0 ∈ S, which has degree δ,
where δ is as in Lemma 22.18, such that S = {cH0 : c ∈ F}.
(iii) Suppose that the inhomogeneous equation (8) has a solution U ∈ F[x]. Prove that the set of
all solutions to this equation is {U + H: H ∈ S}.
Summa cum laude.1
The task that we address in this chapter is, given an “expression” g(n) depending
on n, to find an “expression” f (n) such that
f (n) = ∑ g(k),
0≤k<n
or, more generally, a closed form for the sum ∑a≤k<b g(k) for arbitrary nonnegative
integers a ≤ b. We will explain later what kind of expressions we consider; for the
time being, the reader may imagine univariate rational functions over a field of
characteristic zero.
We first solve the summation problem for polynomials, and introduce much of
the notation used later. After a digression about harmonic numbers, we discuss
hypergeometric terms and their summation. Section 24.3 gives a brief outlook on
further extensions, where computer algebra systems have had remarkable success
in giving short proofs of seemingly difficult problems. In contrast to the rest of
this book, we omit cost analyses.
n(n − 1)
∑ k= ,
0≤k<n 2
n(n − 1)(2n − 1)
∑ k2 = ,
0≤k<n 6
n2 (n − 1)2
∑ k3 = ,
0≤k<n 4
n(n − 1)(2n − 1)(3n2 − 3n − 1)
∑ k4 = ,
0≤k<n 30
645
646 23. Symbolic summation
cn − 1
∑ ck = if c 6= 1,
0≤k<n c−1
n
∑ = (1 + 1)n = 2n , (1)
0≤k≤n k
n
∑ (−1)k k = (1 − 1)n = 0 if n > 0. (2)
0≤k≤n
The last two summations are of a different type than the others, in that the up-
per bound n also occurs in the summand. In this chapter, we will only consider
summations where this is not the case; this is called indefinite summation.
A useful tool for symbolic summation is the difference operator ∆. It asso-
ciates to an expression f an expression ∆ f , defined by (∆ f )(n) = f (n+1)− f (n).
It has the following properties:
◦ Linearity: ∆(a f + bg) = a∆ f + b∆g for expressions f , g and constants a, b
in F,
◦ Product rule: ∆( f g) = f ∆g + g∆ f + ∆ f · ∆g for expressions f , g.
In particular, ∆ f is a rational function if f is. We will see below, however, that
the converse is false in general. Related operators are the shift operator E, with
(E f )(n) = f (n + 1), and its powers (E k f )(n) = f (n + k) for k ∈ Z. We have the
operator identity ∆ = E − I, where I = E 0 is the identity operator.
The following lemma gives the connection between the difference operator and
symbolic summation.
P ROOF.
∑ g(k) = ∑ f (k + 1) − f (k) = ∑ f (k + 1) − ∑ f (k)
a≤k<b a≤k<b a≤k<b a≤k<b
Both here and in (3) it is assumed that the integral and the sum, respectively, are
well-defined.
We have seen that the product rule is somewhat different from the Leibniz rule.
What about the analog of
D(xm ) = mxm−1 (4)
for m ∈ N ? For m = 3, for example, we have
so that (4) does not hold with ∆ instead of D. The following notions restore (4)
for the difference operator.
f m = f (x) f (x − 1) · · · f (x − m + 1) = f · E −1 f · E −2 f · · · E −m+1 f .
In particular, we have
xm = x(x − 1) · · · (x − m + 1),
which is a monic polynomial of degree m. Similarly, we also have the mth rising
factorial
f m = f (x) f (x + 1) · · · f (x + m − 1) = E m−1 f m .
For m = 0, we let f 0 = f 0 = 1.
648 23. Symbolic summation
P ROOF. Statements (i)–(v) and (vi) “⇐=” are clear. We first prove (vi) “=⇒”
when ρ = ∑0≤i≤n fi xi ∈ F[x] is a polynomial, with fn 6= 0 and n > 0. Then the
coefficient of xn−1 in E ρ = fn (x + 1)n + fn−1 (x + 1)n−1 + ∑0≤i≤n−2 fi (x + 1)i is
n fn + fn−1 , and in ρ it is fn−1 . Since F has characteristic zero, n fn 6= 0, and E ρ 6= ρ.
Now we let ρ = f /g, with coprime f , g ∈ F[x] and deg g > 1, and assume that
E ρ = ρ, or equivalently, g · E f = f · Eg. Then g | Eg, by the relative primality of
f and g. Since the degrees and the leading coefficients of g and Eg agree, we have
g = Eg, and hence g ∈ F, by what we have already shown. This is a contradiction
to deg g > 1 and concludes the proof. ✷
for all m ∈ N, and this is the discrete analog of (4). Thus Σ xm = xm+1 /(m + 1) and
nm+1
∑ km =
0≤k<n m+1
for all m, n ∈ N, by Lemma 23.1. We are somewhat abusing our notation here in
that we write km instead of xm (k) for k ∈ N.
23.1. Polynomial summation 649
E XAMPLE 23.4.
n2 n(n − 1)
∑ k= ∑ k1 = = ,
0≤k<n 0≤k<n 2 2
n3 n2 n(n − 1)(n − 2) n(n − 1)
∑ k2 = ∑ (k2 + k1 ) = + = +
0≤k<n 0≤k<n 3 2 3 2
n(n − 1)(2n − 1)
= ,
6
n4 n2 n2 (n − 1)2
∑ k3 = ∑ (k3 + 3k2 + k1 ) = + n3 + = .
0≤k<n 0≤k<n 4 2 4
These sums are in accordance with the first three examples at the beginning of the
chapter. ✸
for m > 1, where we have used that xi+1 = xi (x − i) in the second line. Comparing
coefficients of xi in the last line and in (5), we find that the { mi } satisfy the recursion
formula nmo m − 1 m − 1
= +i (6)
i i−1 i
for m ≥ i > 0, with the boundary conditions
nmo nmo
0
= 0 if i > m, = 0 for m ≥ 1, = 1.
i 0 0
In particular, { mi } is a nonnegative integer for 0 ≤ i ≤ m.
650 23. Symbolic summation
x1 = x1 ,
x2 = x2 + x1 ,
x3 = x3 + 3x2 + x1 ,
x4 = x4 + 6x3 + 7x2 + x1 ,
x5 = x5 + 10x4 + 25x3 + 15x2 + x1 .
The rational number Hn is called the nth harmonic number, since it is the nth
partial sum of the (divergent!) harmonic series ∑k≥1 1/k. The following lemma
implies that the harmonic numbers cannot be represented by a rational function.
P ROOF. We assume the contrary, namely that there exist coprime polynomials
f , g ∈ F[x] of degrees m and n, respectively, such that
1 f Ef f g · E f − f · Eg
=∆ = − =
x g Eg g g · Eg
m = n ⇐⇒ deg(g · Eg) = m + n
⇐⇒ deg (x(g · E f − f · Eg)) = m + n
⇐⇒ m 6= n.
Generalizations of this lemma are in Exercises 23.12 and 23.28. The harmonic
numbers are the discrete analog of the natural logarithm ln x, and in fact
1 1
Hn ∈ ln n + γ + + O 2 ,
2n n
n Hn ln n Hn − ln n n(Hn − ln n − γ)
10 2.9289682540 2.3025850930 0.6263831610 0.4916749607
100 5.1873775176 4.6051701860 0.5822073316 0.4991666750
1000 7.4854708606 6.9077552790 0.5777155816 0.4999166667
10 000 9.7876060360 9.2103403720 0.5772656640 0.4999916667
100 000 12.0901461299 11.5129254650 0.5772206649 0.4999991667
1 000 000 14.3927267229 13.8155105579 0.5772161650 0.4999999167
One can also prove that there is no rational function representing the sum
1
∑ k j
1≤k≤n
1 π2
ζ (2) = ∑ 2 6.=
k≥1 k
We have come across this number in Chapter 3, where we found its inverse to be
the probability that two random integers have a nontrivial gcd.
g = Df g = ∆f
R
f= g f = Σg
Z b
f (b) − f (a) = g(x)dx f (b) − f (a) = ∑ g(k)
a a≤k<b
Intuitively, the first factorization in the above example is “maximal” in the sense
that we have extracted the “greatest” possible falling factorial. An informal algo-
rithm for its computation would be to look for the largest m ∈ N such that gm | f
for some nonconstant g ∈ F[x], divide gm out, and proceed recursively.
The definition formalizes the maximality condition indicated above: (F3 ) states
j
that the falling factorial f j = f j · E −1 f j · · · E − j+1 f j cannot be extended to the left
(if g = gcd( fii , E f j ) 6= 1, then g j+1 is a falling factorial of length j + 1 dividing f ),
and (F4 ) means that it cannot be extended to the right.
In the example, only the first sequence (x, 1, 1, x + 2) is a greatest factorial fac-
torization. For (1, x, x + 2), condition (F4 ) is violated since gcd(x2 , E −3 (x + 2)) =
x − 1, so that (x + 2)3 may be extended to the right by (x − 1) to get (x + 2)4 .
The factorization (x2 + 2x, 1, x + 1) fails to satisfy (F3 ) for i = 1 and j = 3, since
(x + 1)3 may be extended to the left by the factor x + 2 of x2 + 2x, and ( f ) violates
both (F3 ) and (F4 ) for i = j = 1.
are all integral shifts of x. Figure 23.3 illustrates the shift structure of f . A bullet at
point (i, j) ∈ N 2 indicates that E −i x j = (x − i) j divides f . A gff of f can be read off
this figure by collecting maximal horizontal chains and packing together chains of
equal length (shaded equally in Figure 23.3). Thus (x2 − 5x + 4, x2 − 5x + 4, x) =
((x − 1)(x − 4), (x − 1)(x − 4), x) is a gff of f . ✸
23.3. Greatest factorial factorization 655
1
0 1 2 3 4 5 i
F IGURE 23.3: The shift structure of x(x − 1)3 (x − 2)2 (x − 4)2 (x − 5).
0 1 2 3 4 5 i
1
Examples 23.8 and 23.9 illustrate two extreme cases. The general situation is
three-dimensional: If we partition the monic irreducible factors of a polynomial
f ∈ F[x] into shift-equivalence classes Π1 , . . . , Πl and determine the unique rep-
resentative pk ∈ Πk for each k so that all other elements of Πk are of the form E −i pk
656 23. Symbolic summation
for some i ∈ N, then the full information about the shift structure of f can be read
off the set of ordered triples S = {(i, j, k) ∈ N 3 : E −i pkj | f }. In Example 23.8, we
have only one shift-equivalence class Π1 = {x, x − 1, x − 2, x − 4, x − 5} and p1 = x.
In Example 23.9, we have the three classes Π1 = {x, x − 1, x − 2, x − 3, x − 5},
Π2 = {x − 1/3, x − 7/3, x − 10/3}, and Π3 = {x − 2/3, x − 5/3}, and all multiplic-
ities are 1. It is easy to find a gff of f knowing S: As in the examples, we look for
maximal chains “in the i-direction” and combine all chains of equal length.
The examples suggest that the gff is unique, and the following lemma confirms
this.
L EMMA 23.10. A nonzero monic polynomial f ∈ F[x] has at most one gff.
P ROOF. If f = 1, then the empty sequence is the only gff of f , by (F1 ), and we
now assume that deg f > 0. We suppose that ( f1 , . . . , fm ) and (g1 , . . . , gn ) are both
greatest factorial factorizations of f , and show by induction on deg f that they are
equal. Let p ∈ F[x] be an irreducible factor of fm . We will show that p | gm . To
this end, we let k ∈ {1, . . . , n} be maximal such that gcd(pm , gkk ) 6= 1. Then there
exists some i ∈ {−m + 1, . . . , k − 1} with p | E −i gk .
If i > 0, then E p | E −i+1 gk | f , which is impossible by (F3 ) for ( f1 , . . . , fm ), and
j
we conclude that i ≤ 0. If i < 0, then E i+1 p divides f , and hence E i+1 p | g j for some
j
j ∈ {1, . . . , k}, by the maximality of k. Thus E i+1 p | gcd(g j , Egk ), contradicting
(F3 ) for (g1 , . . . , gn ), which implies that i = 0 and p | gk . In (10) and (11), the
situations i > 0 and i < 0, respectively, are illustrated; arrows indicate divisibility.
p E −1 p E −2 p · · ·
↓ ↓ ↓ (10)
gk E −1 gk · · · E −i+1 gk E −i gk E −i−1 gk E −i−2 gk · · ·
The following lemma not only proves that a gff always exists, but also leads
to an algorithm for its computation similar to the algorithm for computing the
squarefree decomposition (Section 14.6).
P ROOF. Uniqueness was proven in Lemma 23.10. For the existence, we proceed
by induction on deg f . If f = 1, then by definition gff( f ) = (), and we may assume
that deg f > 0. Then g = gcdE( f ) has strictly smaller degree than f , since f = E f
if and only if f is constant, by Lemma 23.3. If g = 1, then gff( f ) = ( f ) (it is easily
checked that (F1 ) through (F4 ) hold).
If g is nonconstant, then by induction there are m ∈ N≥2 and nonconstant monic
g1 , . . . , gm−1 ∈ F[x] such that
Thus
g E −1 g lcm(g, E −1 g)
(E −1 g1 ) · · · (E −m+1 gm−1 ) = E −1 = = .
gcdE(g) gcd(g, E −1 g) g
lcm(g, E −1 g) f
(E −1 g1 ) · · · (E −m+1 gm−1 ) = | . (14)
g g
If we let fi+1 = gi for 1 ≤ i < m, then (14) proves that f1 in (13) is indeed a
polynomial, and (F1 ) and (F2 ) are satisfied for ( f1 , . . . , fm ).
To show (F3 ) for ( f1 , . . . , fm ), let 1 ≤ i ≤ j ≤ m. If i ≥ 2, then property (F3 ) for
i−1 i−1
(g1 , . . . , gm−1 ) implies that gcd( fi , E f j ) = gcd(gi−1 , Eg j−1 ) = 1. Now E −i+1 fi =
E −i+1 gi−1 divides f /g, by (14), and E f j divides E( f1 · · · fm ) = (E f )/g, and since
658 23. Symbolic summation
f /g and (E f )/g are coprime, so are E −i+1 fi and E f j . Thus (F3 ) holds if i ≥ 2. For
i = 1, we have that f1 | f /g and E f j | (E f )/g, and again gcd( f /g, (E f )/g) = 1
implies that gcd( f1 , E f j ) = 1. This concludes the proof of (F3 ).
The proof of (F4 ) is similar, see Exercise 23.16. ✷
4. return ( f1 , . . . , fm )
T HEOREM 23.14.
Algorithm 23.13 works correctly as specified and uses O(n · M(n) log n) operations
in F , where n = deg f .
P ROOF. Correctness follows from the fundamental lemma. The recursion depth
of the algorithm is at most n. The cost for one iteration of the algorithm is
O(M(n) log n), and the claim follows. ✷
Our most important example of a difference field is the field F(x) of rational
functions, with E being the shift operator E f = f (x + 1), as before, and Lemma
23.3 implies that CF(x) = F. Another example is the difference field Q(2x ) with
E(2x ) = 2x+1 = 2 · 2x .
∆ f = E f − f = E τ · Eg − τ g = (E τ · σ − τ )g,
E τ · σ − τ = 1 in F(x). (15)
We note that only rational functions occur in (15); we have eliminated all hy-
pergeometric terms and reduced the original hypergeometric summation problem
to a purely rational question.
If we write σ = a/b with coprime polynomials a, b ∈ F[x], b 6= 0 monic, and
similarly τ = u/v with coprime u, v ∈ F[x], v 6= 0 monic, and multiply up denomi-
nators in (15), we arrive at the equivalent polynomial condition
a · v · Eu − b · u · Ev = b · v · Ev. (16)
Conversely, we see that any polynomial solution u, v ∈ F[x] of the above equa-
tion for the given a, b ∈ F[x] yields a solution to our hypergeometric summation
23.4. Hypergeometric summation: Gosper’s algorithm 661
problem by setting
u
f = g. (17)
v
In order to solve (16), we try to find a suitable denominator polynomial v or a
multiple of it. We define v0 , v1 ∈ F[x] by v = v0 · gcdE(v) and Ev = v1 · gcdE(v),
so that v0 , v1 are coprime. Dividing (16) by gcdE(v) yields
a · v0 · Eu − b · u · v1 = b · v0 · v1 · gcdE(v). (18)
Since v0 divides a · v0 · Eu and the right hand side of (18), it divides b · u · v1 . But
gcd(u, v0 ) divides gcd(u, v) = 1 = gcd(v1 , v0 ), and hence v0 | b. Similarly, v1 | a.
Let gff(v) = (h1 , . . . , hm ) be the greatest factorial factorization of v. Then
h11 h22 · · · hm
m
v0 = m−1
= h1 · (E −1 h2 ) · · · (E −m+1 hm ) | b,
h21 · · · hm
(19)
(Eh1 )1 (Eh2 )2 · · · (Ehm )m
v1 = m−1
= (Eh1 )(Eh2 ) · · · (Ehm ) | a,
h21 · · · hm
T HEOREM 23.19.
Algorithm 23.18 works correctly as specified. In particular, if u, v are coprime
polynomials in F[x], with v 6= 0 monic, solving (16), and gff(v) = (h1 , . . . , hm ),
then m ≤ d and hi | Hi for 1 ≤ i ≤ m.
662 23. Symbolic summation
2. a0 ←− a, b0 ←− b
for i = 1, . . . , d do
ai−1 bi−1
Hi ←− gcd(E −1 ai−1 , E i−1 bi−1 ), ai ←− , bi ←−
EHi E −i+1 Hi
H1 = gcd(E −1 a, b) = gcd(x + 1, x2 + x) = x + 1,
H2 = gcd(E −1 a, Eb) = gcd(x + 1, x2 + 3x + 2) = x + 1,
Let a, b ∈ F[x] be nonzero monic polynomials that split over some extension
field K of F into linear factors a = ∏1≤i≤m (x − αi ) and b = ∏1≤ j≤n (x − β j ), and
R = resx (a(x), b(x + y)) ∈ F[y], as in step 1 of Algorithms 23.18 and 23.20. For
any γ ∈ K, we have
R(γ ) = 0 ⇐⇒ resx (a(x), b(x + γ )) = 0 in K
⇐⇒ gcd(a(x), b(x + γ )) 6= 1 in K[x]
⇐⇒ a(x) and b(x + γ ) = ∏ (x − β j + γ ) have a common zero
1≤ j≤n
⇐⇒ γ = β j − αi for some i ∈ {1, . . . , m} and j ∈ {1, . . . , n}.
Thus the roots of R are exactly the distances between the roots of a and b. We
have already used this in Section 6.8 to find the minimal polynomial of the sum
of two algebraic numbers. In particular, if the value d computed in step 1 of
Algorithms 23.18 and 23.20 is nonzero, then it is the maximal positive integer
distance between a root of a and a root of b. Thus for computing d, we may
replace a and b by their squarefree parts.
H1 = gcd(E −1 a, b) = gcd(x2 , x) = x
(Algorithm 23.20 computes the same value for H1 ), and the denominator v of a
solution u/v of (16) divides V = H11 = x—provided that such a solution exists. ✸
Exercise 23.27 gives an upper bound on d, and the following example shows
that this bound is almost sharp, and that the value of d may be exponentially large
in the input length.
E XAMPLE 23.23. We let g = (x2 + nx)−1 ∈ Q(x), with a parameter n ∈ N≥1 . Its
term ratio is
Eg x(x + n)
= ,
g (x + 1)(x + n + 1)
so that the input to Algorithm 23.18 is a = x(x + n) and b = (x + 1)(x + n + 1).
Then d = n − 1 in step 1, Hi = gcd(a(x − 1), b(x + i − 1)) = 1 for 1 ≤ i < n − 1,
and Hn−1 = gcd(a(x − 1), b(x + n − 2)) = (x + n − 1), so that V = (x + n − 1)n−1 =
(x + 1)n−1 . (Algorithm 23.20 computes the same result.) Its degree is exponential
in the size of a and b, which is about log264 n words. ✸
L EMMA 23.24. Let r, s,t,U ∈ F[x] satisfy (21), with r,U nonzero and r monic,
let m = max{deg r − 1, deg(s − r)}, and let δ ∈ F be the coefficient of xm in s − r.
(As usual, δ = 0 if m < 0 or deg(s − r) < m.) Moreover, let
degt − m if deg r − 1 < deg(s − r) or δ 6∈ N \ {0, 1, . . . , degt − m},
e=
δ otherwise.
(i) Either degU = degt − m, or else degU = δ > degt − m and deg r − 1 ≥
deg(s − r). In particular, degU ≤ e.
(iv) If deg r − 1 < deg(s − r) or δ 6∈ N, then exactly one U ∈ F[x] satisfies equa-
tion (21).
The proof is analogous to the proof of Lemma 22.18 and left as Exercise 23.31.
We recall that the zero polynomial has degree −∞; thus degt − m is to be inter-
preted as −∞ if t = 0. We have N ⊆ Q ⊆ F, so that any integer is also an element
of F.
In any case, we can (almost) determine degU from the known polynomials r, s,
and t = s · V . If the value e from Lemma 23.24 is a nonnegative integer and if
deg r − 1 < deg(s − r) or degt − m 6= δ , we set up the system of linear equa-
tions equivalent to (21) and solve it for the unknown coefficients of U. Then
τ = U/V ∈ F(x) satisfies (15), and we get a solution to our hypergeometric sum-
mation problem as in (17). If, however, e is negative, or if deg r − 1 ≥ deg(s − r)
and degt − m = δ , or if the linear system is unsolvable, then we know that (15) has
no rational solution τ ∈ F(x), and no hypergeometric term f with ∆ f = g exists.
Here is the complete algorithm.
The solution space of the linear system in step 4 is either empty, or has precisely
one element, or is one-dimensional. In the latter case, we preferably take a solu-
tion leading to a numerator U of smallest degree. The coefficient matrix of the
linear system is triangular, so that the system is particularly easy to solve without
Gaussian elimination, simply by back substitution, taking O(e2 ) operations in F.
At most one diagonal element is zero, and this occurs only if deg r −1 ≥ deg(s−r).
Exercise 23.26 shows that we may even obtain gcd(r,t) = gcd(s,t) = 1 in step 2,
by appropriately dividing out common factors, and perform steps 3 through 5 for
a divisor of U. This may further reduce the size of the linear system in step 4.
We conclude this section with a series of examples.
U x2 + 25 x + 1 x + 21
f= g=− 2 =−
V (x + 2x)(x + 1) x(x + 1)
satisfies ∆ f = g. Exercise 23.13 shows that for an arbitrary positive integer n,
U = − 1n (x + n)(xn )′ solves (22), where ′ denotes the formal derivative, and that
∆(−(xn )′ /nxn ) = 1/(x2 + nx). ✸
E XAMPLE 23.26. Let g = 1/x ∈ F(x). Then σ = Eg/g = x/(x + 1), and a = x,
b = x + 1. We compute R = resx (x, x + y + 1) = y + 1 in step 1 of Algorithms 23.20
and 23.18, and hence d = 0 and V = 1. Plugging this into (21), we obtain
x · EU − (x + 1)U = (x + 1).
The following example shows that if deg r − 1 ≥ deg(s − r) in Lemma 23.24 (i),
both choices for degU may lead to a solution of the hypergeometric summation
problem.
We know, of course, that the sum is 0 for m > n, by the binomial theorem, but
sometimes such sums also occur with the upper summation bound being smaller
than n. The term ratio of the summand g = (−1)x ( nx ) is
x+1 n
(−1)
Eg x+1 x−n
σ= = n = ,
g (−1)x x+1
x
668 23. Symbolic summation
and hence a = x − n and b = x + 1. (The reader being concerned about what (−1)x
might mean for x 6∈ Z may replace it by eiπx .) The first step of Algorithms 23.18
and 23.20 computes
R = resx (x − n, x + y + 1) = y + n + 1,
so that d = 0 and V = 1. Equation (21) then is
(x − n)EU − (x + 1)U = x + 1, (24)
and we have r = x − n, s = t = x + 1, deg r − 1 = 0 = deg(s − r), and δ = n + 1.
Lemma 23.24 (i) implies that either degU = degt − m = 1 or degU = δ = n + 1.
The lemma does not tell us which choice to make, so we try degU = 1 first, since
it looks easier. With U = U1 x +U0 , (24) is
x + 1 = (x − n)(U1 (x + 1) +U0 ) − (x + 1)(U1 x +U0 )
= (−n)U1 x + (−nU1 − (n + 1)U0 ),
and the linear system
1 = −nU1 , 1 = −nU1 − (n + 1)U0
has the unique solution U1 = −1/n and U0 = 0. Thus τ = U/V = −x/n,
x n x n x x n x−1 n − 1
Σ (−1) = τ · (−1) = − (−1) = (−1) ,
x x n x x−1
and consequently
n n
∑ (−1)k = 1+ ∑ (−1)k
0≤k<m k 1≤k<m k
m−1n−1 0 n−1
= 1 + (−1) − (−1)
m−1 0
n−1
= (−1)m−1
m−1
for all m ∈ N. In particular, the sum is 0 if we plug in m > n, as it should be.
Now let us try degU = δ = n + 1. If a solution U ∗ ∈ F[x] of (24) of degree n + 1
exists, then the difference U = U ∗ −U solves the homogeneous equation
(x − n)EU − (x + 1)U = 0,
and vice versa. Inspection shows that U = xn+1 is a solution of the homogeneous
equation, and hence U ∗ = U +U = xn+1 − x/n is a solution of (24) of degree n + 1.
Now U = Γ (x + 1)/Γ (x − n), and hence
(x + 1)Γ (x + 1)
E(Ug) = EU · Eg = · σ g = Ug,
(x − n)Γ (x − n)
Notes 669
Notes. An excellent reference for much of this chapter is Graham, Knuth & Patashnik
(1994); the book tower example is from this text. It also contains useful information about
binomial coefficients, Bernoulli, Euler, and Stirling numbers, including lots of pretty sums
involving them.
The theory of differencing, summing, and solving difference (or recurrence) equations
in a symbolic fashion is treated in classics like Boole (1860) and Jordan (1965, first edition
1939). The solution of differential equations by discretization has been a driving force for
studying “difference calculus” and solving difference equations numerically.
23.1. Archimedes gives in his book On spiral lines, Proposition 10, essentially the formula
for ∑0≤k<n k2 . Fermat says in a letter to Mersenne, to be forwarded to de Sainte-Croix,
from September or October 1636, that he has found a way of computing ∑0≤k<n km for
any m. He gives his solution for m = 4 (actually describing it for n = 5):
!
1 2
∑ k4 = 5 4(n − 1) + 2 · ∑ k − ∑ k2 .
0≤k<n 0≤k<n 0≤k<n
Von zur Gathen & Gerhard (1997) analyze several algorithms to compute E f = f (x + 1)
for a polynomial f ∈ Z[x].
There is a common framework which covers the similarity between the two equalities
Dxn = nxn−1 and ∆xn = nxn−1 for n ∈ N, the umbral calculus. It studies linear operators
on the vector space F[x] of polynomials over a field F. If T is such a linear operator with
the additional properties that T commutes with the differential operator D and deg(T f ) =
deg f −1 for all nonzero f ∈ F[x], then there is a unique sequence f0 = 1, f1 , f2 , . . . ∈ F[x] of
polynomials such that deg fn = n, T fn = n fn−1 , and fn (0) = 0 for all n ≥ 1, the sequence
associated to T . Thus fn = xn is associated to D and fn = xn is associated to ∆. All
associated sequences satisfy a binomial theorem
n
fn (x + y) = ∑ fk (x) fn−k (y)
0≤k≤n k
(this is clear for fn = xn , and Exercise 23.9 proves it for the falling factorials); in fact, this
property is equivalent to being an associated sequence. The origins of the umbral calculus
date back to the middle of the 19th century, and Gian-Carlo Rota put it on a rigorous formal
basis in the 1970s. An excellent reference is Roman (1984).
670 23. Symbolic summation
R
The gamma function is defined by Γ (x) = 0∞ e−t t x−1 dt for all x ∈ R≥0 . It satisfies
the functional equation Γ (x + 1) = xΓ (x) for all x ≥ 1, and since Γ (1) = 1, we have in
particular Γ (n + 1) = n! for all n ∈ N (Exercise 23.5). By analytic continuation, the gamma
function can be extended to a meromorphic function on the complex plane with simple
poles at the nonpositive integers 0, −1, −2, −3, . . .. This leads to a more general definition
of (falling and rising) factorials and binomial coefficients, via xn = Γ (x + n)/Γ (x) for
arbitrary complex numbers x and n with x + n 6∈ −N.
The rising factorial is also called the Pochhammer symbol and written as (x)m .
The formula for summing a polynomial goes back to Stirling (1730), where also the
Stirling numbers (of both kinds) are defined. Vandermonde introduced xn in 1772. Knuth
(1993) explains Johann Faulhaber’s (1631) methods for summation of powers, yielding
much more beautiful expressions than the ones we give. A true renaissance man.
23.3. The definition of the gff, as well as Theorem 23.12 and Algorithm 23.13, are from
Paule (1995). We have adopted the graphical representation of the shift structure from
Pirastu (1992).
23.4. Hypergeometric terms inherit their name from hypergeometric series, which are
power series over C with hypergeometric coefficients in the sense of Definition 23.16:
a series f = ∑k≥0 fk xk /k! ∈ C[[z]] is hypergeometric if
ak1 · · · akm
fk =
bk1 · · · bkn
for all k ∈ N, where the upper parameters a1 , . . . , am ∈ C may be arbitrary and the lower
parameters b1 , . . . , bn ∈ C must not lie in −N. Hypergeometric series have a distinguished
history in calculus, and many familiar series such as
zk 1 zk 1 1k 1k zk
exp(z) = ∑ k! , a
= ∑ ak , ln =z∑
k≥0 (1 − z) k≥0 k! 1−z k≥0 2 k!
k
are in fact hypergeometric, including the second example for a = 1: the geometric se-
ries. Hypergeometric series with two upper parameters and one lower parameter were first
studied by Euler, Gauß, and Pfaff.
Algorithm 23.20, Lemma 23.24, and Algorithm 23.25 are due to Gosper (1978); see
also Graham, Knuth & Patashnik (1994), §5.7, and Koepf (1998). Our presentation follows
Paule (1995).
In view of the fact that the values of d and δ may be exponentially large in the input
size, as in Examples 23.23 and Exercise 23.24, it would be interesting to know what asym-
ptotically fast methods can achieve in this area; a first step was taken by von zur Gathen
& Gerhard (1997). Gerhard (2001b), Chapters 8 and 10, gives a cost analysis of modular
variants of Algorithms 23.20 and 23.25, respectively, in terms of word operations.
If Gosper’s algorithm is applied to a rational function g = p/q, with nonzero p, q ∈ F[x],
then deg r − 1 ≥ deg(s − r) in Lemma 23.24. Lisoněk, Paule & Strehl (1993) prove that
in this situation the case degU = δ occurs if and only if g is a proper rational function, so
that deg p < deg q. Moreover, they show that if Σg exists, then (21) has a unique solution
U ∈ F[x] of degree degt − m, so that the case degU = δ in Lemma 23.24 (i) need not be
considered.
Exercises 671
Further notes. The early work of Abramov (1971, 1975), Moenck (1977b), Gosper
(1978), and Karr (1981, 1985) was influential for symbolic summation. Lafon (1983)
gives an overview of the state in the early 1980s. More recent works on rational and hyper-
geometric summation and extensions of Gosper’s algorithm are due to Lisoněk, Paule &
Strehl (1993), Man (1993), Petkovšek (1994), Pirastu & Strehl (1995), Koepf (1995), Paule
(1995), Paule & Strehl (1995), Pirastu (1996), Bauer & Petkovšek (1999), and Gerhard,
Giesbrecht, Storjohann & Zima (2003).
An exciting development was started by Zeilberger’s (1990a, 1990b, 1991) solution of
the definite hypergeometric summation problem (the two sums (1) and (2) are of that type).
It provided rather surprising computer-aided verifications of well-known identities, such as
the Rogers-Ramanujan formula, the Pfaff-Saalschütz identity, Dixon’s theorem, Apéry’s
formula, and similar proofs of new identities. We will briefly discuss this in Section 24.3;
see also Notes 24.3. Almkvist & Zeilberger (1990) discuss an analogous algorithm for
definite hyperexponential integration. Generalizations of these algorithms are due to Wilf
& Zeilberger (1992), Chyzak (1998a, 1998b, 2000), Chyzak & Salvy (1998), and Abramov
& van Hoeij (1999).
Equation (15) is a special case of a first order linear difference equation with rational
coefficients. Algorithms for solving higher order linear difference equations are given, for
example, by Abramov (1989a, 1989b, 1995), Petkovšek (1992), van Hoeij (1998, 1999),
Hendriks & Singer (1999), and Bronstein (2000).
Exercises.
23.1 Give an example of functions f , g: R −→ R such that f (k + 1) − f (k) = g(k) for all k ∈ Z but
∆ f 6= g.
23.2 Let ∇ be the “backward” difference operator, with ∇ f = f − E −1 f = ∆E −1 f . Prove the
following identities for all m ∈ N.
(i) xm = (x + m − 1)m = (−1)m (−x)m ,
(ii) ∆xm = m · Exm−1 ,
(iii) ∇xm = mxm−1 .
23.3 (i) Show that ∆ f · g − f · ∆g = E f · g − f · Eg.
(ii) The product rule for the difference operator ∆ can be written as
∆( f · g) = f · ∆g + Eg · ∆ f = E f · ∆g + g · ∆ f .
Find and prove a quotientrule for ∆ expressing
∆( f /g) in terms of f , ∆ f , g, ∆g, and Eg.
(iii) Prove that ∆ f m = E f − E 1−m f · f m−1 for all m ∈ N.
23.4∗ Let F be a field of characteristic zero. For an arbitrary h ∈ F, we define the h-shift operator
E h by E h f = f (x + h) (if h ∈ Z, then this coincides with the usual definition as hth power of E), and
similarly ∆h = E h − I.
(i) Show that ∑0≤k<n g(a + kh) = f (a + nh) − f (a) for all n ∈ N and a ∈ F if ∆h f = g.
k
(ii) Prove the operator identities ∆kh = ∑0≤i≤k (−1)k−i i E ih and ∆k = ∆ ∑0≤i<k E i for k ∈ N.
(iii) Let f ∈ F[x] have degree less than n, and let h ∈ F. Prove that f has the Newton expansion
(∆ih f )(0)
f= ∑ x(x − h) · · · (x − ih + h),
0≤i<n hi i!
and relate this to the Taylor expansion of f around 0, and also to Newton interpolation (Exercise 5.11)
at the equidistant pointsu j = jh for 0 ≤ i < n.
(iv) Conclude that i! mi = (∆i xm )(0) for 0 ≤ i ≤ m.
672 23. Symbolic summation
R
23.5 (i) Show that Γ (x) = 0∞ e−t t x−1 dt exists for all x ∈ R>0 .
(ii) Prove the functional equation Γ (x + 1) = xΓ (x) for all x ∈ R>0 . Hint: Integration by parts.
(iii) Show that Γ (1) = 1, and conclude that Γ (n + 1) = n! for all n ∈ N.
m
23.6 Show that m−1 = m2 and m2 = 2m−1 − 1 for m ≥ 1.
23.7∗ Let nk denote the number of permutations on {1, . . ., n} with exactly k cycles, for all non-
negative integers.
h i Theseh i numbers are the Stirling
h i numbers of the first kind. We have the boundary
conditions 00 = 1, n0 = 0 if n > 0, and nk = 0 if k > n.
(i) Give all permutations on {1, . . ., n} having k cycles, for 1 ≤ k ≤ n ≤ 4.
n
(ii) Prove that nn = 1, n−1 = n2 , and n1 = (n − 1)! for all n ∈ N>0 .
(iii) Find and prove a recursion formula for nk for 1 ≤ k ≤ n. Hint: Distinguish the two cases
whether n is a fixed point (a cycle of length 1) or not.
(iv) Prove that xm = ∑0≤i≤m (−1)m−i mi xi for m ∈ N. What is the corresponding formula for xm ?
(v) Conclude that
hmin n o nmoh n i
∑ (−1)m−i i m = δn−i = ∑ (−1)n−m i m
i≤m≤n i≤m≤n
(iii) Prove that ∆Sm = xm for all m ∈ N. (Hint: Use (ii).) Show that this implies ∑0≤k<n km = Sm (n)
for all n ∈ N.
(iv) Conclude from Exercise 23.7 and (7) that
! ( )" #
Bm+1−k m + 1 (−1)i+1−k m i+1
m+1 k
= ∑ i+1 i k
k−1≤i≤m+1
for integers r, s, m with 1 ≤ m ≤ r + s by counting in two different ways the number of possibilities
to choose m persons among r women and s men.
Exercises 673
(ii) Give a different proof of (25) by comparing coefficients of zm on both sides of the (formal)
power series equality
1 1 1
· =
(1 − z)r (1 − z)s (1 − z)r+s
in Q[[z]].
(iii) Show that for each m ∈ N≥1 , (25) becomes an equality in the polynomial ring Z[x, y] if we
formally replace r, s by indeterminates x, y. Hint: Lemma 6.44.
(iv) Conclude that the falling factorials satisfy the binomial theorem
m
∑ i xi ym−i = (x + y)m .
0≤i≤m
(i) Prove that there exist hi j ∈ F[x] of degree less than j deg gi for 1 ≤ j ≤ i ≤ m such that we have
the “partial fraction decomposition”
f hi j
= ∑ j
.
g 1≤ j≤i≤m g i
(ii) Show that there are polynomials s,t ∈ F[x] of degree less than deg gi such that sE − j+1 gi + t ·
(gi − E − j+1 gi ) = hi j . Using the product rule, conclude that
hi j t s − Et
j
= ∆ j−1
+ j−1 .
gi gi gi
(iii) Let b = g1 · · ·gm and d = E −1 (g/b). Conclude that there exist polynomials a, c ∈ F[x] with
deg a < deg b and deg c < deg d such that
f c a
=∆ + .
g d b
23.18 Which of the following expressions are hypergeometric, which are not? Compute the term
ratios.
(x + 1)2 2 2
(i) , (ii) (x + 1)2x , (iii) (−1)x Γ (x + 1).
3
23.19 Prove that the set of hypergeometric terms is closed under multiplication and division but not
under addition.
23.20 Trace Algorithm 23.25 on computing Σx2 , and compare its result to the one that you obtain
from Section 23.1.
23.21 Let n ∈ N≥1 . Prove that there is no hypergeometric expression f such that ∆ f = nx .
23.22 Decide whether the following hypergeometric expressions have hypergeometric sums, and if
so, compute
them.
3x + 1 2x 100
(i) , (ii) (2x + 1)2x Γ (x + 1), (iii) 2x .
x+1 x x
2 2
23.23 Fix n ∈ N≥1 . Which of the two indefinite sums Σ(−1)x nx and Σ nx are hypergeomet-
ric?
23.24−→ (Gerhard 1998) Let n ∈ N≥2 and
24x
g= 2 .
n+x 2n + 2x 2
x n+x
(i) Show that the term ratio of g is
Eg (x + 1)2 x2 + 2x + 1
σ= = 2 = . (27)
g 2n + 1 2 (2n + 1)2
x+ x + (2n + 1)x +
2 4
(ii) The numerator and denominator in (i) are a = x2 +2x +1 and b = x2 +(2n +1)x +(2n +1)2 /4.
Show that both Algorithms 23.20 and 23.18 return the denominator V = 1.
(iii) Equation (21) now reads a · EU − b · u = b. Prove that the solution U ∈ Q[x] has degree
δ = 2n − 1 if it exists.
(iv) Show that the linear operator L = aE − b: Q[x] −→ Q[x], with L f = a · E f − b · f , maps the 2n-
dimensional vector space W ⊆ Q[x] of all polynomials of degree less than 2n to itself, and conclude
that there is a unique polynomial U ∈ Q[x] with LU = a · EU − b ·U = b.
(v) Compute U for n = 6.
Exercises 675
x4 + 4x3 + 3x2
∈ Q(x).
x6 + 7x4 + 5x5 + x3 − 2x2 − 4x − 8
The example in (iv) is from Abramov & Petkovšek (2001), who also show that the extended Gosper-
Petkovšek form is unique in the case (v).
23.30 Let F be a field of characteristic zero, f ∈ F[x] nonconstant, and k ∈ N. Prove that
23.31 Prove Lemma 23.24. Hint: Rewrite (21) in terms of the difference operator ∆.
It is no paradox to say that in our most theoretical moods
we may be nearest to our most practical applications.
Alfred North Whitehead (1911)
L’algèbre est généreuse, elle donne souvent plus qu’on lui demande.1
Jean le Rond D’Alembert ()
677
678 24. Applications
true ←→ 0, false ←→ 1
¬ϕ ←→ 1 − ϕ
e; eψe;
ϕ ∨ ψ ←→ ϕ e)(1 − ψe).
ϕ ∧ ψ ←→ 1 − (1 − ϕ
1 Dirichlet’s drawer principle. The English “pigeonhole” is actually an office mail box.
24.2. Petri nets 679
The Nullstellensatz proof system asks to derive 1, that is, to prove that 1 ∈ I,
according to these rules, in order to refute S. Corresponding to (2), we have
and a refutation of S is
xe2 = (1 − xe1 )e
x2 + xe2 · xe1 , xe3 = (1 − xe2 )e
x3 + xe3 · xe2 ,
xe4 = (1 − xe3 )e
x4 + xe4 · xe3 , 1 = xe4 + (1 − xe4 ) ∈ I.
The Gröbner proof system, introduced by Clegg, Edmonds & Impagliazzo
(1996), computes the reduced Gröbner basis G of I and then checks whether
G = {1}, thus testing whether 1 ∈ I (Exercise 21.19). For the ideal in (4), M APLE’s
Groebner:-Basis command produces G = {1}, immediately showing that 1 ∈ I.
Clegg et al. prove that their Gröbner proof system can simulate others efficiently,
such as Horn clause resolution, and thus is at least not worse than these, in an
appropriate sense. They also show that in some cases, this system is better than
others. The details are not too difficult, but beyond the scope of this text.
transitions t1 ,t2 ,t3 , and weights on the edges. All weights are 1, except weight 2
from s3 to t3 . Furthermore, a marking M of the net assigns to each place si a non-
negative integer M(si ), the number of tokens on that node. Such a marked Petri
net can be used to describe a state of a system of processes.
s1 s2
t1 t2
s3
2
t3
s1 s2 s1 s2 s1 s2
t1 t2 t1 t2 t1 t2
s3 s3 s3
2 2 2
t3 t3 t3
F IGURE 24.2: The Petri net from Figure 24.1 after one, two, and three firings, respectively.
A Petri net is reversible if for each firing there is a sequence of firings that
form the reverse of the given one. This is illustrated in Figure 24.2, where the last
two firings reverse the first one. The reachability problem for (reversible) Petri
nets is, given two markings M and M ∗ of the same net, to decide whether M ∗ can
be obtained from M by a sequence of firings. If the Petri net is reversible, then M ∗
is reachable from M if and only if M is reachable from M ∗ .
24.3. Proving identities and analysis of algorithms 681
marking in Figure 24.2, respectively, are reachable from each other, and in fact the
polynomial
x2 x3 − x1 x2 = x2 · f1
is in the ideal h f1 , f2 , f3 i ⊆ F[x1 , x2 , x3 ].
We model this by the following random experiment. An urn contains w white and
n − w black balls, for integers 0 < w ≤ n. The white and black balls represent the
lucky and unlucky points in U, respectively. We repeatedly draw balls, without
replacement, and let the random variable T denote the number of trials until we
have first found precisely s white balls, where 0 ≤ s ≤ w. Moreover, we consider
random variables X1 , . . . , Xn , where Xk counts the number of white balls obtained
after k trials. Then the Xk have a hypergeometric distribution
wn−w
prob(Xk = s) = s k− s ,
n
k
since there are ws possibilities to choose s white balls, n−w k−s possibilities to
n
obtain k − s black balls, and the total number of choices is k . If k < s, then we
have prob(Xk = s) = 0. Using conditional probabilities, we find
(n + 1)s
∑ kpk = , (6)
0≤k≤n w+1
(this is quite close to the expected value ns/w for drawing with replacement ) and
let
k n−k k n−k
kpk (w + 1) s w−s s w−s
g(n, k) = = = (7)
(n + 1)s n+1 n n+1
w+1 w w+1
for 0 ≤ k ≤ n. If we define S(n) = ∑0≤k≤n g(n, k) = ∑k∈Z g(n, k), then the claim (6)
is equivalent to S(n) = 1 for all n ∈ N with n ≥ w. It is easy to check that the
24.3. Proving identities and analysis of algorithms 683
(k − n − 1)(k − s)
f (n, k) = − g(n, k) (8)
(n + 2)(k − n − 1 + w − s)
satisfies
f (n, k + 1) − f (n, k) = g(n + 1, k) − g(n, k) (9)
for all n ≥ w and k ∈ Z (after dividing both sides in (9) by g(n, k), only rational
functions in n and k remain). Thus
for all n ≥ w, so that indeed S(n) = S(n − 1) = · · · = S(w) = 1 (by (7), the only
nonvanishing summand in S(w) = ∑0≤k≤w g(w, k) is g(w, s) = 1), and the claim is
proved.
But where does the magic term f in (8) come from? We consider s, w to be
indeterminates, let x and y be two other indeterminates over Q, and see that (9),
with n and k replaced by y and x, respectively, is just an indefinite summation
problem with respect to the variable x over the field Q(s, w, y) of rational functions
in s, w, y, namely ∆ f ∗ = g∗ , where f ∗ (x) = f (y, x) and g∗ (x) = g(y + 1, x) − g(y, x),
and we can apply the hypergeometric summation algorithm 23.25. In our example,
we have
y−x+1 y−x
x w−s − w−s
g(y + 1, x) − g(y, x) =
s y+2 y+1
w+1 w+1
x y−x
(y + 1 − w)(x − y − 1) s w−s
= −1
(y + 2)(x − y + w − s − 1) y+1
w+1
(w + 1)x − (s + 1)y + w − 2s − 1
=− g(y, x), (10)
(y + 2)(x − y + w − s − 1)
g(y + 1, x + 1) − g(y, x + 1)
σ=
g(y + 1, x) − g(y, x)
(x + 1)(x − y + w − s − 1) (w + 1)x − (s + 1)y + 2w − 2s
= ,
(x − s + 1)(x − y) (w + 1)x − (s + 1)y + w − 2s − 1
684 24. Applications
U (x − y − 1)(x − s)
f (y, x) = (g(y + 1, x) − g(y, x)) = − g(y, x),
V (y + 2)(x − y − 1 + w − s)
which enabled us to verify the correctness of (6) independently of the above com-
putations, by simply checking the validity of (9). In the example, it may be easier
to prove (6) directly by induction (Exercise 24.3). A variant of the above procedure
can even find the right hand side in (6), given only the summand kpk .
The above approach, due to Herbert Wilf and Doron Zeilberger, works for a
certain class of bivariate hypergeometric summands. In this way a large variety of
combinatorial identities involving sums over binomial coefficients, with (6) being
only a rather trivial special case, can be automatically proved, and proof certificates
similar to f in (9) such that f (n, k)/g(n, k) is a rational function can be generated.
If a closed form for the sum is not known in advance, then Zeilberger’s method
finds one if it exists, or otherwise at least a recursion formula. For example, the
method finds routinely the second order recurrence
which played an important role in Roger Apéry’s sensational proof that ζ (3) is
irrational. The ideas can also be extended to more than two variables, nested sums,
24.4. Cyclohexane revisited 685
a1 ⋆ a1 = a2 ⋆ a2 = · · · = a6 ⋆ a6 = 1,
1
a1 ⋆ a2 = a2 ⋆ a3 = · · · = a6 ⋆ a1 = , (12)
3
a1 + a2 + · · · + a6 = 0,
where ⋆ is the inner product. These conditions express the convention that each
bond has unit length, the angle α between two successive (oriented) bonds has
cos α = 1/3, and that the structure is cyclic. We now let Si j = ai ⋆ a j for 1 ≤ i, j ≤ 6.
Under the conditions (12), Si j is the cosine of the angle between ai and a j . Since
Si j = S ji for 1 ≤ i < j ≤ 6,
S11 = S22 = · · · = S66 = 1,
1 (14)
S12 = S23 = · · · = S61 = ,
3
Si1 + Si2 + · · · + Si6 = 0 for 1 ≤ i ≤ 6
The advantage of (14) over (12) is that all equations are linear. We have 33 =
15 + 6 + 6 + 6 linear equations in 36 variables. It turns out that these equations
are linearly independent, so that the solution space has 36 − 33 = 3 dimensions.
Calculating by hand, we plug the first three lines into the last six equations and
686 24. Applications
a4
a3 a5
a2 a6
a1
F IGURE 24.3: A “chair” conformation of cyclohexane, and the orientation we give to the
bonds a1 , . . . , a6 .
arrange the indices so that only Si j ’s with i < j appear. All 36 values are then
expressed as linear functions of the nine unknowns
with(LinearAlgebra):
G := Matrix(1..6, 1..6, (i,j)->’S’[i,j], shape=symmetric);
for i from 1 to 6 do
S[i,i] := 1:
end:
24.4. Cyclohexane revisited 687
for i from 1 to 5 do
S[i,i+1] := 1/3:
end:
S[1,6] := 1/3:
eq := {seq(S[i,1]+S[i,2]+S[i,3]+S[i,4]+S[i,5]+S[i,6]=0,
i=1..6)}:
sol := solve(eq, {S[1,4],S[2,4],S[2,5],S[2,6],S[3,6],S[4,6]});
G := eval(G, sol);
S1, 1 S1, 2 S1, 3 S1, 4 S1, 5 S1, 6
S2, 1 S2, 2 S2, 3 S2, 4 S2, 5 S2, 6
S3, 1 S3, 2 S3, 3 S3, 4 S3, 5 S3, 6
G :=
S4, 1 S4, 2 S4, 3 S4, 4 S4, 5 S4, 6
S5, 1 S5, 2 S5, 3 S5, 4 S5, 5 S5, 6
S6, 1 S6, 2 S6, 3 S6, 4 S6, 5 S6, 6
5 5
sol := {S1, 4 = − − S1, 3 − S1, 5 , S2, 5 = −S1, 5 − S3, 5 − ,
3 3
5
S3, 6 = −S1, 3 − − S3, 5 , S4, 6 = S1, 3 , S2, 6 = S3, 5 , S2, 4 = S1, 5 }
3
1 5 1
1 , , S1, 3 , − − S1, 3 − S1, 5 , S1, 5 ,
3 3 3
1 1 5
, 1 , , S1, 5 , −S1, 5 − S3, 5 − , S3, 5
3 3 3
1 1 5
S1, 3 , , 1 , , S3, 5 , −S1, 3 − − S3, 5
3 3 3
G :=
5 1 1
− − S1, 3 − S1, 5 , S1, 5 , , 1 , , S1, 3
3 3 3
S , −S − S − 5 , S , 1 , 1 , 1
1, 5 1, 5 3, 5
3
3, 5
3 3
1 5 1
, S3, 5 , −S1, 3 − − S3, 5 , S1, 3 , , 1
3 3 3
We have included M APLE’s results here. The M APLE code can be downloaded
from the book’s web page http://cosec.bit.uni-bonn.de/science/mca/,
and the reader is encouraged to run this code herself or to modify it so that it runs
under her computer algebra system, if that is different from M APLE.
In the transition from the vectors ai to the inner products Si j we have lost one
central piece of information: the dimension of the space in which the ai ’s live.
Mathematically (but not chemically) the Si j might just as well be the inner products
of some ai ’s in R 10 or so. In fact, if we consider science-fiction cyclohexane
in six (or more) dimensions, then (14) describes precisely all its conformations.
(Actually, some inequalities also have to hold; these are explained later.)
688 24. Applications
Back to the real world! We have to reintroduce the information that chemistry
(unlike mathematics and computer science) lives in three dimensions only. In R 3 ,
any four vectors are linearly dependent, and hence a solution to (14) can be realized
in three-space if and only if any four of a1 , . . . , a6 are linearly dependent. In order
to express this in terms of the Si j , we introduce the abbreviations x = S13 , y = S35 ,
and z = S15 , and consider the Gramian matrix (Section 25.5)
The convert command transforms the set A \ {i, j} into a list, the data format
required for the second and third arguments of the SubMatrix command.
As noted above, any assignment of specific real values for the inner products
Si j for 1 ≤ i, j ≤ 6 coming from a conformation of the cyclohexane molecule in
three-space yields a common zero of the polynomials in F, and hence a zero of all
polynomials in I. More precisely, we have
{(S13 , S35 , S15 ) ∈ R 3 : ∃S11 , S12 , . . . , S66 such that (14) and (18) hold} = V (I).
We first look at a two-dimensional image of our situation. We are lucky: the set
F already contains exactly one polynomial in x and y only, namely g1 from (19).
It will turn out that its zero set X = V (g1 ), shown in Figure 24.4, is the projection
of V (F) onto the x, y-plane, and that with two exceptions, over each point of X lies
exactly one point of V (F).
The polynomial g1 is quadratic both in x and y and of total degree four, and for
a specific value u ∈ R, we can determine v ∈ R such that (u, v) ∈ V (g1 ) by solving
g1 (u, v) = 0:
p
−3u2 + 10u + 17 ± 8(27u4 + 48u3 − 24u2 − 44u − 7)
v= , (20)
9u2 + 6u − 23
as provided by M APLE’s command
g[1] := Determinant(SubMatrix(G, [1,2,3,6], [1,2,3,6]));
solve(g[1], y);
If the denominator in (20) does not vanish, then this equation has 0, 1, or 2 real
solutions v ∈ R, depending on whether the discriminant
32
(27u4 + 48u3 − 24u2 − 44u − 7)
81
690 24. Applications
x-y=0
–4 –2 0 2 4 x
x+y+2/3=0
g[1]=0 –2
–4
0.2
–0.2
Q y
–0.4
"boat"
–0.6
g[1]=0
–0.8
–1
of g1 (see Example 6.18) is negative, zero, or positive. The latter happens when
√ √
6 7 6
u < −1 − or − < u < −1 + or 1 < u, (21)
3 9 3
and single solutions occur for
√
6 7
u ∈ {−1 ± , − , 1} ≈ {−1.8165, −0.1835, −0.7778, 1} (22)
3 9
(the pink points in Figure 24.4), as certified by the M APLE command
factor(discrim(g[1], y));
√
For u = (−1 ± 2 6)/3 ≈ −0.3333 ± 1.6330 (the light blue points in Figure 24.4),
the coefficient of y2 in g1 , which equals the denominator in (20), vanishes, and
there is a unique v ∈ R such that g1 (u, v) = 0, namely
√
23u2 + 34u + 15 −1 ∓ 2 6
v= = . (23)
6u2 − 20u − 34 3
Figure 24.4 shows a plot of X and of a magnification of the central piece of X,
which will turn out to be the only piece relevant for our cyclohexane problem. (The
yellow triangle is explained below.) The points (−1/3, −1/3), (−1/3, −7/9), and
(−7/9, −1/3) marked in Figure 24.4 are the projections of the three “boat” points
in Figure 1.5 on page 15.
What is the precise connection between X and V (F)? Since g1 ∈ F, for any
(u, v, w) ∈ V (F), we have g1 (u, v) = 0, and thus the whole projection of V (F) is
contained in X. Conversely, if (u, v) ∈ X, can we find a w ∈ R such that (u, v, w) is
a common zero of the other eight polynomials in F? All of them have degree two
in z, and it would be nice if we could somehow eliminate the occurrences of z2 .
We take a close look, and find that the two polynomials
g2 (x, y, z) = det Ga2 ,a3 ,a5 ,a6
1
= (9x2 y2 + 18x2 yz + 9x2 z2 + 18xy2 z + 18xyz2 + 9y2 z2 + 30x2 y
9
+30x2 z + 60xy2 + 120xyz + 30xz2 + 60y2 z + 30yz2 + 16x2
+118xy + 98xz + 36y2 + 118yz + 16z2 + 50x + 60y + 50z + 21),
g3 (x, y, z) = det Ga1 ,a3 ,a4 ,a6 = g2 (y, x, z)
have the same leading coefficient (9x2 + 18xy + 9y2 + 30x + 30y + 16)/9 with re-
spect to the variable z. Thus
10 2
g4 = g3 − g2 = (3x y + 3x2 z − 3xy2 − 3y2 z + 2x2 + 2xz − 2y2 − 2yz + x − y)
9
10
= (x − y)(3xy + 3xz + 3yz + 2x + 2y + 2z + 1)
9
692 24. Applications
3uv + 2u + 2v + 1
w=− . (24)
3u + 3v + 2
as provided by
factor(eval(g[1], y=x));
The plane curve X contains no line and has degree four, and any line in the plane
intersects X in at most four points, counting multiplicities, by the famous theorem
of Bézout; see Section 6.8. We have found those four points for our special line
x = y (see Figure 24.4). We have to check separately—by using other polynomials
from F—that they yield the six points
1 1 1 1 1 7
(−3, −3, −3), (−3, −3, 1),
C = − ,− ,− , − ,− ,− ,
3 3 3 3 3 9
(26)
2√ 2√ 1√ 2√ 2√ 1√
1+ 6, 1 + 6, −1 − 6 , 1− 6, 1 − 6, −1 + 6
3 3 3 3 3 3
factor(eval(g[1], y = -x-2/3));
gives three values for u, and substituting each of them in the equation v = −u−2/3
yields the three intersection points
1 1 −1 + 2√6 −1 − 2√6 −1 − 2√6 −1 + 2√6
− ,− , , , , (27)
3 3 3 3 3 3
of the line V (3x + 3y + 2) with X (see Figure 24.4). The first one is the point Q
from above, which lies on the central piece and is actually a “double point” of the
intersection. The slope of the tangent to X at a point (u, v) is
∂g1 /∂x 18uv2 + 12uv + 6v2 − 46u − 20v − 34
− (u, v) = − ,
∂g1 /∂y 18u2 v + 6u2 + 12uv − 20u − 46v − 34
and its value at Q = (−1/3, −1/3) is −1. The line has the same slope, and so it
is the tangent at Q to X. We have already seen that there are precisely two points
of V (F) lying over Q. In the vicinity of the other two intersection points, the z-
coordinate grows unboundedly, and there are no points of V (F) lying above them.
Putting things together, we have found the following. In order to determine all
solutions S11 , S12 , . . . , S66 of (14) and (18), we can proceed as follows. We pick
a point P = (u, v, w) ∈ V (F), set S13 = u, S35 = v, S15 = w, and solve for the
remaining Si j via (14) and (16). To find P ∈ V (F), we pick a real number u as
in (21) or (22), determine v according to (20) or (23) (so that (u, v) ∈ X), and w
by (24) if (u, v) equals none of the points in (25) and (27); otherwise, P is one of the
six points in (26). We obtain similar solutions, with the roles of three coordinates
permuted, when we apply the M APLE command solve directly to the original
nine equations in F.
Finally, another constraint comes into play that we have ignored so far. Each
Si j is the cosine of an angle, and hence lies between −1 and 1. These inequalities,
applied to S14 , S25 , S36 , and using (16), show that all our physical solutions lie in
the polytope
2 2 2
A = {(u, v, w) ∈ [−1, 1]3 : u + v ≤ − , u + w ≤ − , v + w ≤ − },
3 3 3
The projection of A onto the first two coordinates is the yellow triangle in Fig-
ure 24.4. Thus neither the point (−3, −3, −3) nor the outlying branches of X con-
tribute physical
√ solutions, but C = (−1/3, −1/3, −1/3) (the “chair”) and −7/9 ≤
u ≤ −1 + 6/3 do, leading precisely to the points in V (F) ∩ A.
694 24. Applications
From the point of view of computer algebra, this completely solves the problem,
except that we would also have to calculate actual a1 , . . . , a6 from S11 , S12 , . . . , S66
(Exercise 24.6).
We now indicate how Gröbner bases lead to a somewhat more systematic way
of solving our problem than the above ad hoc approach. It may seem that this is a
bit of overkill, but the reader may imagine that the solution “by hand” is no longer
feasible for cycloheptane (seven carbon atoms), where 35 polynomial equations in
seven unknowns have to be solved, while Gröbner bases still work.
We take the lexicographical order with z ≻ y ≻ x. In M APLE, the commands
with(Groebner):
B := Basis(F, plex(z,y,x));
provide in a few seconds the reduced Gröbner basis B of V (F) consisting of the
four polynomials
f1 = 9g1 = 9x2 y2 + 6x2 y + 6xy2 − 23x2 − 20xy − 23y2 − 34x − 34y − 15,
f2 = 27x4 y + 27x4 z + 18x4 + 108x3 y + 108x3 z + 18x2 y + 18x2 z
−284x2 − 212xy − 212xz − 400x − 69y − 69z − 102.
f3 = −9x3 y − 9x3 z − 6x3 − 9x2 y − 9x2 z + 18x2 + 41xy + 41xz + 20yz
+54x + 21y + 21z + 18,
f4 = 9x2 z2 + 6x2 z + 6xz2 − 23x2 − 20xz − 23z2 − 34x − 34z − 15.
B := factor(B);
24.4. Cyclohexane revisited 695
shows that f1 , f3 and f4 are irreducible over Q. For f1 , for example, this follows
from the facts that f1 is primitive with respect to x, so that it has no nonconstant
factor in Q[y], and that f1 (x, 2) = 25(x2 − 2x − 7) is irreducible. The polynomial
f2 factors as f2 = (x + 3)(3x + 1) f5 , where
The first two factors can be found by computing contents with respect to y or z,
and f5 is irreducible because it is primitive with respect to x, so that it contains no
nonconstant factor in Q[y, z], and since f5 (x, 0, 0) = 2(3x2 − 10x − 17) is irreduci-
ble. Since a point in R 3 is a root of a polynomial f = gh if and only if it is either
a root of g or a root of h (or of both), we have V (I) = V (I1 ) ∪V (I2 ) ∪V (I3 ), where
I1 = h f1 , f3 , f4 , x + 3i, I2 = h f1 , f3 , f4 , 3x + 1i, I3 = h f1 , f3 , f4 , f5 i.
F1 := {B[1],B[3],B[4],op(1,B[2])}:
F2 := {B[1],B[3],B[4],op(2,B[2])}:
F3 := {B[1],B[3],B[4],op(3,B[2])}:
B1 := Basis(F1, plex(z,y,x));
B2 := Basis(F2, plex(z,y,x));
B3 := Basis(F3, plex(z,y,x));
compute the reduced Gröbner bases for the three new ideals with respect to the
lexicographic order and z ≻ y ≻ x. The op command in the first line extracts the
first operand x+3 of its second argument B[2], and analogously in the following
two lines. We obtain
B1 = {z2 + 2z − 3, yz + 3y + 3z + 9, y2 + 2y − 3, x + 3},
B2 = {27z2 + 30z + 7, 9yz + 3y + 3z + 1, 27y2 + 30y + 7, 3x + 1},
B3 = { f1 , f5 , f6 }, (28)
where
f6 = 3xy + 3xz + 3yz + 2x + 2y + 2z + 1.
All polynomials in B1 and B2 are products of linear factors; for example, the second
one in B1 is yz + 3y + 3z + 9 = (y + 3)(z + 3). The solutions of B1 and B2 are easily
determined:
V1 := solve({op(B1)});
V2 := solve({op(B2)});
The following three M APLE lines verify that of the six points in V (I1 ) and V (I2 ),
all but (−3, −3, −3) and C = (−1/3, −1/3, −1/3) are also contained in V (I3 ).
for v in V1 do
eval(B3, v);
end;
for v in V2 do
eval(B3, v);
end;
We note that f6 = 9g4 /(x − y), and proceeding as in our ad-hoc approach, we can
show that over each point of X = V ( f1 ) lies precisely one point of V (I3 ), and
hence V (F) is the disjoint union of V (I3 ) and two isolated points (−3, −3, −3)
and C = (−1/3, −1/3, −1/3).
Figure 1.5 on page 15 gives a three-dimensional plot of E = V (I3 ) ∩ A. We did
not proceed as described above to produce this plot, but instead took the equation
f5 (u, v, w) = 0 to obtain the third coordinate
and we used some ad hoc tricks. Our strategy can be summarized as follows: we
expressed the solutions as roots of polynomial equations, computed Gröbner bases,
and factored our polynomials whenever possible. A factorization splits the prob-
lem into smaller subproblems; each of these is better manageable than the big
problem. The bottleneck in this approach is typically the Gröbner basis computa-
tion.
Notes. 24.1. We refer the reader to Krajíček (1995), Urquhart (1995), Pitassi (1997), and
Beame & Pitassi (1998) for excellent surveys of the state of the art in proof systems. The
Nullstellensatz proof system was introduced by Beame, Impagliazzo, Krajíček, Pitassi &
Pudlák (1996). Gröbner proof systems are an active area of research; see Buss, Impagli-
azzo, Krajíček, Pudlák, Razborov & Sgall (1996/97) and Razborov (1998); they are also
called polynomial calculus systems . A central measure of the complexity of such a system
is the degree of the polynomials that occur. The pigeonhole principle for n = 100 is stated
in Schwenter (1636), 53. Auffgab.
24.2. Peterson (1981) and Reisig (1985) give general introductions to Petri nets. Our alge-
braic description of Petri nets follows Mayr (1992). Further results about the reachability
problem for Petri nets and connections to finitely presented commutative semigroups and
vector addition systems are given in Mayr (1995). The fact about binomial ideals is due to
Eisenbud & Sturmfels (1996).
Mayr (1984) solved a long-standing open problem by showing that reachability for Petri
nets is decidable. His algorithm is not primitive recursive, but the best proven lower bound
for reachability is EX PSPA CE -hardness. In fact, reachability for reversible Petri nets is
EX PSPA CE-complete.
24.3. See also Notes 23.4. The method of creative telescoping for proving hypergeometric
identities was pioneered by Doron Zeilberger (1990a, 1990b, 1991), who has his comput-
ers publish papers (Ekhad 1990, Ekhad & Tre 1990) (“And how many papers did your
workstation publish?”), and Herbert Wilf (Wilf & Zeilberger 1990, 1992), and started a
debate about the price of mathematical theorems (Zeilberger 1993, Andrews 1994). Wilf
and Zeilberger received the 1998 Leroy P. Steele Prize for a Seminal Contribution to Re-
search, as reported in the April 1998 issue of the Notices of the AMS. We refer the reader
to the well-written books of Petkovšek, Wilf & Zeilberger (1996) and Koepf (1998) for
further reading on the method.
Our proof of (6) actually uses WZ-pairs , as invented by Wilf & Zeilberger (1990); see
also Wilf (1994), §4.4. Van der Poorten (1978) gives an overview of Apéry’s proof. Paule’s
(1994) computer-generated proof of (11) can be verified using only high-school algebra.
For the analysis of algorithms, it is often sufficient to have only an asymptotic approxi-
mation for a sum such as (6), in particular in those cases where (provably) no closed form
exists. There is a powerful general tool, generating functions , which together with singu-
larity analysis from complex analysis provides a standard means to obtain such asymptotic
expansions (Flajolet & Odlyzko 1990, Vitter & Flajolet 1990, Flajolet, Salvy & Zimmer-
mann 1991, Odlyzko 1995a). The software package ΛΥΩ (Flajolet, Salvy & Zimmer-
mann 1989a, 1989b, Salvy 1991, Zimmermann 1991) automates this process; it is inte-
grated in the combstruct package of the M APLE library A LGOLIB developed at INRIA
(http://algo.inria.fr/libraries/software.html). Sedgewick & Flajolet (1996)
is a very readable textbook in this area.
698 24. Applications
24.4. Most introductory texts on organic chemistry discuss the cyclohexane conforma-
tions; see for example Wade (1995). Sachse (1890, 1892) first postulated the existence of
infinitely many flexible and a single rigid conformation of cyclohexane. Oosterhoff (1949)
and Hazebroek & Oosterhoff (1951), whose goal was to determine the potential energy of
cyclohexane conformations, pioneered the approach given here, based on the inner prod-
ucts. Levelt (1997) applied computer algebra to the problem, actually to cycloheptane; our
presentation is based on Levelt’s work. Levelt cautions: Does it matter to the chemists?
The answer is “NO!”. In our model the geometry rules: the ‘building blocks’ are rigid;
in chemistry energy rules and nothing is rigid. Distances between carbon molecules may
vary, just as angles between bonds. The molecule is viewed as a conglomerate of atoms
kept together by the various forces between the constituents. The geometry of the molecule
is the result of the balance of the forces. The chemist’s flexible model is the opposite of
the rigid one in this [model]. Of course, one might now take the formulas for the potential
energy and process them with computer algebra tools; we do not know whether something
really useful comes out of that.
In their important paper, Gō & Scheraga (1970) found that for a cyclic molecule with
n ≥ 6 carbon atoms, the solution space of possible conformations is (n − 6)-dimensional in
the generic case. This does not apply to cyclohexane, where n = 6 and we have seen that the
solution space contains a one-dimensional component. For more recent contributions and
references, see Havel & Najfeld (1995) and Emiris & Mourrain (1999). The cyclohexane
problem is closely related to the well-studied 6R inverse kinematics problem from robotics;
see Parsons & Canny (1994) for references and an overview on related problems.
M OLGEN is a general purpose computer chemistry system (Benecke, Grund, Hohberger,
Kerber, Laue & Wieland 1995).
The two equations (24) and (29) are equivalent since
so that both equations determine the same value of w whenever (u, v) ∈ X = V (g1 ) and
both are defined.
Exercises.
24.1−→ Refute PHP2 with both the Nullstellensatz and the Gröbner proof system.
24.2 Prove that the Petri net in Figure 24.1 is not reversible. Hint: Consider the marking M(s1 ) = 2,
M(s2 ) = M(s3 ) = 0.
24.3∗ Prove (6) for all nonnegative integers n ≥ w ≥ s by double induction on w and n.
24.4∗ Let V be a vector space over a field F and ⋆:V ×V −→ F an inner product on V . For a finite
sequence a1 , . . ., an ∈ V of vectors, let G = (ai ⋆ a j ) ∈ F n×n be the Gramian matrix of a1 , . . ., an .
(i) Show that det G = 0 if and only if a1 , . . ., an are linearly dependent.
(ii) Conclude that the rank of G is equal to the rank of {a1 , . . ., an }.
Exercises 699
This appendix presents some of the basic notions used throughout the text, for the reader’s
reference. By necessity, this is kept rather short and without proofs; we indicate, however,
reference texts where these can be found. The reader is required to either have previous
acquaintance with the material or be willing to read up on it. Our presentation is too concise
for self-study; its purpose is to fix the language and point the reader to those areas, if any,
where she needs brushing up.
The first five sections deal with algebra: groups, rings, polynomials and fields, finite
fields, and linear algebra. Then we discuss finite probability spaces. After this mathe-
matical background come some fundamentals from computer science: O-notation and a
modicum of complexity theory.
25.1. Groups
The material of the first three sections can be found in any basic algebra text, such as
Hungerford (1990) or the latest edition of van der Waerden’s (1930b, 1931) classic on
Modern Algebra.
The group is denoted by (G; ·, 1,−1 ), but usually just the set name G is sufficient.
It is usual, for convenience of notation, to omit the symbol · from products. Thus a · b
becomes the simpler ab. We will also frequently need to distinguish between two group
operations. The alternate notation + for · , 0 for 1 and −a instead of a−1 is used. The
first representation is called a multiplicative group and the new one is called an additive
group, denoted by (G; +, 0, −).
Familiar examples are the additive groups of Z, Q, R, and C, the multiplicative groups of
Q\{0}, R\{0}, and C\{0}, and for any n ∈ N, the additive group Zn = {0, 1, 2, . . . , n−1}
with addition modulo n and the multiplicative group Z× n = {1 ≤ a < n: gcd(a, n) = 1} with
multiplication modulo n.
703
704 25. Fundamental concepts
For n ∈ N>1 , the symmetric group Sn consists of all permutations of the elements
{1, . . . , n}:
Sn = {σ: {1, . . . , n} −→ {1, . . . , n}: σ bijective};
the group operation is the composition ◦ of maps. This group has #Sn = n! elements and is
not commutative if n ≥ 3.
25.2. Rings
A ring is an algebraic structure with two operations, as follows.
Familiar examples are Z, Q, R, and C, with the usual addition and multiplication, and,
for all n ∈ N>0 , Zn with addition and multiplication modulo n, and the set R n×n of all
n × n matrices with real entries, with matrix addition and matrix multiplication. All these
examples, except the matrices, form a commutative ring. Matrix rings briefly occur in
Chapter 12.
In this book, all rings are commutative with 1 unless otherwise stated.
In general, we write
ha1 , . . . , as i = a1 R + · · · + as R = {a1 r1 + · · · + as rs : r1 , . . . , rs ∈ R}
706 25. Fundamental concepts
for the ideal generated by a1 , . . . , as , and say that a1 , . . . , as is a basis of that ideal. In
particular, hai = aR = {ar: r ∈ R} is the principal ideal generated by a ∈ R. We note an
ambiguity inherent in the notation hai, as exemplified by 12Z = “h12i” 6= 12Q = Q.
Suppose that I ⊆ R is an ideal, and r, s ∈ R. We say that r and s are congruent modulo I
(written as “r ≡ s mod I”) if r − s ∈ I. As an example, with R = Z, we have 14 ≡ 2
mod 12Z, which we also write as 14 ≡ 2 mod 12. If a, b ∈ R, we write a | b (“a divides b”)
if there exists some r ∈ R with ar = b, and a ∤ b otherwise.
For r ∈ R, the set r mod I = r + I = {r + a: a ∈ I} ⊆ R is a residue class modulo I or a
coset of the ideal I. (Note the distinction between the congruence relation modulo I, as in
14 ≡ 2 mod 12Z, where the “ mod ” belongs to the ≡ sign, and the residue class modulo I,
as in 2 mod 12Z.) We have the following equivalences:
r mod I = s mod I ⇐⇒ r − s ∈ I ⇐⇒ r ≡ s mod I
for all r, s ∈ R. The set R/I = {r mod I: r ∈ R} of all residue classes modulo I is again a ring
if we define the ring operations by (r mod I) + (s mod I) = (r + s) mod I and (r mod I) ·
(s mod I) = (rs) mod I. It is called the residue class ring (or factor ring) of R modulo I.
We have the canonical ring homomorphism ϕ: R −→ R/I mapping r ∈ R to its residue
class r mod I. For instance, if R = Z and I = 12Z, then R/I = Z/12Z = {0 mod 12Z,
1 mod 12Z, 2 mod 12Z, . . . , 11 mod 12Z}, and ϕ(14) = 14 mod 12Z = 2 mod 12Z. We
will also write 2 mod 12, or even simply 2, for 2 mod 12Z, thus identifying the residue
class ring Z/12Z with Z12 = {0, 1, 2, . . . , 11}.
More generally, a set of elements S ⊆ R is a system of representatives for I if for all
a ∈ R there exists exactly one b ∈ S such that a ≡ b mod I. For example, {0, 1, 2, . . . , 11}
is a system of representatives for I = 12Z; another one is {−5, −4, . . . , 4, 5, 6}. There are
many other such systems. A system of representatives can be made into a ring again, by
using multiplication and addition modulo I, and then S ∼ = R/I.
As for groups, there is also a homomorphism theorem for rings. If R and S are rings,
ϕ: R −→ S is a ring homomorphism, and I = ker ϕ = {r ∈ R: ϕ(r) = 0} ⊆ R is the kernel
of ϕ, then I is an ideal of R, and R/I is isomorphic to the subring ϕ(R) = {ϕ(r): r ∈ R}
of S, the image of ϕ.
If R and S are rings, then the ring R × S = {(r, s): r ∈ R, s ∈ R} is the direct product of R
and S. The ring operations are defined componentwise: (r1 , s1 )+(r2 , s2 ) = (r1 +r2 , s1 +s2 )
and (r1 , s1 ) · (r2 , s2 ) = (r1 r2 , s1 s2 ) for all r1 , r2 ∈ R and s1 , s2 ∈ S.
We can add more and more properties to rings, to get domains in which more interesting
things can be done, for instance computing greatest common divisors or factoring. The first
restriction is to consider integral domains, which are nontrivial commutative rings without
nonzero zero divisors. Here, nontrivial means that 1 and 0 are distinct, and a zero divisor
is an element a ∈ R for which there is a nonzero element b ∈ R such that ab = 0. (Is Z12
or Z7 an integral domain?) Thus 0 is a zero divisor in any ring. In an integral domain we
have the useful fact that if a 6= 0 and ab = ac then b = c, known as the cancellation law.
For the ring of integers, we have two further interesting properties.
◦ Division property: ∀a, b ∈ Z, b 6= 0, ∃!q, r ∈ Z a = qb + r and 0 ≤ r < |b|.
◦ Unique factorization: Every integer greater than 1 has an (essentially) unique factor-
ization as a product of primes.
These properties generalize to other rings. To talk about the division property we need an
extra function to satisfy the role played by the absolute value in the integer case. An integral
25.2. Rings 707
The ring Z[i] of Gaussian integers is the special case where d = −1. The norm N: R −→ Z
is defined by N(a) = aa = |a|2 = b2 + c2 , where a denotes the complex conjugate of a =
b + ic, with b, c ∈ R, and takes only nonnegative values. This norm is a Euclidean function
on R if and only if d ∈ {−1, −2, −3, −7, −11}, and these are the only cases where R is
Euclidean at all. Furthermore, R is a Unique Factorization Domain if and only if R is
Euclidean or d ∈ {−19, −43, −67, −163}.
There exist integral domains that are not even UFDs. The√classical example (from
Dirichlet’s (1893) Zahlentheorie, page 451) is R = O−5 = Z + Z −5, the ring of algebraic
708 25. Fundamental concepts
√
integers of Q( −5). In this ring,
√ √
(1 + −5) · (1 − −5) = 6 = 2 · 3
T HEOREM 25.3.
For an integral domain R, the following are equivalent.
(i) R is a UFD.
(ii) Any nonzero nonunit in R can be written as a product of primes.
(iii) Any nonzero nonunit in R can be written as a product of irreducibles, and any irre-
ducible in R is prime.
(iv) Any nonzero nonunit in R can be written as a product of irreducibles, and any two
nonzero elements of R have a gcd in R.
In particular, since gcd’s exist in Euclidean domains (Chapter 3), every Euclidean do-
main is a UFD. The reverse is false in general, as we have seen above: O−19 is a UFD but
not a Euclidean domain. Other examples are in Exercises 3.17 and 21.1.
We also use polynomials in two or more variables. R[x][y] consists of univariate polyno-
mials in y with coefficients in R[x], but by collecting powers of x, we may as well consider
its elements as univariate polynomials in x with coefficients in R[y]. To reflect this symme-
try, we use the notation R[x, y], and more generally R[x1 , . . . , xn ]. We denote the degree and
the leading coefficient of such a multivariate polynomial a with respect to the variable xi
by degxi a and lcxi (a), respectively. The total degree of a multivariate monomial xe11 · · · xenn
is e1 + · · · + en , and the total degree of a 6= 0 is the maximal total degree of its monomials.
If R is a commutative ring or an integral domain, then so is R[x]. Gauß’ famous theo-
rem 6.8 shows that R[x] is a UFD if R is. We might hope that the same holds for Euclidean
domains. However, the division property goes away (say, in Z[x], as can be seen when you
try to divide x2 + 3 by 3x + 1). The division property holds if the leading coefficient of b is
a unit of R (Section 2.4).
If R is integral, then the units of R[x] are simply the units of R, where we use the nat-
ural identification of R with polynomials of degree 0. Irreducibles are a bit trickier. For
instance, x2 + 1 is irreducible in Z[x] and Z3 [x], but in Z5 [x], x2 + 1 = (x + 2)(x − 2).
The following lemma states an important property of polynomials over integral domains.
(ii) If R is an integral domain and f 6= 0, then f has at most deg f many roots in R.
Claim (ii) is not true in general rings: f = x2 ∈ Z16 [x] has the four roots 0, 4, 8, and 12.
For m ∈ Z, the canonical ring homomorphism ϕ: Z −→ Zm can be applied to each co-
efficient of a polynomial; this yields a homomorphism Z[x] −→ Zm [x] that is usually also
denoted by ϕ. Its kernel is m · Z[x], the ideal of polynomials with all coefficients divisible
by m. When u is an element of a ring R, then the evaluation homomorphism ε: R[x] −→ R
takes a polynomial f ∈ R[x] to ε( f ) = f (u) ∈ R. Its kernel is hx − ui, by Lemma 25.4 (i),
and the homomorphism theorem for rings shows that R[x]/hx − ui ∼ = im ε = R.
More generally, we have the canonical homomorphism R[x] −→ R[x]/hmi for any m
in R[x]. If m is nonconstant and monic, then the polynomials f ∈ R[x] of degree less
than deg m form a system of representatives for hmi, and hence they form the factor ring
R[x]/hmi, with addition and multiplication modulo m. When computing in R[x]/hmi, one
usually takes these representatives. The evaluation homomorphism ε is the special case
m = x − u.
If R and S are rings, ϕ: R −→ S is a ring homomorphism, f ∈ R[x1 , . . . , xn ] a polynomial
in n variables, and r1 , . . . , rn are elements of R, then
A field is an integral domain in which every nonzero element is a unit, that is, it
has a multiplicative inverse. Familiar examples are the fields Q of the rational num-
bers, the field R of the real numbers, and the field C of the complex numbers. We have
Q ⊆ R ⊆ C. The polynomial ring F[x] over a field F is Euclidean.
The number of elements in a field or ring is called its order. The above fields all have
infinite order, however, there are fields of finite order too. Among them are the fields Z p ,
where p is a prime. The existence of the inverse of a nonzero element a in Z p follows from
the fact that for 1 ≤ a < p, the (traditional) Extended Euclidean Algorithm 3.6 computes
s,t ∈ Z such that 1 = as + pt ≡ as mod p. Finite fields will be discussed in the next section.
If we consider the ring Z3 × Z3 of order 9, then its multiplicative identity is (1, 1), and
(1, 1) + (1, 1) + (1, 1) = (0, 0). This leads us to define the characteristic char R of a ring
or field R to be the minimum number of times the identity element can be added to itself
to get 0. In the case where this can never produce zero, the ring or field is said to have
characteristic zero. Q, R, and C are fields of characteristic zero, and the characteristic of
Z p is p.
If R is an integral domain, then K = {a/b: a, b ∈ R, b 6= 0} is the field of fractions of R.
For example, Q is the field of fractions of Z, and F(x), the set of rational functions in x
with coefficients in the field F, is the field of fractions of the polynomial ring F[x].
If a field F is contained in another field E, then we say that E is an extension field
of F and F is a subfield of E. For instance, C is an extension field of R, and R is an
extension field of Q. E is a vector space over F (see Section 25.5). An element α ∈ E is
algebraic over F if it is the root of a polynomial f ∈ F[x]: f (α) = 0 (or equivalently, if the
F-subspace of E generated 2
√by 1, α, α , . . . is finite dimensional). Thus all elements of F are
algebraic over F, and i = −1 ∈ C is algebraic over Q and R (taking f = x2 +1). Elements
that are not algebraic are called transcendental. For example, π and e are transcendental
over Q (see Notes 4.6). If all elements of E are algebraic over F, then we say that E is an
algebraic extension of F. For example, C is an algebraic extension of R, but not of Q.
If the dimension of E as a vector space over F is finite, then we say that E is a finite
extension of F. The dimension is denoted by [E : F], also called the degree of E over F.
All finite extensions are algebraic. If F ⊆ E ⊆ K are finite extensions, we have the degree
formula [K : F] = [K : E] · [E : F].
If α ∈ E is algebraic over F, then the set I = { f ∈ F[x]: f (α) = 0} of all polynomials
with coefficients in F that have α as a root is an ideal in F[x]. Since F[x] is a Euclidean
domain, every ideal in F[x] is generated by a single element, namely the unique nonzero
monic polynomial mα of least degree in I, so that I = hma i. It is called the minimal
polynomial of α. The minimal polynomial mα is irreducible, since otherwise there would
be a divisor of mα of smaller degree that has α as a root. Since mα generates I, all other
polynomials having α as a root are divisible by mα , and it is the only monic polynomial
with that property. The degree of α over F is deg mα . If F(α) ⊆ E denotes the smallest
subfield of E containing F and α, then deg mα = [F(α) : F]. For example, if E = C, F = R,
and α = i, then mi = x2 + 1, R(i) = C, and [C: R] = 2.
We may construct an algebraic field extension of a field F by taking E = F[x]/h f i
for an irreducible polynomial f ∈ F[x]. Since F[x] is Euclidean, the Extended Euclidean
Algorithm 3.14 computes s,t ∈ F[x] with 1 = as + f t ≡ as mod f for all nonzero a ∈ F[x]
with deg a < deg f . This shows that all nonzero elements of E are invertible, and E is an
extension field of F if we identify F with the set of constant polynomials in E; in fact,
it is an algebraic extension. The polynomial f ∈ F[x] has α = (x mod f ) ∈ E as a root
25.4. Finite fields 711
(Lemma 4.5); actually, it is the minimal polynomial of α. If deg f = n, then the elements
αn−1 , . . . , α2 , α, 1 ∈ E are a basis of E over F. Thus E = F(α) and [E : F] = n.
On the other hand, if E is any extension field of F and α ∈ E is algebraic over F, with
minimal polynomial f ∈ F[x], then F(α), the smallest subfield of E containing F and α,
is isomorphic to F[x]/h f i. This follows from the homomorphism theorem for rings, since
the homomorphism F[x] −→ E which evaluates at α has kernel h f i and image F(α). For
example, R[x]/hx2 + 1i and C are isomorphic fields, under an isomorphism that associates
x mod (x2 + 1) to i.
An algebraic field extension E of a field F is the splitting field of a nonconstant poly-
nomial f ∈ F[x] if f splits into linear factors over E, but not over any proper subfield of E.
A field F is algebraically closed if and only if every nonconstant polynomial f ∈ F[x]
has a root in F; then f has deg f many roots, counting multiplicities. The fundamental
theorem of algebra says that the field C of complex numbers has this property. A smallest
algebraically closed field containing F (with no proper subfield enjoying this property) is
called an algebraic closure of F; this always exists.
rings
commutative rings
integral domains
UFDs
Euclidean
domains
fields
Figure 25.1 illustrates the classes of rings that we have discussed so far and their con-
tainment relations.
For every prime power q = pn , there exists a field with q elements. All such fields are
(non-canonically) isomorphic to each other, and we write Fq for any of them. In partic-
ular, F p = Z p for a prime p, but it is important to remember that F pn ∼ 6 Z pn for n ≥ 2.
=
On the other hand, every finite field has pn elements, for some prime p and n ≥ 1, and
is isomorphic to Z p [y]/h f i for some irreducible polynomial f ∈ Z p [y] of degree n. The
characteristic of F pn is p.
Fermat’s little theorem 4.9 says that a p−1 = 1 for a prime p and all a ∈ F× p
p , hence a = a
for all a ∈ F p . This holds in arbitrary finite fields.
xq − x = ∏ (x − a) in Fq [x].
a∈Fq
P ROOF. Lagrange’s theorem implies that each element g of a group with m elements sat-
isfies gm = 1. The unit group F× q = Fq \{0} has q − 1 elements, so that a
q−1 = 1 for all
nonzero a ∈ Fq , and aq = a for all a ∈ Fq . Thus x − a divides xq − x for all a ∈ Fq , and since
gcd(x − a, x − b) = 1 for a 6= b, we have that ∏a∈Fq (x − a) divides xq − x. Both polynomials
are monic and have degree q, and hence they are equal. ✷
Fq12
Fq6 Fq4
Fq3 Fq2
Fq
If a finite field Fqm is contained in another finite field Fqn , then Fqn is a vector space
over Fqm , and in particular the number of elements #Fqn = qn is a power of #Fqm = qm , or
equivalently, m | n. Conversely, if m | n, then Fqn is an extension field of (an isomorphic
m
copy of) Fqm , namely the set of all roots of xq − x in Fqn . For example, F4 is a subfield
of F16 , but F8 is not, despite the fact that 8 | 16. Figure 25.2 shows the lattice of all sub-
fields of Fq12 corresponding to the lattice of divisors of 12; a field is contained in another
one if there is a path from the latter down to the former. (A different notion of “lattice” is
used in Chapter 16.)
25.5. Linear algebra 713
The order of the multiplicative group F× q is q − 1. Fermat’s little theorem implies that
ord(a) | q − 1 for all a ∈ F× × ×
q . An element a ∈ Fq is primitive if it generates the group Fq ,
× ×
or equivalently, if its order is q − 1. Fq contains a primitive element, so that Fq is cyclic
(Exercise 8.16). More generally, Fq contains an element of order n if and only if n | (q − 1)
(Lemma 8.8).
A ring R containing F p is called an F p -algebra. A fundamental property is that for any
commutative F p -algebra R, elements a, b ∈ R, and i ∈ N, we have
i i i
(a + b) p = a p + b p .
This is proved by induction on i; for i = 1, all binomial coefficients in the expansion of the
left hand power are divisible by p, and hence 0 in R. Let Fqn be an extension field of Fq .
The map
Fqn −→ Fqn
ϕ:
α 7−→ αq
is an automorphism of the finite field Fqn , called the Frobenius automorphism. The
following hold for all α, β ∈ Fqn :
(α + β)q = αq + β q , (αβ)q = αq β q ,
(1)
αq = α ⇐⇒ α ∈ Fq .
The last property, an immediate consequence of Fermat’s little theorem, says in the lan-
guage of Galois theory that Fq is the fixed field of ϕ.
Similarly, in any Fq -algebra R, we have the Frobenius endomorphism
R −→ R
ϕ: (2)
α 7−→ αq
Of particular importance is the case R = Fq [x], which also shows that ϕ is not surjective in
general.
If f ∈ Fq [x] is irreducible of degree n and α ∈ Fqn ∼ = Fq [x]/h f i is a root of f , then
f (αq ) = f (α)q = 0, so that αq is also a root of f . More generally, the roots of f in Fq n are
2 n−1
precisely the n conjugates α, αq , αq , . . . , αq of α.
In computer algebra, both the finite fields F pn and the finite commutative rings Z pn ,
each with pn elements, play a role. If n ≥ 2, then these are non-isomorphic objects, since
the former is a field while the latter has nonzero zero divisors. Another difference is that
char F pn = p and its additive group is isomorphic to Z pn , while char Z pn = pn and its additive
group is cyclic.
◦ λ · (v + w) = λ · v + λ · w,
◦ (λ + µ) · v = λ · v + µ · v,
◦ λ · (µ · v) = (λµ) · v,
for all λ, µ ∈ F and v, w ∈ V . We will write λv instead of λ · v for short. The elements of V
are called vectors, those of F scalars. The most popular example of a vector space is F n
for some n ∈ N, whose elements are n-tuples (a1 , . . . , an ) of elements a1 , . . . , an ∈ F, with
componentwise addition and scalar multiplication.
A subset U of a vector space V is a subspace of V if it is closed under addition and
scalar multiplication, so that u + v and λv are again in U for all u, v ∈ U and λ ∈ F. A fi-
nite sequence v1 , . . . , vn ∈ V of vectors is called linearly dependent if there exist scalars
λ1 , . . . , λn ∈ F, not all zero, such that λ1 v1 + · · · + λn vn = 0. Otherwise, v1 , . . . , vn are lin-
early independent. The subspace generated by the vectors v1 , . . . , vn ∈ V is the set of all
linear combinations hv1 , . . . , vn i = {λ1 v1 + · · · + λn vn : λ1 , . . . , λn ∈ F}. A vector space V is
finite-dimensional if it is generated by finitely many vectors. A finite sequence (v1 , . . . , vn )
of elements of V is a basis of V if the vectors are linearly independent and hv1 , . . . , vn i = V .
A central theorem in linear algebra is that any finitely generated vector space V has a finite
basis (and any generating sequence contains one), and that all bases have the same number
of elements, called the dimension dimV of V . For example, dim F 3 = 3, and a basis is
given by the three unit vectors (1, 0, 0), (0, 1, 0), and (0, 0, 1). More generally, we have
dim F n = n for all n ∈ N>0 . With respect to a basis (v1 , . . . , vn ) of V , every vector v has a
unique representation v = λ1 v1 + · · · + λn vn as a linear combination of the basis elements,
with coordinates λ1 , . . . , λn ∈ F.
A map f :V −→ W between two vector spaces over the same field F is (F -)linear or
a homomorphism if f (v1 + v2 ) = f (v1 ) + f (v2 ) and f (λv1 ) = λ f (v1 ) for all λ ∈ F and
v1 , v2 ∈ V . The notions endo-, iso-, and automorphism are defined similarly as for groups.
V and W are isomorphic if there exists an isomorphism between them. If V and W are
finite-dimensional, then they are isomorphic if and only if dimV = dimW . The image
im f = { f (v): v ∈ V } of a homomorphism f :V −→ W is a subspace of W , and the kernel
ker f = {v ∈ V : f (v) = 0} is a subspace of V . As for groups, f is injective if and only
if ker f = {0}, and f is surjective if and only if im f = W . An equivalent of Lagrange’s
theorem is the dimension formula for homomorphisms:
dim ker f + dim im f = dimV, (3)
if V is finitely generated.
If V and W are vector spaces over F with bases v1 , . . . , vn and w1 , . . . , wm , respectively,
then to a homomorphism f :V −→ W corresponds the m × n matrix A = (ai j ) 1≤i≤m ∈ F m×n
1≤ j≤n
defined by
f (vi ) = a1i w1 + · · · + ami wm , (4)
and then
λ1 µ1
A ... = .. ⇐⇒ f (λ v + · · · + λ v ) = µ w + · · · + µ w
. 1 1 n n 1 1 m m
λn µm
for arbitrary λi , µ j ∈ F. Conversely, for any matrix A ∈ F m×n , (4) defines a homomorphism
f :V −→ W , and the kernel and image of A are defined to be those of f . The rank of A is
25.5. Linear algebra 715
dim(im A), or equivalently, the maximal number of linearly independent columns (or rows)
of A. Composition of homomorphisms corresponds to multiplication of matrices.
A square matrix A = (Ai j )1≤i, j≤n ∈ F n×n is nonsingular (or invertible) if there exists
a matrix B ∈ F n×n such that AB = In , where In is the n × n unit matrix. Otherwise, A is
singular. We write A−1 for B. The matrix A is nonsingular if and only if the endomorphism
y 7−→ Ay of F n is an automorphism, which holds if and only if the rank of A is n. The set
of all nonsingular n × n matrices forms a group with respect to matrix multiplication.
An n × n matrix A = (ai j )1≤i, j≤n ∈ F n×n is a permutation matrix if there is a permu-
tation σ ∈ Sn such that for all i, j, we have ai j = 1 if j = σ(i) and ai j = 0 otherwise. The
set of all permutation matrices in R n×n is a finite subgroup of the multiplicative group of
invertible n × n matrices which is isomorphic to Sn .
A system of linear equations over F has the form
where a11 , a12 , . . . , amn , b1 , . . . , bm ∈ F are given and y1 , . . . , yn ∈ F are sought. The matrix
A = (ai j ) ∈ F m×n is the coefficient matrix and the vector b = (b1 , . . . , bm )T ∈ F m the
right hand side of the system, where T denotes transposition. The system may then be
written more briefly as Ay = b, where y = (y1 , . . . , yn )T is the vector of indeterminates. The
solution space {y ∈ F n : Ay = b} of the linear system is either empty or a coset (in the sense
of additive groups) v + ker A of the subspace ker A = {y ∈ F n : Ay = 0}, where v ∈ F n is any
particular solution. In the language of homomorphisms, {y ∈ F n : Ay = b} is the preimage
of b under the homomorphism f : F n −→ F m given by f (y) = Ay.
The famous Gaussian elimination algorithm provides a means for solving linear sys-
tems (and many other computational problems in linear algebra). Given a matrix A ∈ F m×n ,
Gaussian elimination computes an invertible matrix L ∈ F m×m and a permutation matrix
P ∈ F n×n such that U = LAP is of block form
Ir V
U=
0 0
where sign σ = #{1 ≤ i < j ≤ n: σ(i) > σ( j)} is the number of inversions of the permuta-
tion σ of {1, . . . , n}. The determinant is multiplicative, so that det(AB) = det A · det B for
all A, B ∈ F n×n, changes sign when two rows (or columns) are exchanged, and is invariant
under addition of a multiple of one row (or column) to another one. Moreover,
det A = 0 ⇐⇒ A is singular.
this is called Laplace expansion (or expansion into cofactors) along the ith row. Of course,
this also holds when the roles of rows and columns are exchanged.
For computing determinants, this is not useful. It is more efficient to use a variant of
Gaussian elimination which produces a matrix L ∈ F n×n with det L = 1 and a permutation
matrix P ∈ F n×n , which has det P = ±1, such that U = LAP is upper triangular, and then
det A = det L−1 detU det P−1 = ± detU is—up to sign—equal to the product of the diagonal
elements of U. This follows from repeated use of Laplace expansion.
If A ∈ F n×n is nonsingular, then the linear system Ay = b has a unique solution y ∈ F n
for any right hand side b ∈ F n , namely y = A−1 b. The following theorem is an impor-
tant theoretical application of determinants; it is not useful for the practical solution of
nonsingular systems of linear equations.
det Ai
yi = ,
det A
where Ai ∈ F n×n is the matrix A with the ith column replaced by b.
for all a ∈ C n and p > q. Besides the max-norm, the most important norms are the 1-norm
||a||1 = ∑1≤i≤n |ai | and the 2-norm (or Euclidean norm) ||a||2 = (∑1≤i≤n |ai |2 )1/2 . We have
the following relations between these three norms:
√
||a||∞ ≤ ||a||2 ≤ n||a||∞ , ||a||2 ≤ ||a||1 ≤ n||a||∞ . (5)
These norms carry over in a natural way to univariate polynomials with complex coeffi-
cients: for f = ∑0≤i≤n fi xi ∈ C[x], we write || f ||q for the q-norm of the coefficient vector
( f0 , . . . , fn ) ∈ C n+1 .
A map ⋆:V × V −→ F, where V is a vector space over a field F, is called an inner
product on V if
◦ v ⋆ v = 0 ⇐⇒ v = 0,
◦ u ⋆ v = v ⋆ u,
◦ (λu + µv) ⋆ w = λ(u ⋆ w) + µ(v ⋆ w)
hold for all u, v, w ∈ V and λ, µ ∈ F. (Not all vector spaces have such an inner product; for
example, F22 does not.) Two vectors v, w ∈ V are orthogonal (with respect to ⋆) if v ⋆ w = 0.
The most important example of an inner product on R n is (x1 , . . . , xn ) ⋆ (y1 , . . . , yn ) =
x1 y1 + · · · + xn yn , and we have v ⋆ v = ||v||22 for all v ∈ R n . For a sequence v1 , . . . , vn ∈ V
of vectors, G = (vi ⋆ v j )1≤i, j≤n ∈ F n×n is the Gramian matrix of v1 , . . . , vn , and det G is
their Gramian determinant. The vectors v1 , . . . , vn ∈ V are linearly dependent if and only
if their Gramian determinant vanishes. (Exercise 24.4).
A basis (v1 , . . . , vn ) of a vector space V is orthogonal with respect to an inner product ⋆
if its vectors are pairwise orthogonal, so that their Gramian matrix is a diagonal matrix.
The Gram-Schmidt orthogonalization procedure, described in Chapter 16, transforms
an arbitrary basis into an orthogonal one.
U = {1, 2, 3, 4, 5, 6} and P(u) = 1/6 for all u ∈ U gives a finite probability space describing
the possible outcomes of the experiment. When P(u) = 1/#U for all u, as in the example,
we say that P is a uniform probability function.
An event is a subset A ⊆ U, and the probability of A is P(A) = ∑u∈A P(u). In the above
example, the probability of the event “odd roll” A = {1, 3, 5} is 1/2. We have P(Ø) = 0,
P(U \A) = 1−P(A), and P(A∪B) = P(A)+P(B)−P(A∩B) for all A, B ⊆ U. In particular,
P(A ∪ B) = P(A) + P(B) if A and B are disjoint. We usually write prob(A) for P(A).
The conditional probability PB (A) = P(A ∩ B)/P(B) for two events A, B with P(B) 6= 0
is the probability of A under the condition that also B happens. This makes (B, PB ) into a
finite probability space. The events A and B are independent if P(A ∩ B) = P(A)P(B). In
that case, we have PB (A) = P(A) if P(B) 6= 0. In the above example, the two events A =
{u ∈ U: u is odd} = {1, 3, 5} and B = {u ∈ U: u ≤ 2} = {1, 2} are independent, while A
and C = {u ∈ U: u ≤ 3} = {1, 2, 3} are not. Intuitively, if two events are independent, then
the occurrence of one of them has no impact on the probability of the other one to happen.
A random variable X on a finite probability space (U, P) is a function X:U −→ R. The
expected value (or mean value, or average) of X is
where X = x is shorthand for the event X −1 (x) = {u ∈ U: X(u) = x}. If X(u) = u in our
running example, then the expected value of X is
1 21
E(X) = ∑ i· = = 3.5.
1≤i≤6 6 6
Finally, limn−→∞ E(Y (n) ) = 1/p, as expected, since |q| < 1 implies that limn−→∞ qn+1 = 0.
As an example, the waiting time for a 6 to be rolled with a fair die is close to 1/(1/6) = 6.
More precisely, the value of E(Y (n) ) with p = 1/6 is the expected number of rolls until a 6
shows up, if that happens with no more than n rolls, and counting n + 1 if no 6 shows up
at all. This value gets close to 6 when n is large; the difference qn+1 /(1 − q) is about 0.13
for n = 20 and about 0.6 · 10−7 for n = 100.
The probability that we need at least k ≤ n trials until A happens for the first time is
P(Y (n) ≥ k) = P(X1 = 0) · · · P(Xk−1 = 0) = qk−1
for k ≥ 1, independent of n. It is exponentially decreasing with k. For example, the proba-
bility that we need at least 10 rolls until a 6 occurs is (5/6)9 ≈ 19.38 %.
720 25. Fundamental concepts
D EFINITION 25.7. (i) A partial function f : N −→ R, that is, one that need not be de-
fined for all n ∈ N, is called eventually positive if there is a constant N ∈ N such
that f (n) is defined and strictly positive for all n ≥ N .
(ii) Let g: N −→ R be eventually positive. Then O(g) is the set of all eventually positive
functions f : N −→ R for which there exist N, c ∈ N such that f (n) and g(n) are
defined and f (n) ≤ cg(n) for all n ≥ N .
If f (n) denotes the cost for matrix multiplication as above and g(n) = n3 , we may write
f ∈ O(g). In the literature, one often finds f = O(g) or f (n) = O(n3 ) for this. The equal
sign then has unusual properties: if g(n) = n3 and h(n) = n4 , then g = O(h) and h = O(h),
but we do not want to conclude that g = h.
A slight abuse of notation is that we often write, for example, n3 ∈ O(n4 ). For each
n ∈ N, n3 is just a number and the O-notation makes little sense for single numbers. What
is meant is that g ∈ O(h), with g, h as above. Similarly, we may write f (n) ∈ O(n3 ), or
f ∈ O(n3 ). There is a notation to avoid this abuse, called the λ-calculus, but it is somewhat
clumsy and we do not use it.
For example, if f : N −→ R with f (n) = 3n4 − 300n + 1, then f (n) ∈ O(n4 ), and also
f (n) ∈ O(n5 ) (“O” does not imply “as accurate as possible”), but f 6∈ O(n3 ). An eventually
positive function h satisfies h(n) ∈ O(1) if and only if h is bounded from above. We have
f ∈ O( f ), and f ∈ O(g) and g ∈ O(h) imply that f ∈ O(h), for all eventually positive
functions f , g, h. If f : N −→ R is eventually nonzero, then we write f ∈ O(g) instead of
| f | ∈ O(g) for short. Thus, for example, −2n ∈ O(n).
Often the O is used in a more extended form, where it may appear anywhere on the
right hand side. For instance, f (n) ∈ g(n) + O(h(n)) is shorthand for f (n) = g(n) + k(n)
with some k ∈ O(h), or more briefly f − g ∈ O(h). Similarly, f (n) ∈ g(n) · O(h(n)) if
( f /g) ∈ O(h), f (n) ∈ g(n)O(h(n)) if f (n) = g(n)k(n) for some k ∈ O(h), and more generally
f (n) ∈ g(n, O(h(n))) if f (n) = g(n, k(n)) for some k ∈ O(h). If f , g: N −→ R are eventually
positive, then
◦ c · O( f ) = O( f ) for any c ∈ R>0 ,
◦ O( f ) + O(g) = O( f + g) = O(max( f , g)), where max is the pointwise maximum,
◦ O( f ) · O(g) = O( f · g) = f · O(g),
◦ O( f )m = O( f m ) for any m ∈ R>0 , where f m denotes the function for which f m (n) =
f (n)m (and not f ( f (· · · f (n) · · ·))), and
| {z }
m
◦ f (n) ∈ g(n)O(1) ⇐⇒ f is bounded by a polynomial in g.
25.8. Complexity theory 721
All equations are equations of sets, so for example O( f ) + O(g) is shorthand for the set
{h + k: h ∈ O( f ) and k ∈ O(g)}.
We use logarithms in O-expressions without explicit reference to a base, and the reader
may always think of some fixed base such as 2 or e.
Be cautious with exponentiation of O! At first glance, you might consider eO( f ) = O(e f )
to be valid. But we have e2n ∈ eO(n) , and yet e2n = (en )2 6∈ O(en ). The constant hidden
within the “O” does influence the rate of growth when it occurs as an exponent.
We often also use the O-notation for functions g of two or three arguments, in the fol-
lowing sense. A partial function g: N × N −→ R is eventually positive if there is a constant
N ∈ N such that g(m, n) is defined and positive for all m, n ≥ N. For such a function g,
O(g) is the set of all eventually positive functions f : N × N −→ R for which there exist
N, c ∈ N such that f (m, n), g(m, n) are defined and f (m, n) ≤ cg(m, n) for all m, n ≥ N, and
similarly for ternary functions.
In some situations, the “O” carries still too much information. For instance, the fast
algorithm for multiplying two integers of length n uses O(n log n loglog n) word operations
(Section 8.3), and hence is, up to logarithmic factors, essentially a linear algorithm like the
addition algorithm for n-word integers.
Thus n log n loglog n ∈ O∼ (n), and the ugly log-factors are swallowed by the “soft Oh”.
We use terminology like “quadratic time” for O(n2 ), and “softly linear time” for O∼ (n).
and the same bound holds for the rejection probability of an x ∈ I \ X. Furthermore, X ∈
BPP if and only if its complement I \ X is in BPP.
The complexity class RP (“random polynomial time”) consists of those decision prob-
lems X for which there exists a polynomial-time Turing machine which, given an instance
x ∈ I of X and a random bit string of length polynomial in λ(x), does the following. If
x ∈ X, then it accepts x with probability at least 1/2, while if x 6∈ X, then it always rejects x.
The difference to the definition of BPP is that a BPP machine is allowed to make mis-
takes both in accepting instances not in X and in rejecting instances in X, while an RP
machine is not allowed to accept instances not in X. A standard trick is to run such an
algorithm k times and accept if and only if one of the runs accepts; then an element in X
will be accepted with probability at least 1 − 2−k . Furthermore, we define co-RP to consist
of those problems X whose complement I \ X is in RP. An RP Turing machine is also
called a one-sided Monte Carlo Turing machine.
The class ZPP = RP ∩ co-RP (“zero-error probabilistic polynomial time”) consists of
those problems for which probabilistic polynomial-time algorithms exist that always give
the right answer; their running time is a random variable with a certain mean t (polynomial
in the input length) and exponential decay: prob(time ≥ at) ≤ 2−a . The only problem
in this class that is not known to be already in P is treated extensively in this text: (the
decision version of) factoring polynomials over finite fields. A ZPP Turing machine is
also called a Las Vegas Turing machine. We have P ⊆ ZPP, since every deterministic
algorithm is also a probabilistic one (that just does not use any random bits).
The class NP (“non-deterministic polynomial time”), introduced by Cook (1971) and
Karp (1972), comprises those problems X that have a non-deterministic polynomial-time
solution, so that there exists a deterministic polynomial-time Turing machine M such that
for all x ∈ I we have x ∈ X if and only if there exists a bit string y of length polynomial in
λ(x) such that M accepts (x, y). (“Non-deterministic” does not mean “not deterministic”;
taking the empty string for y shows that P ⊆ NP.) The only known simulations of M on a
realistic computer try all exponentially many possibilities for y, and it is the most important
open problem in theoretical computer science to prove Cook’s hypothesis that P = 6 NP.
The class co-NP consists of those X for which I \ X ∈ NP.
A (Turing-)reduction from a problem X to a problem Y is a deterministic polynomial-
time algorithm (Turing machine) for X that may use an (unspecified) subroutine for decid-
ing membership in Y . If such a reduction exists, then X is (polynomial-time) reducible
to Y ; this implies that X is not harder to solve than Y (in the sense of polynomial time). If
also Y is reducible to X, then they are (polynomial-time) equivalent.
A decision problem X is C-hard for a complexity class C if every problem in C is
reducible to it, and C-complete if in addition X ∈ C. The C-complete problems are the
“hardest” ones in C. Cook’s hypothesis implies that the NP-complete problems cannot
be solved in polynomial time. His first example were satisfiable formulas of propositional
calculus (see Section 24.1), and the subset sum problems of Section 17.1 are also NP-
complete. The classic by Garey & Johnson (1979) lists over 1000 such problems.
25.8. Complexity theory 723
EX PEX PT IME
EX PSPA CE
EX PT IME
PSPA CE
co-NP
co-RP NP ∩ co-NP
NP
ZPP
RP
P
For the classes EX PT IME and EX PEX PT IME, one allows the algorithms to take
exponential and doubly-exponential time, respectively, that is,
O(1) nO(1)
time 2n and 22 , respectively,
on inputs of length n. Such algorithms can be run in practice only for rather small values
of n.
In space bounded complexity classes, one limits the number of memory cells used by
algorithms. The read-only input cells and the write-only output cells are not counted, but
only the essential work cells. This leads to the classes PSPA CE and EX PSPA CE, with
polynomially and exponentially bounded work space, respectively.
The relations between the various complexity classes described above are illustrated
in the “complexity onion” of Figure 25.3. Clearly RP ⊆ BPP ∩ NP and co-RP ⊆
BPP ∩ co-NP, but no “nice” inclusion for BPP in these classes is known, except that
724 25. Fundamental concepts
BPP ⊆ PSPA CE. The feasible problems, for which algorithms exist that can handle in-
puts up to a “reasonable” size, are those in BPP and smaller classes. (This statement has to
be taken with a grain of salt.) The first two thirds of this book (up to Chapter 18) deal with
such problems. Sometimes an effort is required to show that they are in ZPP (for poly-
nomial factorization over finite fields) or P (P RIMES and Gaussian elimination over Q),
and sometimes they are clearly in P and our effort goes into reducing the time from O(n2 )
to O∼ (n), say (for multiplication, division with remainder, etc.). The later chapters treat
problems that are not known to be in BPP. For their solutions, there are reasonably small
inputs (say, a 400-digit integer to be factored) for which all known methods take more time
than is feasible in practice. But still, experience so far gives rise to the hope that improved
algorithms (and hardware) will increase the range of interesting solvable problems further
and further.
Notes. 25.2. Proposition 30 in Book 7 of Euclid’s Elements shows that prime numbers
are irreducible. Gauß (1831, 1863c) showed that O−1 = Z[i] and O−3 are Euclidean.
Hendrik Lenstra (1979a, 1980a, 1980b) studied Euclidean number fields in detail, and
Lemmermeyer (1995) provides an exhaustive discussion.
25.3. Gauß (1863a), article 243, proved Lemma 25.4 (ii) for R = Z p , where p is a prime.
25.4. Galois (1830) laid the foundations of the theory of finite fields. They are often called
Galois fields, and GF(q) is a common notation for our Fq .
25.5. See Notes 5.5 for Gauß’ elimination procedure. Laplace (1772), chapter IV, gives his
determinant expansion; it is also in Bézout (1764), pages 293 ff. Cramer (1750), Appendice
No I, page 658, states his rule.
25.7. The “big Oh” notation was introduced by Paul Bachmann and Edmund Landau in
number theory at the end of the 19th century, and popularized in computer science by
Don Knuth (1970). Von zur Gathen (1985) and Babai, Luks & Seress (1988) invented the
“soft Oh” notation.
25.8. Ulam used a randomized method to estimate the success probability in the card game
solitaire and apparently coined the term Monte Carlo . Levin (1973) also introduced the
class NP. Babai (1979) invented the designation Las Vegas algorithm. See Notes 6.5.
The best known upper bound for BPP appears to be BPP ⊆ MA ⊆ Σ2p ∩ Π2p ; Johnson
(1990) gives more detailed information about complexity classes.
Exercises for this chapter can be found on the book’s web page.
Sources of illustrations
Page 14: Désirée von zur Gathen twisting a plastic model of cyclohexane.
Page 23: First page of Euclid’s Elements , printed 1482 by Erhard Ratdolt in Venice. University Library, Basel.
Reproduced with kind permission.
Page 25: Miniature from the manuscript Agrimensorum on Roman land surveyors, 6th century AD. Possibly
represents Euclid. Courtesy Herzog–August–Bibliothek, manuscript 2403, Wolfenbüttel.
Page 217: Portrait of Isaac Newton by Sir Godfrey Kneller, 1689. Courtesy of the Trustees of the Portsmouth
Estates.
Page 219: One pound UK banknote (in circulation until 1988) depicting Isaac Newton. Reproduced with kind
permission of the Bank of England.
Pages 365 ff.: Schloß Neuhaus in Paderborn. Residence of Bishop Ferdinand von Fürstenberg (see page 513).
Page 371: Portrait of Carl Friedrich Gauß. Oil painting by Gottlieb Biermann (1824–1908), a copy made in
1887 of a portrait executed by Christian Albrecht Jensen (1792–1870) in 1840. Lecture Hall in the Sternwarte
(observatory), Göttingen. Reproduced with kind permission of the Universitäts-Sternwarte Göttingen.
Page 373: German 10 DM banknote, using a mirror-image of the portrait on page 371. Designed by Reinhold
Gerstetter. In circulation from 16 April 1991 to 31 December 2001. Reproduced with kind permission of
Deutsche Bundesbank.
Page 511: Marble statue of Pierre Fermat with muse, by Théophile Barrau, 1898. Inscription: Fermat. Inventeur
du calcul différentiel. 1585[sic!]–1665. Salle des illustres, Capitole, Toulouse.
Page 512: Engraving of Pierre Fermat by François Poilly. From Varia Opera, Toulouse, 1679.
Page 513: Dedication by Samuel Fermat to Ferdinand von Fürstenberg, Bishop of Paderborn, in the Varia Opera,
Toulouse, 1679.
Page 585: Portrait of David Hilbert. Lecture Hall in the Mathematisches Institut, Universität Göttingen.
Reproduced with kind permission of Mathematisches Institut der Georg-August-Universität, Göttingen.
Page 587: Signed photograph of David Hilbert. Apparently taken by the photographer August Schmidt. This
was one in a series of popular postcards Portraits Göttinger Professoren. Hrsg. von der Göttinger Freien
Studentenschaft. Nr. 13. Acquired by the library in 1915. Courtesy Niedersächsische Staats- und
Universitätsbibliothek, Göttingen.
All photographs except those on pages 25, 217, and 587
1999c by Joachim von zur Gathen.
Sources of quotations
Introduction (page 0): William Shakespeare (1564–1616), King Henry VIII, 1.1.123. The Works, Jacob
Tonson, London, 1709, vol. 4, p. 1725. Lord Francis Bacon (1561–1626), Essays, Of Studies, 1597. Reprinted
by Henry Altemus Company, Philadelphia PA, c. 1900, p. 201. Anonymous referee, Bulletin des sciences
mathématiques Férussac 3 (1825), p. 77. Isaac Newton (1642–1727), Universal Arithmetick: or, A Treatise of
Arithmetical Composition and Resolution, translated by the late Mr. Raphson and revised and corrected by Mr.
Cunn, London, 1728, Preface To The Reader. Translation of Arithmetica Universalis, sive de compositione et
resolutione arithmetica liber, 1707. Reprinted in: Derek T. Whiteside, The mathematical works of Isaac Newton,
vol. 2, Johnson Reprint Co, New York, 1967, pp. 4–5. Ghiyāth al-Dı̄n Jamshı̄d bin Mas֒ūd bin Mah.mūd
al-Kāshı̄ (c. 1390–c. 1448), H. AmÌ '@ hAJ®Ó (miftāh. al-h.isāb, The key to computing ), written in 1427. Manuscript
copied in 1645, now in the Preußische Staatsbibliothek, Berlin, edited by Luckey (1951), p. 128, lines 15–17.
Chapter 1 (page 10): Arthur C. Clarke (*1917). An article by Jeremy Bernstein in the New Yorker of 9 Au-
gust 1969 mentions Clarke’s Third Law as being most recently formulated and which he made use of in writing the
enigmatic ending of “2001”. Napoléon I. Bonaparte (1769–1821). Correspondance de Napoléon, t. 24, p. 131,
letter 19 028, 1 August 1812, Vitebsk, to Laplace. Imprimerie Royale, Paris, 1868. Augusta Ada Lovelace
(1815–1852), Sketch of the Analytical Engine Invented by Charles Babbage, Esq., by L. F. Menabrea (translated
and with notes by “A. A. L.”). Taylor’s Scientific Memoirs 3 (1843), Article XXIX, 666–731. Reprinted in Bab-
bage’s Calculating Engines, E. and F. N. Spon, London, 1889, 4–50, p. 23. Reprinted in The Charles Babbage
Institute Reprint Series for the History of Computing, vol. II, Tomash Publishers, Los Angeles/San Francisco CA,
1982. Robert Ludlum (*1927), Apocalypse Watch, Bantam paperback, 1996, ch. 8, p. 135. Reprinted with kind
permission of Bantam Books, a divison of Bantam, Doubleday, Dell Publishing Group, Inc., New York. Eric
Temple Bell (1883–1960), Men of Mathematics I, ch. 1: Introduction, Penguin Books, 1937, p. 2.
Chapter 2 (page 28): Leopold Kronecker (1823–1891), Vortrag bei der Berliner Naturforscher-Versamm-
lung, 1886. Quoted by H. Weber, Leopold Kronecker, Jahresberichte der Deutschen Mathematiker Vereinigung 2
725
726 Sources of quotations
(1891/92), p. 19. Also quoted by David Hilbert, Neubegründung der Mathematik, Abhandlungen aus dem Mathe-
matischen Seminar der Hamburger Universität 1 (1922), p. 161. Lewis Carroll (Rev. Charles Lutwidge Dodgson)
(1832–1898), Alice’s Adventures in Wonderland, Macmillan and Co., London, 1865, Ch. 9: The mock turtle’s
story. Reprinted by Avon, The Heritage Press, 1969. Isaac Newton (1642–1727), Universal Arithmetick: or,
A Treatise of Arithmetical Composition and Resolution, translated by the late Mr. Raphson and revised and
corrected by Mr. Cunn, London, 1728, p. 1. Translation of Arithmetica Universalis, sive de compositione et
resolutione arithmetica liber, 1707. Reprinted in: Derek T. Whiteside, The mathematical works of Isaac New-
ton, vol. 2, Johnson Reprint Co, New York, 1967, pp. 6–7. Stanisław Marcin Ulam (1909–1984), Computers,
Scientific American, September 1964, 203–216. Reprinted with kind permission. Also reprinted in Science,
Computers, and People, Birkhäuser, Boston, 1986, p. 43. Marcus Tullius Cicero (106–43 BC), Tusculanae Dis-
putationes, Liber primus, II.5. Opera Omnia, Lugdunus, Sumptibus Sybillæ à Porta, 1588, vol. 4, p. 165. Robert
Louis Stevenson (1850–1894), The Master of Ballantrae, Collins, London and Glasgow, 1889, p. 51. State of
California, Instructions for Form 540 NR, California Nonresident or Part-Year Resident Income Tax Return,
1996, p. 3.
Chapter 3 (page 44): Godfrey Harold Hardy (1877–1947), A Mathematician’s Apology, Cambridge Uni-
versity Press, 1940, ch. 8, p. 21. Robert Recorde (c. 1510–1558), The Whetstone of Witte, The seconde parte
of Arithmetike, London, 1557. Murray Gell-Mann (*1929), The Quark and the Jaguar, Abacus, London, 1994,
ch. 9: What is fundamental, p. 109. Reprinted with kind permission from Little, Brown, London and Murray Gell-
Mann, Santa Fe NM. Robert Boyle (1627–1691), Some Considerations touching the Usefulness of Experimental
Natural Philosophy, vol. 2, The Usefulness of Mathematicks to Natural Philosophy ; Oxford, 1671. The Works,
ed. by Thomas Birch, vol. 3, London, 1772, p. 426. Augustus De Morgan (1806–1871), Smith’s Dictionary of
Greek and Roman Biography and Mythology, London, c. 1844, Article “Eucleides”, 63–75, p. 63.
Chapter 4 (page 68): Novalis (Friedrich Leopold Freiherr von Hardenberg) (1772–1801), Materialien zur
Encyclopädie. In: Schriften, hrsg. Ernst Heilbronn, Teil 2, Georg Reimer, Berlin, 1901, p. 549. Karl Theodor
Wilhelm Weierstraß (1815–1897), letter to Sonja Kowalevski, 27 August 1883. See Gustav Magnus Mittag-
Leffler: Une page de la vie de Weierstrass, Compte rendu du deuxième congrès international des mathématiciens
(Paris, 1900), Gauthiers-Villars, Paris, 1902, p. 149. David Hume (1711–1776), A Treatise of Human Nature,
John Noon, London, 1739, Part III: Of Knowledge and Probability, Sect. I: Of Knowledge. Augustus De Morgan
(1806–1871), Elements of Algebra, London, 1837, Preface. Abū Ja֒far Muh.ammad bin Mūsā al-Khwārizmı̄
(c. 780–c. 850), éÊK. A®ÒË@ ð QJ.m.Ì '@ H
. Ak ú¯ QåJjÒË@ H. AJºË@ (al-kitāb al-mukhtas.ar fı̄ h.isāb al-jabr wa-l-muqābala,
The concise book on computing by moving and reducing terms ), often called Algebra, c. 825, marginal note
to p. 51 (51) and pp. 299–300 of Rosen’s (1831) edition. Manuscript in the Bodleian Library at Oxford, UK,
transcribed in 1342, edited by Frederic Rosen.
Chapter 5 (page 96): Eric Temple Bell (1883–1960), Men of Mathematics I, ch. 2: Modern minds in ancient
bodies, Penguin Books, 1937, p. 33. James Joseph Sylvester (1814–1897), Proof of the Fundamental Theorem
of Invariants, Philosophical Magazine (1878), p. 186. Collected Mathematical Papers, vol. 3, p. 126. Gottfried
Wilhelm Freiherr von Leibniz (1646–1716), Untitled and unpublished manuscript, Hannover Library. From:
Gottfried Wilhelm Leibniz, Opera philosophica, ed. Johann Eduard Erdmann, 1840, XI. De scientia universali
seu calculo philosophico (title by Erdmann). Reprint Scientia Verlag, Aalen, 1974, p. 84. Augustus De Morgan
(1806–1871), Study and Difficulties of Mathematics, Society for the Diffusion of Useful Knowledge, 1831,
chap. 12, On the Study of Algebra. Fourth Reprint Edition, Open Court Publishing Company, La Salle IL, 1943,
p. 176.
Chapter 6 (page 140): Godfrey Harold Hardy (1877–1947), A Mathematician’s Apology, Cambridge Uni-
versity Press, 1940, ch. 10, p. 25. David Hilbert (1862–1943), Mathematische Probleme, Nachrichten von der
Königlichen Gesellschaft der Wissenschaften zu Göttingen (1900), 253–297. Archiv für Mathematik und Physik,
3. Reihe 1 (1901), 44–63 and 213–237. Gesammelte Abhandlungen, Springer Verlag, 1970, 290–329, p. 294.
Reprinted with kind permission. Johann Wolfgang von Goethe (1749–1832), Wilhelm Meisters Wanderjahre,
Zweites Buch; Betrachtungen im Sinne der Wanderer: Kunst, Ethisches, Natur. Thomas Edward Lawrence
(1888–1935), Seven Pillars of Wisdom, George Doran Publishing Co., 1926. Book III: A railway diversion,
ch. XXXIII. Reprint by Anchor Books, Doubleday, New York, 1991, p. 192.
Chapter 7 (page 208): Oliver Cromwell (1599–1658), Letter C (= 100), to Richard Mayor, father of Crom-
well’s daughter-in-law, written off Milford Haven, 13th August 1649. In: Thomas Carlyle, Oliver Cromwell’s
Letters and Speeches, vol. II, Chapman and Hall, London, 1845, p. 41. John Locke (1632–1704), An Essay
concerning Humane Understanding: in Four Books, Thomas Basset, London, 1690, Bk. 4: Of Knowledge and
Opinion, chap. 3: Of the extent of human knowledge, sect. 18. John Cougar Mellencamp (*1951), CD Big
Daddy, J. M.’s Question, Mercury Records, Copyright
c Full Keel Music Co. Rights for Germany, Austria,
Switzerland and Eastern Europe except Lithuania, Latvia, and Estonia by Heinz Funke Musikverlag GmbH,
Berlin. Reprinted with kind permission of Heinz Funke Musikverlag GmbH, Berlin. Michael Crichton (*1942),
The Lost World. Ballantine Books, Random House, Inc., New York, 1996, ch. Raptor, pp. 82–83. Reprinted with
kind permission of Alfred A. Knopf Incorporated, New York, and Random House, Inc., New York. Immanuel
Kant (1724–1804), Über Pädagogik (A. Von der physischen Erziehung). Notes on his lectures on pedagogy
Sources of quotations 727
between 1776 and 1787, published 1803 by Friedrich Theodor Rink. Werke, hrsg. Karl Rosenkranz und Friedrich
Wilhelm Schubert, Band 9, Leopold Voss, Leipzig, 1838, 367–439, p. 409.
Chapter 8 (page 220): Richard Phillips Feynman (1918–1988), Surely You’re Joking, Mr. Feynman. Ad-
ventures of a Curious Character. With Ralph Leighton. W. W. Norton Inc., 1984. Paperback: Vintage, 1992,
p. 100. Reprinted with kind permission of W. W. Norton & Company. Inc., New York and Random House
UK Limited, London. John le Carré (David John Moore Cornwell) (*1931), The Russia House, Hodder &
Stoughton, 1989, ch. 8, p. 160. Reprinted by kind permission of David Higham Associates Limited, London.
Arnold Schönhage (*1934), Andreas F. W. Grotefeld, Ekkehard Vetter, Fast Algorithms: A Multitape Tur-
ing Machine Implementation, BI-Wissenschaftsverlag, Mannheim, 1994, p. 284.
c Spektrum Akademischer
Verlag, Heidelberg. Reprinted with kind permission. Ernst Mach (1836–1916), Populär-wissenschaftliche Vor-
lesungen. Barth, Leipzig, 1896. 13. Vorlesung: Die ökonomische Natur der physikalischen Forschung, 217–244,
pp. 228–229. Reprinted by Böhlau Verlag Wien, Köln, Graz 1987. English translation by McCormack, Popular
Scientific Lectures, Open Court Publishing Company, La Salle IL, 1895.
Chapter 9 (page 256): Isaac Newton (1642–1727), Saying attributed to Newton. Robert Edler von Musil
(1880–1942), Der mathematische Mensch, 1913. Gesammelte Werke, Band II, hrsg. Adolf Frisé, Rowohlt,
1978, p. 1006. Copyright
c 1978 by Rowohlt Verlag GmbH, Reinbek. Reprinted with kind permission. Carl
Friedrich Gauß (1777–1855), Announcement of Theoria residuorum biquadraticorum, Commentatio secunda ;
Göttingische Gelehrte Anzeigen (1831). Werke II, Königliche Gesellschaft der Wissenschaften, Göttingen, 1863,
169–178, pp. 177–178. Reprinted by Georg Olms Verlag, Hildesheim New York, 1973. Alfred North White-
head (1861–1947), An Introduction to Mathematics, Ch. 5: The Symbolism of Mathematics, Oxford University
Press, 1911, pp. 39–40. Reprinted by kind permission of Oxford University Press, New York. Abū Ja֒far
Muh.ammad bin Mūsā al-Khwārizmı̄ (c. 780–c. 850), Algorithmi de numero Indorum, often called Arithmetic,
c. 830. 13th century Latin manuscript from the library of the Hispanic Society of America, New York. It is
probably a copy of a 12th century Latin translation of al-Khwārizmı̄’s book on arithmetic whose original is lost.
It was written after his Algebra. The recently discovered manuscript was edited by Folkerts (1997). Quote from
end of Chapter 7, Plate 8 (f. 20v) and p. 70. Crossley & Henry (1990) translate the Latin text of another surviving
manuscript, at Cambridge.
Chapter 10 (page 294): James William Cooley (*1926), The Re-Discovery of the Fast Fourier Transform
Algorithm, Mikrochimica Acta (Wien) 3 (1987), 33–45. Reprinted with kind permission of Springer-Verlag,
Wien. Voltaire (François-Marie Arouet) (1694–1778), Questions sur l’Encyclopédie, Article “Imagination”,
1771. Reprinted in Dictionnaire de la pensée de Voltaire par lui-même, Éditions Complexe, 1994, p. 604. Pierre
Simon Laplace (1749–1827), Théorie analytique des probabilités, Courcier, Paris, 1812. Œuvres, Paris, 1847,
t. 7, p. 131. James Joseph Sylvester (1814–1897), On the explicit values of Sturm’s quotients, Philosophical
Magazine 6 (1853), 293–296. Mathematical Papers, vol. 1, p. 637–640.
Chapter 11 (page 312): Leslie Gabriel Valiant (*1949), Circuits of the Mind, Oxford University Press,
1994, p. ix. Copyright
c 1994 by Oxford University Press. Reprinted with kind permission of Oxford Univer-
sity Press, Inc. Charles Babbage (1792–1871), Passages from the Life of a Philosopher, Chapter VIII: Of the
Analytical Engine. Reprinted in Babbage’s Calculating Engines, E. and F. N. Spon, London, 1889, 154–283,
p. 167. Reprinted in The Charles Babbage Institute Reprint Series for the History of Computing, vol. II, Tomash
Publishers, Los Angeles/San Francisco CA, 1982. Plato (c. 428–c. 347 BC), Πολιτεια (Republic ), Book 7,
chap. 8.
Chapter 12 (page 334): Iosif Semenoviq Iohvidov, Gankelevy i teplicevy matricy
i formy, §18. Obrawenie teplicevyh i gankelevyh matric, Nauka, 1974, p. 171. English
translation by G. Philipp A. Thijsse: I. S. Iohvidov, Hankel and Toeplitz Matrices and Forms, §18. Inversion of
Toeplitz and Hankel matrices, Birkhäuser, Basel, 1982, p. 147. Reprinted with kind permission of Birkhäuser
Verlag AG, Basel, Switzerland. James Joseph Sylvester (1814–1897), On the relation between the minor deter-
minants of linearly equivalent quadratic functions, Philosophical Magazine 1 (1851), 295–305, p. 300. Collected
Mathematical Papers 1, 241–250, pp. 246–247. René Descartes (1596–1650), Discours de la Méthode, troisième
partie, 1637.
Chapter 13 (page 358): Emil Luckhardt, German version of the Internationale. Original French version
1871 by Eugène Pottier (Paris, 1816–1887), music 1888 by Pierre-Chrétien Degeyter (or de Geyter, Lille, 1848–
1932). Jean Baptiste Joseph Fourier (1768–1830), Théorie Analytique de la Chaleur, Firmin Didot Frères,
Paris, 1822. Discours Préliminaire, p. xxii. Felix Klein (1849–1925), Elementarmathematik vom höheren
Standpunkte aus, Band II, Springer, Leipzig, 1909. Also: Grundlehren der Mathematik 15, 1925, Springer, Berlin,
p. 206.
c Springer-Verlag, Heidelberg. Reprinted with kind permission. Johann Wolfgang von Goethe (1749–
1832), Maximen und Reflexionen, Aus dem Nachlass, Sechste Abtheilung, No. 1279. Mark Twain (Samuel
Longhorne Clemens) (1835–1910), A Tramp Abroad, Vol. 2, Appendix D: The awful German language. Harper
& Brothers Publishers, New York and London, 1897.
Chapter 14 (page 376): Zhuojun Liu and Paul Shyh-Horng Wang, Height as a Coefficient Bound for
Univariate Polynomial Factors, Part I, SIGSAM Bulletin 28(2) (1994), ACM Press, 20–27. Reprinted with kind
permission of ACM Publications. Maurice Borisovitch Kraïtchik (1882–1957), Théorie des Nombres, Tome II,
728 Sources of quotations
Gauthier-Villars et Cie., Paris, 1926, Avant-propos, pp. iii–iv. Évariste Galois (1811–1832), Sur la théorie des
nombres, Bulletin des sciences mathématiques Férussac 13 (1830), 428–435. See Galois (1830). Hermann
Hankel (1839–1873), Die Entwicklung der Mathematik in den letzten Jahrhunderten, 2. Auflage, Fues’sche
Sortiment Buchhandlung Tübingen, 1885, p. 25. Tom Clancy (*1947), Debt of Honor, G. P. Putnam’s Sons,
New York, 1994, ch. 44 . . . from one who knows the score . . ., p. 687.
Chapter 15 (page 432): Charles Davies, University Algebra, Barnes & Co., New York, 1867, p. 41. Pierre
Simon Laplace (1749–1827), Théorie analytique des probabilités, Courcier, Paris, 1812. Œuvres, Paris, 1847,
t. 7, p. 156.
Chapter 16 (page 472): Joseph Liouville (1809–1882), Œuvres mathématiques d’Évariste Galois, Journal
de mathématiques pures et appliquées 9 (1846), 381–444, p. 382. Sue Taylor Grafton (*1940), “A” is for Alibi,
Bantam Books, 1987, ch. 9, p. 71. Holt, Rinehart & Winston 1982. Philip Friedman, Inadmissible Evidence,
Ivy Books, published by Ballantine Books, 1992, ch. 22, p. 224.
c Random House, Inc., New York. Reprinted
with kind permission.
Chapter 17 (page 502): Voltaire (François-Marie Arouet) (1694–1778), Questions sur l’Encyclopédie, Ar-
ticle “Géométrie”, 1771. Reprinted in Dictionnaire de la pensée de Voltaire par lui-même, Éditions Complexe,
1994, p. 479. Napoléon I. Bonaparte (1769–1821). Correspondance de Napoléon, t. 2, letter 1231, 15 frimaire 5
= 5 December 1796, to Lalande. Imprimerie Royale, Paris, 1868. Robert Recorde (c. 1510–1558), The Whet-
stone of Witte, London, 1557.
Chapter 18 (page 516): Adrien-Marie Legendre (1752–1833), Théorie des nombres, Firmin Didot Frères,
Paris, 1830. 4e édition, Hermann, Paris, 1900, p. 70. The Rolling Stones, UK: LP The Rolling Stones, 26 April
1964; USA: LP England’s Newest Hit Makers, 1964. Composers: Eddie Holland/Lamont Dozier/Brian Hol-
land. Stanisław Marcin Ulam (1909–1984), Computers, Scientific American, September 1964, 203–216, p. 207.
Reprinted with kind permission. Also reprinted in Science, Computers, and People, Birkhäuser, Boston, 1986,
p. 48. Edgar Allan Poe (1809–1849), The Mystery of Marie Rogêt. Snowden’s Ladies’ Companion, Novem-
ber and December 1842 and February 1843, pp. 15–20, 93–99, 162–167. Collected Works, ed. Thomas Ollive
Mabbott, Harvard University Press, Cambridge MA, 1978, 723–774. Maj Sjöwall (*1935) and Per Wahlöö
(1926–1975), Mannen på balkongen, ch. 24, P. A. Norstedt & Söner, 1967. English translation: The Man On The
Balcony, Random House, New York, 1968. Reprinted with kind permission of Norstedts Förlag AB, Stockholm.
Chapter 19 (page 540): Carl Friedrich Gauß (1777–1855), Disquisitiones Arithmeticae, Duae methodi
numerorum factores investigandi. Article 329, p. 401. Carl Friedrich Gauß, Review of Ladislaus Chernac,
Cribrum Arithmeticum, 1811, in Göttingische Gelehrte Anzeigen (1812). Werke II, Königliche Gesellschaft
der Wissenschaften, Göttingen, 1863, p. 182. Reprinted by Georg Olms Verlag, Hildesheim New York, 1973.
Daniel W. Fish, The Complete Arithmetic, ch. Factoring, §162. Ivison, Blakeman, Taylor & Co, New York and
Chicago, 1874, p. 81. Maurice Borisovitch Kraïtchik (1882–1957), Théorie des nombres, Tome II, Gauthier-
Villars et Cie., Paris, 1926, chap. XII, p. 144. Richard Phillips Feynman (1918–1988), Surely You’re Joking,
Mr. Feynman. Adventures of a Curious Character. With Ralph Leighton. W. W. Norton Inc., 1984. Paperback:
Vintage, 1992, p. 77. Reprinted with kind permission of W. W. Norton & Company. Inc., New York and Random
House UK Limited, London.
Chapter 20 (page 572): Godfrey Harold Hardy (1877–1947), A Mathematician’s Apology, Cambridge Uni-
versity Press, 1940, ch. 28, p. 80. David Hilbert (1862–1943), Naturerkennen und Logik, Naturwissenschaften
(1930), 959–963. Gesammelte Abhandlungen, Springer-Verlag 1970, Teil 3, 378–387, p. 386.
c Springer-
Verlag, Heidelberg. Reprinted with kind permission. Abraham Adrian Albert (1905–1972), Some Mathemat-
ical Aspects of Cryptography, Invited address, AMS Meeting in Manhattan KS on 22 November 1941. Collected
Mathematical Papers 2, AMS, Providence RI, 1993, 903–920. Reprinted with kind permission of American
Mathematical Society. Sir Arthur Conan Doyle (1859–1930), The Sign of the Four; or, The Problem of the
Sholtos, Lippincott’s Magazine, February 1890. Also The Sign of Four, Chapter 1, Spencer Blackett, London,
1890. Philip Friedman, Grand Jury, ch. 14, Ivy Books, Random House, Inc., New York, 1996. Tom Clancy
(*1947), The Cardinal of the Kremlin, ch. 18: Advantages, Harper Collins Publisher, London, 1988.
Chapter 21 (page 590): Joseph Louis Lagrange (1736–1813), Leçons élémentaires sur les Mathématiques,
Leçon Cinquième: Sur l’usage des courbes dans la solution des Problèmes, École Polytechnique, Paris, 1795.
Journal de l’École Polytechnique, VIIe et VIIIe cahiers, tome 2, 1812. Œuvres, publiées par J.-A. Serret,
Gauthiers-Villars, Paris, 1877, t. 7, 183–288, p. 271. Étienne Bézout (1739–1783), Recherches sur le degré
des équations résultantes de l’évanouissement des inconnues, Histoire de l’académie royale des sciences, 1764,
288–338, pp. 290–291. Francis Sowerby Macaulay (1862–1937), The Algebraic Theory of Modular Systems,
Introduction, Cambridge University Press, 1916, p. 2.
Chapter 22 (page 622): Ludwig Boltzmann (1844–1906), Gustav Robert Kirchhoff, Festrede, Graz, 15.11.
1887. Reprinted in: Ludwig Boltzmann, Populäre Schriften, eingeleitet und ausgewählt von Engelbert Broda,
Friedr. Vieweg & Sohn, Braunschweig/Wiesbaden, 1979, 47–53, p. 50. Reprinted with kind permission of Friedr.
Vieweg & Sohn, Wiesbaden. Marius Sophus Lie (1842–1899), Zur allgemeinen Theorie der partiellen Differ-
entialgleichungen beliebiger Ordnung, Leipziger Berichte 47 (1895), Math.-phys. Classe, 53–128, p. 53. Gesam-
melte Abhandlungen, herausgegeben durch Friedrich Engel und Poul Heegaard, B. G. Teubner, Leipzig, 1929,
Sources of quotations 729
vol. 4, p. 320. Augustus De Morgan (1806–1871), On Divergent Series, and various Points of Analysis con-
nected with them. Transactions of the Cambridge Philosophical Society 8 (1844), 182–203, p. 188. George
Berkeley (1684–1753), The Analyst, J. Tonson, London, 1734, sect. 7. William Shanks (1812–1882), Contri-
butions to Mathematics, comprising chiefly the Rectification of the Circle to 607 places of decimals, G. Bell,
London, 1853, p. vi. Excerpt reprinted in Berggren, Borwein & Borwein (1997), 147–161.
Chapter 23 (page 644): Joseph Rudyard Kipling (1865–1936), To the True Romance, In Many Inventions,
MacMillan, London, 1893. James Gleick (*1954), Genius: The life and science of Richard Feynman, Vintage
Books, Random House, Inc., New York, 1992, Prologue, p. 7.
c Random House, Inc., New York. Reprinted
with kind permission. Eric Temple Bell (1883–1960), Men of Mathematics I, ch. 9: Analysis incarnate (Euler),
Penguin Books, 1937, p. 152. George Eyre Andrews (*1938), q-series: Their Development and Application in
Analysis, Number Theory, Combinatorics, Physics, and Computer Algebra, AMS Regional Conference Series in
Mathematics 66, American Mathematical Society, 1986, p. 87. Reprinted with kind permission of the American
Mathematical Society.
Chapter 24 (page 676): Alfred North Whitehead (1861–1947), An Introduction to Mathematics, Oxford
University Press, 1911, p. 71. Reprinted with kind permission. Jean le Rond D’Alembert (1717–1783), Quoted
in Edward Kasner, The present problems of geometry, Bulletin of the American Mathematical Society 11 (1905),
283–314, p. 285. Charles Babbage (1792–1871), On the Theoretical Principles of the Machinery for Calculat-
ing Tables, Letter to Dr. Brewster, 6 November, 1822. Appeared in Brewster’s Journal of Science. Reprinted in
Babbage’s Calculating Engines, E. and F. N. Spon, London, 1889, 216–219, p. 218. Reprinted in The Charles
Babbage Institute Reprint Series for the History of Computing, vol. II, Tomash Publishers, Los Angeles/San Fran-
cisco CA, 1982. Marko Petkovšek, Herbert Saul Wilf, and Doron Zeilberger, A=B, A K Peters, Natick MA,
1996, ch. 9, p. 193. Reprinted with kind permission.
End of Chapter 24 (page 699): Michel Eysquem Seigneur de Montaigne (1533–1592), Essais, Au Lecteur,
Bordeaux, 1580. Aules Persius Flaccus (34–62 AD), Satura prima, line 2. Published posthumously. Markus
Werner, Zündels Abgang, Residenz Verlag, 1984, p. 30.
c 1984 Residenz Verlag, Salzburg und Wien. Reprinted
with kind permission. Carl Friedrich Gauß (1777–1855), Disquisitiones generales de congruentiis. Analysis
residuorum caput octavum. Article 367. Werke II, Handschriftlicher Nachlass, Königliche Gesellschaft der
Wissenschaften, Göttingen, 1863, 212–242. Reprinted by Georg Olms Verlag, Hildesheim New York, 1973.
Published posthumously, see page 372.
Chapter 25 (page 702): Sherlock Holmes’ most famous words do not occur in the writing of Sir Arthur
Conan Doyle (1859–1930). The actor Clifford Hardman (Clive) Brook (1887–1974) said them in his title role in
the first talking film The Return of Sherlock Holmes about the famous sleuth. Garrett Ford (1898–1945) and Basil
Dean wrote the screenplay, Basil Dean directed the movie of 79 minutes’ length, Paramount Famous Players
Lasky Corporation produced it, and it was released on 18 October 1929. William Kingdon Clifford (1845–
1879), The Common Sense of the Exact Sciences, London, 1885 (appeared posthumously), chap. 1, sect. 7, p. 20.
Izaak Walton (1593–1683), The Compleat Angler, Richard Marriot, London, 1653. Dedication to all readers.
p. xvii. John Updike (*1932), Rabbit is Rich, Fawcett Crest, New York, published by Ballantine Books, Random
House, Inc., 1982, ch. IV, p. 301.
c Random House, Inc., New York. Reprinted with kind permission. Jonathan
Swift (1667–1745), Lemuel Gulliver, Travels into Several Remote Nations of the World, Part III: A voyage to
Laputa, Balribarbi, Glubbdubdrib, Luggnag, and Japan, Ch. V: The grand academy of Lagado, London, 1726.
References (page 734): Novalis (Friedrich Leopold Freiherr von Hardenberg) (1772–1801), Mathematische
Fragmente. In Schriften, hrsg. Richard Samuel, vol. 3, Verlag W. Kohlhammer, Stuttgart, 1983, Handschrift
Nr. 241, p. 594. Eugenio Beltrami (1835–1900), Foreword to A. Clebsch’s Commemorazione di Giulio Plücker,
Giornale di matematiche 11 (1873), Napoli, 153–179, p. 153. Bartel Leendert van der Waerden (1903–1996),
Ontwakende wetenschap, Een woord vooraf. P. Noordhoff N.V., Groningen, 1950, English translation by Arnold
Dresden: Science awakening, Oxford University Press, 1961. Raymond Chandler (1888–1959), The Simple
Art of Murder, An Essay, Houghton Mifflin, 1950. Copyright
c 1950 by Raymond Chandler,
c renewed 1978
by Helga Greene. Reprinted by kind permission of Houghton Mifflin Co. All rights reserved.
End of index (page 796): Al-Qur’ān, Sūra 27 al-naml (The ants), 76. Joseph Liouville (1809–1882), Œuvres
mathématiques d’Évariste Galois, Journal de mathématiques pures et appliquées 9 (1846), 381–444, p. 381.
René Descartes (1596–1650), Principia philosophiæ, Elzevier, Amsterdam, 1644. Œuvres de Descartes, tome
VIII-1, publiées par Charles Adam et Paul Tannery, 1905, p. 329. Reprinted by Librairie Philosophique J. Vrin,
Paris, 1973. Francis Sowerby Macaulay (1862–1937), The Algebraic Theory of Modular Systems, Preface,
Cambridge University Press, 1916, p. xiv. Robert Recorde (c. 1510–1558), The Whetstone of Witte, The preface.
London, 1557. Douglas Noël Adams (1952–2001), The Restaurant at the End of the Universe, Pan Books,
London, 1980. UK and Commonwealth copyright
c Serious Productions Ltd 1980. Copyright for the rest of the
universe
c Completely Unexpected Productions 1980. Reprinted with kind permission of The Crown Publishing
Group, New York, of Macmillan Publishers, London, and of Ed Victor Ltd, London.
Moritz’ (1914) compilation is a rich source of mathematical quotations.
List of algorithms
2.1 Addition of multiprecision integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2 Addition of polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.3 Multiplication of polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4 Multiplication of multiprecision integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.5 Polynomial division with remainder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5 Traditional Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.6 Traditional Extended Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.14 Extended Euclidean Algorithm (EEA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.17 Binary Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.8 Repeated squaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4 Chinese Remainder Algorithm (CRA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
5.10 Small primes modular determinant computation . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
6.11 Gcd of primitive polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6.28 Modular bivariate gcd: big prime version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
6.34 Modular gcd in Z[x]: big prime version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
6.36 Modular bivariate gcd: small primes version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
6.38 Modular gcd in Z[x]: small primes version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
6.45 Gcd of many polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
6.57 Modular EEA in Q[x]: small primes version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
6.59 Modular bivariate EEA: small primes version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
6.61 Primitive Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
8.1 Karatsuba’s polynomial multiplication algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
8.14 Fast Fourier Transform (FFT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.16 Fast convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
8.20 Fast negative wrapped convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
8.25 Three primes FFT integer multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
8.29 Fast convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
8.30 Schönhage’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
9.3 Inversion using Newton iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.5 Fast division with remainder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
9.10 p-adic inversion using Newton iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.14 Generalized Taylor expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
9.22 p-adic Newton iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
9.35 Montgomery multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10.3 Building up the subproduct tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
10.5 Going down the subproduct tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
10.7 Fast multipoint evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
10.9 Linear combination for linear moduli . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
10.11 Fast interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
10.14 Fast simultaneous reduction with precomputation . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
10.16 Fast simultaneous modular reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
10.18 Simultaneous inverse computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
10.20 Linear combination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
10.22 Fast Chinese Remainder Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
10.26 Building a mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
10.27 Building a Huffman tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
11.4 Half gcd for normal degree sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
11.6 Half gcd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
11.8 Fast Extended Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
12.1 Matrix multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
12.3 Fast modular composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
12.9 Minimal polynomial for F N . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
12.12 Solving a nonsingular square linear system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
12.13 Minimal polynomial for Krylov subspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
12.20 Composition modulo powers of x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
14.3 Distinct-degree factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
14.8 Equal-degree splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
14.10 Equal-degree factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
14.13 Polynomial factorization over finite fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
14.15 Root finding over finite fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
730
List of algorithms 731
732
List of figures and tables 733
Het is niet alleen veel leerrijker, het geeft ook veel meer genot de
klassieke schrijvers zelf te lezen. [. . . ] Daarom zeg ik mijn lezers
met nadruk: geloof niets op mijn woord, maar kijk alles na!3
Bartel Leendert van der Waerden (1950)
References
The numbers in brackets at the end of a reference are the pages on which it is cited. Names of authors and titles
are usually given in the same form as on the article or book.
J OHN A BBOTT, V ICTOR S HOUP, and PAUL Z IMMERMANN (2000), Factorization in Z[x]: The Searching
Phase. In Proceedings of the 2000 International Symposium on Symbolic and Algebraic Computation
ISSAC2000, St. Andrews, Scotland, ed. C ARLO T RAVERSO, 1–7. [465]
S. A. Abramov (1971), O summirovanii racionalьnyh funkci i . Жurnal
vyqislitelьnoi Matematiki i matematiqeskoi Fiziki 11(4), 1071–1075. S. A.
A BRAMOV, On the summation of rational functions, U.S.S.R. Computational Mathematics and
Mathematical Physics 11(4), 324–330. [671, 675]
S. A. Abramov (1975), Racionalьna komponenta rexeni line i nogo rekurrentnogo
sootnoxeni pervogo pordka s racionalьno i pravo i qastь . Жurnal
vyqislitelьnoi Matematiki i matematiqeskoi Fiziki 15(4), 1035–1039. S. A.
A BRAMOV, The rational component of the solution of a first-order linear recurrence relation with rational
right side, U.S.S.R. Computational Mathematics and Mathematical Physics 15(4), 216–221. [671]
S. A. Abramov (1989a), Zadaqi kompь terno i algebry, svzannye s poiskom
polinomialьnyh rexeni i line i nyh differencialьnyh i raznostnyh
uravneni i . Vestnik Moskovskogo Universiteta. Seri 15. Vyqislitelьna
Matematika i Kibernetika 3, 56–60. S. A. A BRAMOV, Problems of computer algebra involved
in the search for polynomial solutions of linear differential and difference equations, Moscow University
Computational Mathematics and Cybernetics 3, 63–68. [641, 671]
S. A. Abramov (1989b), Racionalьnye rexeni line i nyh differencialьnyh i
raznostnyh uravneni i s polinomialьnymi koзfficientami. Жurnal
vyqislitelьnoi Matematiki i matematiqeskoi Fiziki 29(11), 1611–1620. S. A.
A BRAMOV, Rational solutions of linear differential and difference equations with polynomial coefficients,
U.S.S.R. Computational Mathematics and Mathematical Physics 29(6), 7–12. [641, 671]
1 He who does not take a mathematical book with reverence and reads it like God’s word, does not understand it.
2 Students [. . . ] should learn [. . . ] to study at an early stage the main works of the great masters instead of
making their minds sterile through the everlasting exercises of college.
3 It is not only more instructive but also more fun to read the classical authors themselves [. . . ] Therefore
I implore my readers: do not believe anything I say, verify everything!
734
References 735
S. A. A BRAMOV (1995), Rational solutions of linear difference and q-difference equations with polynomial
coefficients. In Proceedings of the 1995 International Symposium on Symbolic and Algebraic
Computation ISSAC ’95, Montreal, Canada, ed. A. H. M. L EVELT, ACM Press, 285–289. [671]
S ERGEI A. A BRAMOV, M ANUEL B RONSTEIN, and M ARKO P ETKOVŠEK (1995), On Polynomial Solutions of
Linear Operator Equations. In Proceedings of the 1995 International Symposium on Symbolic and
Algebraic Computation ISSAC ’95, Montreal, Canada, ed. A. H. M. L EVELT, ACM Press, 290–296.
[641]
S ERGEI A. A BRAMOV and M ARK VAN H OEIJ (1999), Integration of solutions of linear functional equations.
Integral Transforms and Special Functions 8(1–2), 3–12. [671]
S. A. A BRAMOV and K. Y U . K VANSENKO [K. Y U . K VASHENKO ] (1991), Fast Algorithms to Search for the
Rational Solutions of Linear Differential Equations with Polynomial Coefficients. In Proceedings of the
1991 International Symposium on Symbolic and Algebraic Computation ISSAC ’91, Bonn, Germany, ed.
S TEPHEN M. WATT, ACM Press, 267–270. [641]
S. A. A BRAMOV and M. P ETKOVŠEK (2001), Canonical Representations of Hypergeometric Terms. In Formal
Power Series and Algebraic Combinatorics (FPSAC01), Tempe AZ. [675]
L. M. A DLEMAN (1983), On Breaking Generalized Knapsack Public Key Cryptosystems. In Proceedings of the
Fifteenth Annual ACM Symposium on Theory of Computing, Boston MA, ACM Press, 402–412. [509]
L EONARD M. A DLEMAN (1994), Algorithmic Number Theory—The Complexity Contribution. In Proceedings
of the 35th Annual IEEE Symposium on Foundations of Computer Science, Santa Fe NM, ed. S HAFI
G OLDWASSER, IEEE Computer Society Press, Santa Fe NM, 88–113. [531]
L EONARD M. A DLEMAN and H ENDRIK W. L ENSTRA , J R . (1986), Finding Irreducible Polynomials over
Finite Fields. In Proceedings of the Eighteenth Annual ACM Symposium on Theory of Computing,
Berkeley CA, ACM Press, 350–355. [421]
M ANINDRA AGRAWAL, N EERAJ K AYAL, and N ITIN S AXENA (2004), PRIMES is in P. Annals of
Mathematics 160(2), 781–793. [517, 543]
A LFRED V. A HO, J OHN E. H OPCROFT, and J EFFREY D. U LLMAN (1974), The Design and Analysis of
Computer Algorithms. Addison-Wesley, Reading MA. [286, 332]
A. V. A HO, K. S TEIGLITZ, and J. D. U LLMAN (1975), Evaluating polynomials at fixed sets of points. SIAM
Journal on Computing 4, 533–539. [286, 292]
M. A JTAI (1997), The Shortest Vector Problem in L2 is N P-hard for Randomized Reductions. Electronic
Colloquium on Computational Complexity TR97-047. 33 pages. [496]
A NDRES A LBANESE, J OHANNES B LÖMER, J EFF E DMONDS, M ICHAEL L UBY, and M ADHU S UDAN (1994),
Priority Encoding Transmission. In Proceedings of the 35th Annual IEEE Symposium on Foundations of
Computer Science, Santa Fe NM, ed. S HAFI G OLDWASSER, IEEE Computer Society Press, Los
Alamitos CA, 604–612. [215]
W ILLIAM ROBERT A LFORD, A NDREW G RANVILLE, and C ARL P OMERANCE (1994), There are infinitely
many Carmichael numbers. Annals of Mathematics 140, 703–722. [529, 532]
G ERT A LMKVIST and D ORON Z EILBERGER (1990), The Method of Differentiating under the Integral Sign.
Journal of Symbolic Computation 10, 571–591. [641, 671]
N OGA A LON, J EFF E DMONDS, and M ICHAEL L UBY (1995), Linear Time Erasure Codes With Nearly Optimal
Recovery. In Proceedings of the 36th Annual IEEE Symposium on Foundations of Computer Science,
Milwaukee WI, IEEE Computer Society Press, Los Alamitos CA, 512–519. [215]
F RANCESCO A MOROSO (1989), Tests d’appartenance d’après un théorème de Kollár. Comptes Rendus de
l’Académie des Sciences Paris, série I 309, 691–694. [618]
G EORGE E. A NDREWS (1994), The Death of Proof? Semi-Rigorous Mathematics? You’ve Got to Be Kidding!
The Mathematical Intelligencer 16(4), 16–18. [697]
A NONYMOUS (1835), Wie sich die Division mit Zahlen erleichtern und zugleich sicherer ausführen läßt, als auf
die gewöhnliche Weise. Journal für die reine und angewandte Mathematik 13(3), 209–218. [41]
A NDREAS A NTONIOU (1979), Digital filters: analysis and design. McGraw-Hill electrical engineering series:
Communications and information theory section, McGraw-Hill, New York. [353]
TOM M. A POSTOL (1983), A Proof that Euler Missed: Evaluating ζ(2) the Easy Way. The Mathematical
Intelligencer 5(3), 59–60. Reprinted in Berggren, Borwein & Borwein (1997), 456–457. [62]
A RCHIMEDES (c. 250 BC), Κύκλου μέτρησις (Measurement of a circle). In Opera Omnia, vol. I, ed. I. L.
H EIBERG, 231–243. B. G. Teubner, Stuttgart, Germany, 1910. Reprinted 1972. [82]
A. A RWIN (1918), Über Kongruenzen von dem fünften und höheren Graden nach einem Primzahlmodulus.
Arkiv för matematik, astronomi och fysik 14(7), 1–46. [418]
C. A. A SMUTH and G. R. B LAKLEY (1982), Pooling, splitting and restituting information to overcome total
failure of some channels of communication. In Proceedings 1982 Symposium on Security and Privacy,
IEEE Computer Society Press, Los Alamitos CA, 156–159. [131]
A. O. L. ATKIN and R. G. L ARSON (1982), On a primality test of Solovay and Strassen. SIAM Journal on
Computing 11(4), 789–791. [532]
736 References
L. BABAI (1979), Monte Carlo algorithms in graph isomorphism testing. Technical Report 79-10, Département
de Mathématique et Statistique, Université de Montréal. [198, 724]
L ÁSZLÓ BABAI, E UGENE M. L UKS, and Á KOS S ERESS (1988), Fast Management of Permutation Groups.
In Proceedings of the 29th Annual IEEE Symposium on Foundations of Computer Science, White
Plains NY, IEEE Computer Society Press, Washington DC, 272–282. [724]
E RIC BACH (1990), Number-theoretic algorithms. Annual Review of Computer Science 4, 119–172. [531]
E RIC BACH (1996), Weil Bounds for Singular Curves. Applicable Algebra in Engineering, Communication and
Computing 7, 289–298. [568]
E RIC BACH, J OACHIM VON ZUR G ATHEN, and H ENDRIK W. L ENSTRA , J R . (2001), Factoring Polynomials
over Special Finite Fields. Finite Fields and Their Applications 7, 5–28. [421]
E RIC BACH, G ARY M ILLER, and J EFFREY S HALLIT (1986), Sums of divisors, perfect numbers and factoring.
SIAM Journal on Computing 15(4), 1143–1154. [532, 535]
E RIC BACH and J EFFREY S HALLIT (1988), Factoring with cyclotomic polynomials. Mathematics of
Computation 52(185), 201–219. [568]
E RIC BACH and J EFFREY S HALLIT (1996), Algorithmic Number Theory, Vol.1: Efficient Algorithms.
MIT Press, Cambridge MA. [61, 421, 531, 533, 534]
E RIC BACH and J ONATHAN S ORENSON (1993), Sieve algorithms for perfect power testing. Algorithmica 9,
313–328. [287]
E RIC BACH and J ONATHAN S ORENSON (1996), Explicit bounds for primes in residue classes. Mathematics of
Computation 65(216), 1717–1735. [529]
J OHANN S EBASTIAN BACH (1722), Das Wohltemperierte Klavier. BWV 846–893, Part I appeared in 1722,
Part II in 1738. [86]
C LAUDE G ASPAR BACHET DE M ÉZIRIAC (1612), Problèmes plaisans et délectables, qui se font par les
nombres. Pierre Rigaud, Lyon. [61]
DAVID H. BAILEY, K ING L EE, and H ORST D. S IMON (1990), Using Strassen’s Algorithm to Accelerate the
Solution of Linear Systems. The Journal of Supercomputing 4(4), 357–371. [2, 337]
G EORGE A. BAKER , J R . and P ETER G RAVES -M ORRIS (1996), Padé Approximants . Encyclopedia of
Mathematics and its Applications 59, Cambridge University Press, Cambridge, UK, 2nd edition. First
edition published in two volumes by Addison-Wesley, Reading MA, 1982. [132]
W. W. ROUSE BALL and H. S. M. C OXETER (1947), Mathematical Recreations & Essays. The Macmillan
Company, New York, American edition. First edition 1892. [531, 534]
J. M. BARBOUR (1948), Music and ternary continued fractions. The American Mathematical Monthly 55,
545–555. [91]
E RWIN H. BAREISS (1968), Sylvester’s Identity and Multistep Integer-Preserving Gaussian Elimination.
Mathematics of Computation 22(101–104), 565–578. [132]
A NDREJ BAUER and M ARKO P ETKOVŠEK (1999), Multibasic and Mixed Hypergeometric Gosper-Type
Algorithms. Journal of Symbolic Computation 28, 711–736. [671]
WALTER BAUR and VOLKER S TRASSEN (1983), The complexity of partial derivatives. Theoretical Computer
Science 22, 317–330. [352]
DAVID BAYER and M ICHAEL S TILLMAN (1988), On the complexity of computing syzygies. Journal of
Symbolic Computation 6, 135–147. [618]
PAUL W. B EAME, RUSSELL I MPAGLIAZZO, JAN K RAJÍ ČEK, TONIANN P ITASSI, and PAVEL P UDLÁK (1996),
Lower bounds on Hilbert’s Nullstellensatz and propositional proofs. Proceedings of the London
Mathematical Society 3, 1–26. [697]
PAUL B EAME and TONIANN P ITASSI (1998), Propositional Proof Complexity: Past, Present, and Future.
Bulletin of the European Association for Theoretical Computer Science 65, 66–89. [697]
T HOMAS B ECKER and VOLKER W EISPFENNING (1993), Gröbner Bases—A Computational Approach to
Commutative Algebra . Graduate Texts in Mathematics 141, Springer-Verlag, New York. [618]
A LBERT H. B EILER (1964), Recreations in the Theory of Numbers: The Queen of Mathematics Entertains.
Dover Publications, Inc., New York. [534]
E RIC T EMPLE B ELL (1937), Men of Mathematics. Penguin Books Ltd., Harmondsworth, Middlesex.
[219, 725, 726, 729]
C HRISTOF B ENECKE, ROLAND G RUND, R EINHARD H OHBERGER, A DALBERT K ERBER, R EINHARD L AUE,
and T HOMAS W IELAND (1995), MOLGEN, a computer algebra system for the generation of molecular
graphs. In Computer Algebra in Science and Engineering, Bielefeld, Germany, August 1994, eds.
J. F LEISCHER, J. G RABMEIER, F. W. H EHL, and W. K ÜCHLIN, World Scientific, Singapore, 260–272.
[698]
M. B EN -O R (1981), Probabilistic algorithms in finite fields. In Proceedings of the 22nd Annual IEEE
Symposium on Foundations of Computer Science, Nashville TN, 394–398. [421]
M. B EN -O R, D. KOZEN, and J. R EIF (1986), The complexity of elementary algebra and geometry. Journal of
Computer and System Sciences 32, 251–264. [619]
References 737
M ICHAEL B EN -O R and P RASOON T IWARI (1988), A Deterministic Algorithm For Sparse Multivariate
Polynomial Interpolation. In Proceedings of the Twentieth Annual ACM Symposium on Theory of
Computing, Chicago IL, ACM Press, 301–309. [498]
C ARLOS A. B ERENSTEIN and A LAIN Y GER (1990), Bounds for the Degrees in the Division Problem.
Michigan Mathematical Journal 37, 25–43. [618]
L ENNART B ERGGREN, J ONATHAN B ORWEIN, and P ETER B ORWEIN, eds. (1997), Pi: A Source Book.
Springer-Verlag, New York. [90, 729, 735, 737, 749, 751, 753, 761, 763]
E. R. B ERLEKAMP (1967), Factoring polynomials over finite fields. Bell System Technical Journal 46,
1853–1859. [401, 417, 420, 462]
E. R. B ERLEKAMP (1970), Factoring Polynomials Over Large Finite Fields. Mathematics of
Computation 24(11), 713–735. [198, 401, 406, 417, 419, 420, 421, 462, 465, 530]
E LWYN R. B ERLEKAMP (1984), Algebraic Coding Theory. Aegean Park Press. First edition McGraw Hill,
New York, 1968. [215, 467]
E LWYN R. B ERLEKAMP, ROBERT J. M C E LIECE, and H ENK C. A. VAN T ILBORG (1978), On the Inherent
Intractability of Certain Coding Problems. IEEE Transactions on Information Theory IT-24(3), 384–386.
[215]
B ENJAMIN P. B ERMAN and R ICHARD J. FATEMAN (1994), Optical character recognition for typeset
mathematics. In Proceedings of the 1994 International Symposium on Symbolic and Algebraic
Computation ISSAC ’94, Oxford, UK, eds. J. VON ZUR G ATHEN and M. G IESBRECHT, ACM Press,
348–353. [640]
J OANNES B ERNOULLIUS [J OHANN B ERNOULLI ] (1703), Problema exhibitum. Acta eruditorum, 26–31. [640]
DANIEL J. B ERNSTEIN (1998a), Composing Power Series Over a Finite Ring in Essentially Linear Time.
Journal of Symbolic Computation 26(3), 339–341. [353]
DANIEL J. B ERNSTEIN (1998b), Detecting perfect powers in essentially linear time. Mathematics of
Computation 67(223), 1253–1283. [287]
DANIEL J. B ERNSTEIN (2001), Multidigit multiplication for mathematicians. 19 pp.
http://cr.yp.to/papers/m3.ps. [247]
P. B ÉZIER (1970), Emploi des Machines à Commande Numérique. Masson & Cie , Paris. English translation:
Numerical Control, John Wiley & Sons, 1972. [138]
É TIENNE B ÉZOUT (1764), Recherches sur le degré des Équations résultantes de l’évanouissement des
inconnues, Et sur les moyens qu’il convient d’employer pour trouver ces Équations. Histoire de
l’académie royale des sciences, 288–338. Summary 88–91. [197, 724, 728]
J. B INET (1841), Recherches sur la théorie des nombres entiers et sur la résolution de l’équation indéterminée
du premier degré qui n’admet que des solutions entières. Journal de Mathématiques Pures et
Appliquées 6, 449–494. [61]
I AN B LAKE, G ADIEL S EROUSSI, and N IGEL S MART (1999), Elliptic Curves in Cryptography. London
Mathematical Society Lecture Note Series 265, Cambridge University Press. [580]
E NRICO B OMBIERI and A LFRED J. VAN DER P OORTEN (1995), Continued fractions of algebraic numbers.
In Computational Algebra and Number Theory, eds. W IEB B OSMA and A LF VAN DER P OORTEN,
Kluwer Academic Publishers, 137–155. [90]
O LAF B ONORDEN, J OACHIM VON ZUR G ATHEN, J ÜRGEN G ERHARD, O LAF M ÜLLER, and M ICHAEL
N ÖCKER (2001), Factoring a binary polynomial of degree over one million. ACM SIGSAM
Bulletin 35(1), 16–18. [461]
G EORGE B OOLE (1860), Calculus of finite differences. Chelsea Publishing Company, New York. 5th edition
1970. [669]
A. B ORODIN and R. M OENCK (1974), Fast Modular Transforms. Journal of Computer and System
Sciences 8(3), 366–386. [286, 306]
A. B ORODIN and I. M UNRO (1975), The Computational Complexity of Algebraic and Numeric Problems.
Theory of computation series 1, American Elsevier Publishing Company, New York. [306]
A LLAN B ORODIN and P RASOON T IWARI (1990), On the Decidability of Sparse Univariate Polynomial
Interpolation. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of Computing,
Baltimore MD, ACM Press, 535–545. [498]
J. M. B ORWEIN, P. B. B ORWEIN, and D. H. BAILEY (1989), Ramanujan, Modular Equations, and
Approximations to Pi or How to Compute One Billion Digits of Pi. The American Mathematical
Monthly 96(3), 201–219. Reprinted in Berggren, Borwein & Borwein (1997), 623–641. [83]
R. C. B OSE and D. K. R AY-C HAUDHURI (1960), On A Class of Error Correcting Binary Group Codes.
Information and Control 3, 68–79. [215]
J OAN B OYAR (1989), Inferring Sequences Produced by Pseudo-Random Number Generators. Journal of
the ACM 36(1), 129–141. [505]
G ILLES B RASSARD and PAUL B RATLEY (1996), Fundamentals of Algorithmics. Prentice-Hall, Inc.,
Englewood Cliffs NJ. First published as Algorithmics - Theory & Practice, 1988. [41, 720]
A. B RAUER (1939), On addition chains. Bulletin of the American Mathematical Society 45, 736–739.
738 References
R ICHARD P. B RENT (1976), Analysis of the binary Euclidean algorithm. In Algorithms and Complexity, ed.
J. F. T RAUB, 321–355. Academic Press, New York. [61]
R ICHARD P. B RENT (1980), An improved Monte Carlo factorization algorithm. BIT 20, 176–184. [567]
R. P. B RENT (1989), Factorization of the eleventh Fermat number (preliminary report). AMS Abstracts 10,
89T-11-73. [542]
R ICHARD P. B RENT (1999), Factorization of the tenth Fermat number. Mathematics of Computation 68(225),
429–451. [542, 567]
R ICHARD P. B RENT, F RED G. G USTAVSON, and DAVID Y. Y. Y UN (1980), Fast Solution of Toeplitz Systems
of Equations and Computation of Padé Approximants. Journal of Algorithms 1, 259–295. [332]
R. P. B RENT and H. T. K UNG (1978), Fast Algorithms for Manipulating Formal Power Series. Journal of
the ACM 25(4), 581–595. [353, 354]
R ICHARD P. B RENT and J OHN M. P OLLARD (1981), Factorization of the Eighth Fermat Number. Mathematics
of Computation 36(154), 627–630. Preliminary announcement in AMS Abstracts 1 (1980), 565.
[542, 567]
E RNEST F. B RICKELL (1984), Solving low density knapsacks. In Advances in Cryptology: Proceedings of
CRYPTO ’83, Plenum Press, New York, 25–37. [509]
E RNEST F. B RICKELL (1985), Breaking iterated knapsacks. In Advances in Cryptology: Proceedings of
CRYPTO ’84, Santa Barbara, CA. Lecture Notes in Computer Science 196, Springer-Verlag, 342–358.
[509]
E GBERT B RIESKORN and H ORST K NÖRRER (1986), Plane Algebraic Curves. Birkhäuser Verlag, Basel. [568]
J OHN B RILLHART, D. H. L EHMER, J. L. S ELFRIDGE, B RYANT T UCKERMAN, and S. S. WAGSTAFF , J R .
(1988), Factorizations of bn ± 1, b = 2, 3, 5, 6, 7, 10, 11, 12 up to high powers. Contemporary
Mathematics 22, American Mathematical Society, Providence RI, 2nd edition. [542]
M ANUEL B RONSTEIN (1990), The Transcendental Risch Differential Equation. Journal of Symbolic
Computation 9, 49–60. [641]
M ANUEL B RONSTEIN (1991), The Risch Differential Equation on an Algebraic Curve. In Proceedings of the
1991 International Symposium on Symbolic and Algebraic Computation ISSAC ’91, Bonn, Germany, ed.
S TEPHEN M. WATT, ACM Press, 241–246. [641]
M ANUEL B RONSTEIN (1992), On solutions of linear ordinary differential equations in their coefficient field.
Journal of Symbolic Computation 13, 413–439. [641]
M ANUEL B RONSTEIN (1997), Symbolic Integration I—Transcendental Functions. Algorithms and
Computation in Mathematics 1, Springer-Verlag, Berlin Heidelberg. [640, 641, 642]
M ANUEL B RONSTEIN (2000), On Solutions of Linear Ordinary Difference Equations in their Coefficient Field.
Journal of Symbolic Computation 29, 841–877. [671]
M ANUEL BRRONSTEIN and A NNE F REDET (1999), Solving Linear Ordinary Differential Equations over
C(x, e f (x)dx ). In Proceedings of the 1999 International Symposium on Symbolic and Algebraic
Computation ISSAC ’99, Vancouver, Canada, ed. S AM D OOLEY, ACM Press, 173–180. [641]
W. S. B ROWN (1971), On Euclid’s Algorithm and the Computation of Polynomial Greatest Common Divisors.
Journal of the ACM 18(4), 478–504. [62, 197, 198, 199]
W. S. B ROWN (1978), The Subresultant PRS Algorithm. ACM Transactions on Mathematical Software 4(3),
237–249. [199]
W. S. B ROWN and J. F. T RAUB (1971), On Euclid’s Algorithm and the Theory of Subresultants. Journal of
the ACM 18(4), 505–514. [197, 199, 332]
W. DALE B ROWNAWELL (1987), Bounds for the degrees in the Nullstellensatz. Annals of Mathematics 126,
577–591. [618]
B RUNO B UCHBERGER (1965), Ein Algorithmus zum Auffinden der Basiselemente des Restklassenringes nach
einem nulldimensionalen Polynomideal. PhD thesis, Philosophische Fakultät an der
Leopold-Franzens-Universität, Innsbruck, Austria. [591, 609, 618]
B. B UCHBERGER (1970), Ein algorithmisches Kriterium für die Lösbarkeit eines algebraischen
Gleichungssystems. aequationes mathematicae 4(3), 271–272 and 374–383. English translation by
Michael Abramson and Robert Lumbert in Buchberger & Winkler (1998), 535–545. [618]
B. B UCHBERGER (1976), A theoretical basis for the reduction of polynomials to canonical forms.
ACM SIGSAM Bulletin 10(3), 19–29. [618]
B. B UCHBERGER (1985), Gröbner Bases: An Algorithmic Method in Polynomial Ideal Theory.
In Multidimensional Systems Theory, ed. N. K. B OSE, Mathematics and Its Applications, chapter 6,
184–232. D. Reidel Publishing Company, Dordrecht. [618]
B RUNO B UCHBERGER (1987), History and basic features of the critical–pair/completion procedure. Journal of
Symbolic Computation 3, 3–38. [618]
B RUNO B UCHBERGER and F RANZ W INKLER, eds. (1998), Gröbner Bases and Applications . London
Mathematical Society Lecture Note Series 251, Cambridge University Press, Cambridge, UK. [618, 738]
JAMES R. B UNCH and J OHN E. H OPCROFT (1974), Triangular Factorization and Inversion by Fast Matrix
Multiplication. Mathematics of Computation 28(125), 231–236. [352]
References 739
P ETER B ÜRGISSER (1998), On the Parallel Complexity of the Polynomial Ideal Membership Problem. Journal
of Complexity 14, 176–189. [616]
P ETER B ÜRGISSER, M ICHAEL C LAUSEN, and M. A MIN S HOKROLLAHI (1997), Algebraic Complexity
Theory. Grundlehren der mathematischen Wissenschaften 315, Springer-Verlag. [88, 222, 286, 338, 352]
C HRISTOPH B URNIKEL and J OACHIM Z IEGLER (1998), Fast Recursive Division. Research Report
MPI-I-98-1-022, Max-Planck-Institut für Informatik, Saarbrücken, Germany.
http://domino.mpi-inf.mpg.de/internet/reports.nsf/NumberView/1998-1-022, iv + 27
pages. [286]
S. B USS, R. I MPAGLIAZZO, J. K RAJÍ ČEK, P. P UDLÁK, A. A. R AZBOROV, and J. S GALL (1996/97), Proof
complexity in algebraic systems and bounded depth Frege systems with modular counting. computational
complexity 6(3), 256–298. [697]
M. C. R. B UTLER (1954), On the reducibility of polynomials over a finite field. Quarterly Journal of
Mathematics Oxford 5(2), 102–107. [420]
J OHN J. C ADE (1987), A modification of a broken public-key cipher. In Advances in Cryptology: Proceedings
of CRYPTO ’86, Santa Barbara, CA, ed. A. M. O DLYZKO. Lecture Notes in Computer Science 263,
Springer-Verlag, 64–83. [576]
PAUL C AMION (1980), Un algorithme de construction des idempotents primitifs d’idéaux d’algèbres sur Fq .
Comptes Rendus de l’Académie des Sciences Paris 291, 479–482. [420]
PAUL C AMION (1981), Factorisation des polynômes de Fq . Revue du CETHEDEC 18, 1–17. [419]
PAUL C AMION (1982), Un algorithme de construction des idempotents primitifs d’idéaux d’algèbres sur Fq .
Annals of Discrete Mathematics 12, 55–63. [419]
PAUL F. C AMION (1983), Improving an Algorithm for Factoring Polynomials over a Finite Field and
Constructing Large Irreducible Polynomials. IEEE Transactions on Information Theory IT-29(3),
378–385. [419]
E. R. C ANFIELD, PAUL E RD ŐS, and C ARL P OMERANCE (1983), On a problem of Oppenheim concerning
‘Factorisatio Numerorum’. Journal of Number Theory 17, 1–28. [567]
L ÉANDRO C ANIGLIA, A NDRÉ G ALLIGO, and J OOS H EINTZ (1988), Borne simple exponentielle pour les
degrés dans le théorème des zéros sur un corps de caractéristique quelconque. Comptes Rendus de
l’Académie des Sciences Paris, série I 307, 255–258. [619]
L ÉANDRO C ANIGLIA, A NDRÉ G ALLIGO, and J OOS H EINTZ (1989), Some new effectivity bounds in
computational geometry. In Algebraic Algorithms and Error-Correcting Codes: AAECC-6, Rome, Italy,
1988, ed. T. M ORA, Lecture Notes in Computer Science 357, 131–152. Springer-Verlag. [618]
J OHN C ANNY (1987), A New Algebraic Method for Robot Motion Planning and Real Geometry.
In Proceedings of the 28th Annual IEEE Symposium on Foundations of Computer Science,
Los Angeles CA, IEEE Computer Society Press, Washington DC, 39–48. [619]
J OHN F. C ANNY (1988), The Complexity of Robot Motion Planning. ACM Doctoral Dissertation Award 1987,
MIT Press, Cambridge MA. [619]
DAVID G. C ANTOR (1989), On Arithmetical Algorithms over Finite Fields. Journal of Combinatorial Theory,
Series A 50, 285–300. [280, 281, 282, 287]
DAVID G. C ANTOR and DANIEL M. G ORDON (2000), Factoring Polynomials over p-Adic Fields.
In Algorithmic Number Theory, Fourth International Symposium, ANTS-IV, Leiden, The Netherlands, ed.
W IEB B OSMA, Springer-Verlag, 185–208. [466]
DAVID G. C ANTOR and E RICH K ALTOFEN (1991), On Fast Multiplication of Polynomials Over Arbitrary
Algebras. Acta Informatica 28, 693–701. [245, 247]
DAVID G. C ANTOR and H ANS Z ASSENHAUS (1981), A New Algorithm for Factoring Polynomials Over Finite
Fields. Mathematics of Computation 36(154), 587–592. [405, 406, 417, 418]
L EONARD C ARLITZ (1932), The arithmetic of polynomials in a Galois field. American Journal of
Mathematics 54, 39–50. [426]
R. D. C ARMICHAEL (1909/10), Note on a new number theory function. Bulletin of the American Mathematical
Society 16, 232–238. [531]
R. D. C ARMICHAEL (1912), On composite numbers P which satisfy the Fermat congruence aP−1 ≡ 1 mod P.
The American Mathematical Monthly 19, 22–27. [531]
T HOMAS R. C ARON and ROBERT D. S ILVERMAN (1988), Parallel implementation of the quadratic sieve. The
Journal of Supercomputing 1, 273–290. [531, 567]
PAUL DE FAGET DE C ASTELJAU (1985), Shape mathematics and CAD. Hermes Publishing, Paris. [138]
P IETRO A NTONIO C ATALDI (1513), Trattato del modo brevissimo di trouare la radice quadra delli numeri.
Bartolomeo Cochi, Bologna. [89]
AUGUSTIN C AUCHY (1821), Sur la formule de Lagrange relative à l’interpolation. In Cours d’analyse de
l’École Royale Polytechnique (Analyse algébrique), Note V. Imprimerie royale Debure frères, Paris.
Œuvres Complètes, IIe série, tome III, Gauthier-Villars, Paris, 1897, 429–433. [132]
740 References
AUGUSTIN C AUCHY (1840), Mémoire sur l’élimination d’une variable entre deux équations algébriques.
In Exercices d’analyse et de physique mathématique, tome 1er . Bachelier, Paris. Œuvres Complètes,
IIe série, tome 11. Gauthier-Villars, Paris, 1913, 466–509. [197]
AUGUSTIN C AUCHY (1841), Mémoire sur diverses formules relatives à l’Algèbre et à la théorie des nombres.
Comptes Rendus de l’Académie des Sciences Paris 12, p. 813 ff. Œuvres Complètes, Ire série, tome 6,
Gauthier-Villars, Paris, 1888, 113–146. [131]
AUGUSTIN C AUCHY (1847), Mémoire sur les racines des équivalences correspondantes à des modules
quelconques premiers ou non premiers, et sur les avantages que présente l’emploi de ces racines dans la
théorie des nombres. Comptes Rendus de l’Académie des Sciences Paris 25, p. 37 ff. Œuvres Complètes,
Ire série, tome 10, Gauthier-Villars, Paris, 1897, 324–333. [286]
B. F. C AVINESS (1970), On Canonical Forms and Simplification. Journal of the Association for Computing
Machinery 17(2), 385–396. [640]
A RTHUR C AYLEY (1848), On the theory of elimination. The Cambridge and Dublin Mathematical Journal 3,
116–120. Also Cambridge Mathematical Journal 7. [197]
M IGUEL DE C ERVANTES S AAVEDRA (1615), El ingenioso cavallero Don Quixote de la Mancha, segunda parte .
Francisco de Robles, Madrid. [90]
JASBIR S. C HAHAL (1995), Manin’s Proof of the Hasse Inequality Revisited. Nieuw Archief voor Wiskunde,
Vierde serie 13(2), 219–232. [568]
B RUCE W. C HAR, K EITH O. G EDDES, and G ASTON H. G ONNET (1989), GCDHEU: Heuristic Polynomial
GCD Algorithm Based On Integer GCD Computation. Journal of Symbolic Computation 7, 31–48.
Extended Abstract in Proceedings of EUROSAM ’84, ed. J OHN F ITCH, Lecture Notes in Computer
Science 174, Springer-Verlag, 285–296. [202]
N. T SCHEBOTAREFF [N. C HEBOTAREV ] (1926), Die Bestimmung der Dichtigkeit einer Menge von
Primzahlen, welche zu einer gegebenen Substitutionsklasse gehören. Mathematische Annalen 95,
191–228. [441, 465]
P. L. Qebyxev (1849), Obь oprednjlenii qisla prostyhь qiselь ne prevoshodw ihь
danno i veliqiny. Mémoires présentés à l’Académie Impériale des sciences de St.-Pétersbourg par
divers savants 6, 141–157. P. L. C HEBYSHEV, Sur la fonction qui détermine la totalité des nombres
premiers inférieurs à une limite donnée. Journal de Mathématiques Pures et Appliquées, I série 17 (1852),
341–365. Œuvres I, eds. A. M ARKOFF and N. S ONIN, 1899, reprint by Chelsea Publishing Co.,
New York, 26–48. [533]
P. L. C HEBYSHEV (1852), Mémoire sur les nombres premiers. Journal de Mathématiques Pures et Appliquées,
I série 17, 366–390. Mémoires présentées à l’Académie Impériale des sciences de St.-Pétersbourg par
divers savants 6 (1854), 17–33. Œuvres I, eds. A. M ARKOFF and N. S ONIN, 1899, reprint by Chelsea
Publishing Co., New York, 49–70. [533]
Z HI -Z HONG C HEN and M ING -YANG K AO (1997), Reducing Randomness via Irrational Numbers.
In Proceedings of the Twenty-ninth Annual ACM Symposium on Theory of Computing, El Paso TX,
ACM Press, 200–209. [199]
Z HI -Z HONG C HEN and M ING -YANG K AO (2000), Reducing randomness via irrational numbers. SIAM
Journal on Computing 29(4), 1247–1256. [199]
A LEXANDRE L. C HISTOV (1990), Efficient Factoring Polynomials over Local Fields and Its Applications.
In Proceedings of the International Congress of Mathematicians 1990, Kyoto, Japan, vol. II, 1509–1519.
Springer-Verlag. [466]
A. L. C HISTOV and D. Y U . G RIGOR ’ EV (1984), Complexity of quantifier elimination in the theory of
algebraically closed fields. In Proceedings of the 11th International Symposium Mathematical
Foundations of Computer Science 1984, Praha, Czechoslovakia. Lecture Notes in Computer Science 176,
Springer-Verlag, Berlin, 17–31. [619]
B ENNY C HOR and RONALD L. R IVEST (1988), A knapsack–type public key cryptosystem based on arithmetic
in finite fields. IEEE Transactions on Information Theory IT-34(5), 901–909. Advances in Cryptology:
Proceedings of CRYPTO 1984, Santa Barbara CA, Lecture Notes in Computer Science 196,
Springer-Verlag, New York, 1985, 54–65. [509]
C.-C. C HOU, Y.-F. D ENG, G. L I, and Y. WANG (1995), Parallelizing Strassen’s Method for Matrix
Multiplication on Distributed-Memory MIMD Architectures. Computers & Mathematics with
Applications 30(2), 49–69. [352]
F RÉDÉRIC C HYZAK (1998a), Fonctions holonomes en calcul formel. PhD thesis, École Polytechnique, Paris.
[671]
F RÉDÉRIC C HYZAK (1998b), Gröbner Bases, Symbolic Summation and Symbolic Integration. In Gröbner
Bases and Applications , eds. B RUNO B UCHBERGER and F RANZ W INKLER. London Mathematical
Society Lecture Note Series 251, Cambridge University Press, Cambridge, UK, 32–60. [671]
F RÉDÉRIC C HYZAK (2000), An extension of Zeilberger’s fast algorithm to general holonomic functions.
Discrete Mathematics 217, 115–134. [671]
References 741
F RÉDÉRIC C HYZAK and B RUNO S ALVY (1998), Non-commutative Elimination in Ore Algebras Proves
Multivariate Identities. Journal of Symbolic Computation 26(2), 187–227. [671]
M ICHAEL C LAUSEN, A NDREAS D RESS, J OHANNES G RABMEIER, and M AREK K ARPINSKI (1991),
On Zero–Testing and Interpolation of k-Sparse Multivariate Polynomials over Finite Fields. Theoretical
Computer Science 84, 151–164. [498]
M ATTHEW C LEGG, J EFFREY E DMONDS, and RUSSELL I MPAGLIAZZO (1996), Using the Groebner basis
algorithm to find proofs of unsatisfiability. In Proceedings of the Twenty-eighth Annual ACM
Symposium on Theory of Computing, Philadelphia PA, ACM Press, 174–183. [679]
G. E. C OLLINS (1966), Polynomial remainder sequences and determinants. The American Mathematical
Monthly 73, 708–712. [197, 199]
G EORGE E. C OLLINS (1967), Subresultants and Reduced Polynomial Remainder Sequences. Journal of
the ACM 14(1), 128–142. [197, 199, 332]
G. E. C OLLINS (1971), The Calculation of Multivariate Polynomial Resultants. Journal of the ACM 18(4),
515–532. [197, 198]
G. E. C OLLINS (1973), Computer algebra of polynomials and rational functions. The American Mathematical
Monthly 80, 725–55. [199]
G. E. C OLLINS (1975), Quantifier elimination for real closed fields by cylindrical algebraic decomposition.
Lecture Notes in Computer Science 33, Springer-Verlag. [619]
G. E. C OLLINS (1979), Factoring univariate integral polynomials in polynomial average time. In Proceedings
of EUROSAM ’79, Marseille, France. Lecture Notes in Computer Science 72, 317–329. [455, 465]
G EORGE E. C OLLINS and M ARK J. E NCARNACIÓN (1996), Improved Techniques for Factoring Univariate
Polynomials. Journal of Symbolic Computation 21, 313–327. [465]
S. A. C OOK (1966), On the minimum computation time of functions. Doctoral Thesis, Harvard University,
Cambridge MA. [247, 286]
S TEPHEN A. C OOK (1971), The Complexity of Theorem–Proving Procedures. In Proceedings of the Third
Annual ACM Symposium on Theory of Computing, Shaker Heights OH, ACM Press, 151–158. [722]
JAMES W. C OOLEY (1987), The Re–Discovery of the Fast Fourier Transform Algorithm. Mikrochimica Acta 3,
33–45. [247, 727]
JAMES W. C OOLEY (1990), How the FFT Gained Acceptance. In A History of Scientific Computing, ed.
S TEPHEN G. NASH, ACM Press, New York, and Addison-Wesley, Reading MA, 133–140. [247]
JAMES W. C OOLEY and J OHN W. T UKEY (1965), An Algorithm for the Machine Calculation of Complex
Fourier Series. Mathematics of Computation 19, 297–301. [233, 247]
D. C OPPERSMITH (1993), Solving Linear Equations Over GF(2): Block Lanczos Algorithm. Linear Algebra
and its Applications 192, 33–60. [353]
D ON C OPPERSMITH (1994), Solving homogeneous linear equations over GF(2) via block Wiedemann
algorithm. Mathematics of Computation 62(205), 333–350. [353]
D ON C OPPERSMITH and S HMUEL W INOGRAD (1990), Matrix Multiplication via Arithmetic Progressions.
Journal of Symbolic Computation 9, 251–280. [352, 420]
ROBERT M. C ORLESS, E RICH K ALTOFEN, and S TEPHEN M. WATT (2003), Hybrid Methods. In Computer
Algebra Handbook – Foundations, Applications, Systems, eds. J OHANNES G RABMEIER, E RICH
K ALTOFEN, and VOLKER W EISPFENNING, 112–125. Springer-Verlag, Berlin, Heidelberg, New York.
[41]
T HOMAS H. C ORMEN, C HARLES E. L EISERSON, RONALD L. R IVEST, and C LIFFORD S TEIN (2009),
Introduction to Algorithms. MIT Press, Cambridge MA, London UK, third edition. [41, 368]
JAMES C OWIE, B RUCE D ODSON, R. M ARIJE E LKENBRACHT-H UIZING, A RJEN K. L ENSTRA, P ETER L.
M ONTGOMERY, and J ÖRG Z AYER (1996), A World Wide Number Field Sieve Factoring Record: On to
512 Bits. In Advances in Cryptology—ASIACRYPT ’96. Lecture Notes in Computer Science 1163,
Springer-Verlag, 382–394. [569]
DAVID A. C OX (1989), Primes of the Form x2 + ny2 — Fermat, Class Field Theory, and Complex
Multiplication . John Wiley & Sons, New York. [568]
DAVID C OX, J OHN L ITTLE, and D ONAL O’S HEA (1997), Ideals, Varieties, and Algorithms: An Introduction to
Computational Algebraic Geometry and Commutative Algebra. Undergraduate Texts in Mathematics,
Springer-Verlag, New York, 2nd edition. First edition 1992. [614, 617, 618]
DAVID C OX, J OHN L ITTLE, and D ONAL O’S HEA (1998), Using Algebraic Geometry. Graduate Texts in
Mathematics 185, Springer-Verlag, New York. [617]
G ABRIEL C RAMER (1750), Introduction a l’analyse des lignes courbes algébriques. Frères Cramer &
Cl. Philibert, Genève. [198, 724]
J OHN N. C ROSSLEY and A LAN S. H ENRY (1990), Thus Spake al-Khwārizmı̄: A Translation of the Text of
Cambridge University Library Ms. Ii.vi.5. Historia Mathematica 17, 103–131. [727]
A LLAN J. C. C UNNINGHAM and H. J. W OODALL (1925), Factorization of (yn ∓ 1), y = 2, 3, 5, 6, 7, 10, 11, 12
up to high powers (n). Francis Hodgson, London. [541]
742 References
I VAN DAMGÅRD, P ETER L ANDROCK, and C ARL P OMERANCE (1993), Average case error estimates for the
strong probable prime test. Mathematics of Computation 61(203), 177–194. [532]
J. H. DAVENPORT (1986), The Risch differential equation problem. SIAM Journal on Computing 15(4),
903–918. [641]
P IERRE D ÈBES (1996), Hilbert subsets and s-integral points. Manuscripta Mathematica 89, 107–137. [498]
R ICHARD A. D E M ILLO and R ICHARD J. L IPTON (1978), A probabilistic remark on algebraic program testing.
Information Processing Letters 7(4), 193–195. [88, 198]
A NGEL D ÍAZ and E RICH K ALTOFEN (1995), On Computing Greatest Common Divisors with Polynomials
Given By Black Boxes for Their Evaluations. In Proceedings of the 1995 International Symposium on
Symbolic and Algebraic Computation ISSAC ’95, Montreal, Canada, ed. A. H. M. L EVELT, ACM Press,
232–239. [199]
A NGEL D ÍAZ and E RICH K ALTOFEN (1998), F OX B OX: A System for Manipulating Symbolic Objects in Black
Box Representation. In Proceedings of the 1998 International Symposium on Symbolic and Algebraic
Computation ISSAC ’98, Rostock, Germany, ed. O LIVER G LOOR, ACM Press, 30–37. [498]
L EONARD E UGENE D ICKSON (1919), History of the Theory of Numbers, vol. 1. Carnegie Institute of
Washington. Published in 1919, 1920, and 1923 as publication 256. Reprinted by Chelsea Publishing
Company, New York, N.Y., 1971. [88]
W HITFIELD D IFFIE and M ARTIN E. H ELLMAN (1976), New directions in cryptography. IEEE Transactions on
Information Theory IT-22(6), 644–654. [503, 575, 576, 578, 581]
G. L EJEUNE D IRICHLET (1837), Beweis des Satzes, dass jede unbegrenzte arithmetische Progression, deren
erstes Glied und Differenz ganze Zahlen ohne gemeinschaftlichen Factor sind, unendlich viele Primzahlen
enthält. Abhandlungen der Königlich Preussischen Akademie der Wissenschaften, 45–81. Werke, Erster
Band, ed. L. K RONECKER, 1889, 315–342. Reprint by Chelsea Publishing Co., 1969. [528]
G. L EJEUNE D IRICHLET (1842), Verallgemeinerung eines Satzes aus der Lehre von den Kettenbrüchen nebst
einigen Anwendungen auf die Theorie der Zahlen. Bericht über die Verhandlungen der Königlich
Preussischen Akademie der Wissenschaften, 93–95. Werke, Erster Band, ed. L. K RONECKER, 1889,
635–638. Reprint by Chelsea Publishing Co., 1969. [506, 509]
G. L EJEUNE D IRICHLET (1849), Über die Bestimmung der mittleren Werthe in der Zahlentheorie.
Abhandlungen der Königlich Preussischen Akademie der Wissenschaften, 69–83. Werke, Zweiter Band,
ed. L. K RONECKER, 1897, 51–66. Reprint by Chelsea Publishing Co., 1969. [62]
P. G. L EJEUNE D IRICHLET (1893), Vorlesungen über Zahlentheorie, herausgegeben von R. D EDEKIND.
Friedrich Vieweg & Sohn, Braunschweig, 4th edition. Corrected reprint, Chelsea Publishing Co.,
New York, 1968. First edition 1863. [707]
J OHN D. D IXON (1970), The Number of Steps in the Euclidean Algorithm. Journal of Number Theory 2,
414–422. [61]
J OHN D. D IXON (1981), Asymptotically Fast Factorization of Integers. Mathematics of Computation 36(153),
255–260. [541, 549, 569]
B RUCE D ODSON and A RJEN K. L ENSTRA (1995), NFS with Four Large Primes: An Explosive Experiment.
In Advances in Cryptology: Proceedings of CRYPTO ’95, Santa Barbara, CA, ed. D ON C OPPERSMITH.
Lecture Notes in Computer Science 963, Springer-Verlag, 372–385. [569]
K ARL D ÖRGE (1926), Über die Seltenheit der reduziblen Polynome und der Normalgleichungen.
Mathematische Annalen 95, 247–256. [466]
J EAN L OUIS D ORNSTETTER (1987), On the Equivalence Between Berlekamp’s and Euclid’s Algorithms. IEEE
Transactions on Information Theory IT-33(3), 428–431. [215]
M. W. D ROBISCH (1855), Über musikalische Tonbestimmung und Temperatur. Abhandlungen der
Mathematisch-Physischen Classe der Königlich Sächsischen Gesellschaft der Wissenschaften 4, 1–120
plus 1 table. [91]
T HOMAS W. D UBÉ (1990), The structure of polynomial ideals and Gröbner bases. SIAM Journal on
Computing 19(4), 750–773. [618]
R AYMOND D UBOIS (1971), Utilisation d’un théorème de Fermat à la découverte des nombres premiers et notes
sur les nombres de Fibonacci . Albert Blanchard, Paris. [532]
L IONEL D UCOS (2000), Optimizations of the subresultant algorithm. Journal of Pure and Applied Algebra 145,
149–163. [199]
ATHANASE D UPRÉ (1846), Sur le nombre des divisions a effectuer pour obtenir le plus grand commun diviseur
entre deux nombres entiers. Journal de Mathématiques Pures et Appliquées 11, 41–64. [61]
WAYNE E BERLY and E RICH K ALTOFEN (1997), On Randomized Lanczos Algorithms. In Proceedings of the
1997 International Symposium on Symbolic and Algebraic Computation ISSAC ’97, Maui HI, ed.
W OLFGANG W. K ÜCHLIN, ACM Press, 176–183. [353]
JACK E DMONDS (1967), Systems of Distinct Representatives and Linear Algebra. Journal of Research of the
National Bureau of Standards 71B(4), 241–245. [132]
D. E ISENBUD and L. ROBBIANO, eds. (1993), Computational algebraic geometry and commutative algebra.
Symposia Mathematica 34, Cambridge University Press, Cambridge, UK. [617]
References 743
D. E ISENBUD and B. S TURMFELS (1996), Binomial ideals. Duke Mathematical Journal 84(1), 1–45. [697]
G. E ISENSTEIN (1844), Einfacher Algorithmus zur Bestimmung des Werthes von ab . Journal für die reine und
angewandte Mathematik 27(4), 317–318. [533]
S HALOSH B. E KHAD (1990), A Very Short Proof of Dixon’s Theorem. Journal of Combinatorial Theory,
Series A 54, 141–142. [697]
S HALOSH B. E KHAD and S OL T RE (1990), A Purely Verification Proof of the First Rogers–Ramanujan
Identity. Journal of Combinatorial Theory, Series A 54, 309–311. [697]
I. Z. E MIRIS and B. M OURRAIN (1999), Computer Algebra Methods for Studying and Computing Molecular
Conformations. Algorithmica 25(2/3), 372–402. Special Issue on Algorithms for Computational Biology.
[698]
L EONHARD E ULER (1732/33), Observationes de theoremate quodam Fermatiano aliisque ad numeros primos
spectantibus. Commentarii academiae scientiarum imperalis Petropolitanae 6, 103–107. Eneström 26.
Opera Omnia, series 1, volume 2, B. G. Teubner, Leipzig, 1915, 1–5. [76, 88, 513, 542]
L EONHARD E ULER (1734/35a), Solutio problematis arithmetici de inveniendo numero qui per datos numeros
divisus relinquat data residua. Commentarii academiae scientiarum imperalis Petropolitanae 7, 46–66.
Eneström 36. Opera Omnia, series 1, volume 2, B. G. Teubner, Leipzig, 1915, 18–32. [131]
L EONHARD E ULER (1734/35b), De summis serierum reciprocarum. Commentarii Academiae Scientiarum
Petropolitanae 7, 123–134. Eneström 41. Opera Omnia, series 1, volume 14, B. G. Teubner, Leipzig,
1925, 73–86. [62]
L EONHARD E ULER (1736a), Mechanica sive motus scientia analytice exposita, Tomus I. Typographia
Academia Scientiarum, Petropolis. Opera Omnia, series 2, volume 1, B. G. Teubner, Leipzig, 1912. [90]
L EONHARD E ULER (1736b), Theorematum quorundam ad numeros primos spectantium demonstratio.
Commentarii academiae scientiarum imperalis Petropolitanae 8, 1741, 141–146. Eneström 54. Opera
Omnia, series 1, volume 2, B. G. Teubner, Leipzig, 1915, 33–37. [88]
L EONHARD E ULER (1737), De fractionibus continuis dissertatio. Commentarii academiae scientiarum
imperalis Petropolitanae 9, 1744, 98–137. Eneström 71. Opera Omnia, series 1, volume 14, B. G.
Teubner, Leipzig, 1925, 187–215. [89, 90, 91]
L EONHARD E ULER (1743), Démonstration de la somme de cette suite 1 + 14 + 19 + 16 1 1
+ 25 1
+ 36 + etc. Journal
littéraire d’Allemagne, de Suisse et du Nord (La Haye) 2, 115–127. Bibliotheca Mathematica, Serie 3, 8
1907–1908, 54–60. Eneström 63. Opera Omnia, series 1, volume 14, 177–186. [62]
L EONHARD E ULER (1747/48), Theoremata circa divisores numerorum. Novi commentarii academiae
scientiarum imperalis Petropolitanae 1, 20–48. Summarium ibidem, 35–37. Eneström 134. Opera Omnia,
series 1, volume 2, B. G. Teubner, Leipzig, 1915, 62–85. [131, 513, 542]
L EONHARD E ULER (1748a), Introductio in analysin infinitorum, tomus primus et secundus. M.-M. Bousquet,
Lausanne. Opera Omnia, series 1, volume 8 and 9. Teubner, Leipzig, 1922/1945. [62, 90, 132]
L EONHARD E ULER (1748b), Sur une contradiction apparente dans la doctrine des lignes courbes. Mémoires de
l’Académie des Sciences de Berlin 4, 1750, 219–233. Eneström 147. Opera Omnia, series 1, volume 26,
Orell Füssli, Zürich, 1953, 34–45. [198]
L EONHARD E ULER (1748c), Démonstration sur le nombre des points où deux lignes des ordres quelconques
peuvent se couper. Mémoires de l’Académie des Sciences de Berlin 4, 1750, 234–248. Eneström 148.
Opera Omnia, series 1, volume 26, Orell Füssli, Zürich, 1953, 46–59. [197, 198]
L EONHARD E ULER (1754/55), Demonstratio theorematis Fermatiani omnem numerum sive integrum sive
fractum esse summam quatuor pauciorumve quadratorum. Novi commentarii academiae scientiarum
imperalis Petropolitanae 5, 13–58. Summarium ibidem 6–7. Eneström 242. Opera Omnia, series 1,
volume 1, B. G. Teubner, Leipzig, 1915, 339–372. [418]
L EONHARD E ULER (1760/61), Theoremata arithmetica nova methodo demonstrata. Novi commentarii
academiae scientiarum imperalis Petropolitanae 8, 74–104. Summarium ibidem 15–18. Eneström 271.
Opera Omnia, series 1, volume 2, B. G. Teubner, Leipzig, 1915, 531–555. [131]
L EONHARD E ULER (1761), Theoremata circa residua ex divisione potestatum relicta. Novi commentarii
academiae scientiarum imperalis Petropolitanae 7, 49–82. Eneström 262. Opera Omnia, series 1,
volume 2, B. G. Teubner, Leipzig, 1915, 493–518. [76, 418]
L EONHARD E ULER (1762/63), Specimen algorithmi singularis. Novi commentarii academiae scientiarum
imperalis Petropolitanae 9, 1764, 53–69. Summarium ibidem 10–13. Eneström 281. Opera Omnia,
series 1, volume 15, B. G. Teubner, Leipzig, 1927, 31–49. [90]
L EONHARD E ULER (1764), Nouvelle méthode d’éliminer les quantités inconnues des équations. Mémoires de
l’Académie des Sciences de Berlin 20, 1766, 91–104. Eneström 310. Opera Omnia, series 1, volume 6,
B. G. Teubner, Leipzig, 1921, 197–211. [197, 198]
L EONHARD E ULER (1783), De eximio methodi interpolationum in serierum doctrina. Opuscula analytica 1,
157–210. Eneström 555. Opera Omnia, ser. 1, vol. 15, Teubner, Leipzig, 1927, 435–497. [134]
S ERGEI E VDOKIMOV (1994), Factorization of Polynomials over Finite Fields in Subexponential Time under
GRH. In Algorithmic Number Theory, First International Symposium, ANTS-I, Ithaca, NY, USA. Lecture
Notes in Computer Science 877, 209–219. [421]
744 References
G. F ROBENIUS (1896), Über Beziehungen zwischen den Primidealen eines algebraischen Körpers und den
Substitutionen seiner Gruppe. Sitzungsberichte der Königlich Preussischen Akademie der
Wissenschaften, Berlin, 689–702. [441, 465]
A. F RÖHLICH and J. C. S HEPHERDSON (1955–56), Effective procedures in field theory. Philosophical
Transactions of the Royal Society of London 248, 407–432. [419]
W. F ULTON (1969), Algebraic Curves. W. A. Benjamin, Inc., New York. [568]
M ARTIN F ÜRER (2009), Faster Integer Multiplication. SIAM Journal on Computing 39(3), 979–1005.
[222, 244, 247]
P. X. G ALLAGHER (1973), The large sieve and probabilistic Galois theory. In Analytic Number Theory, ed.
H AROLD G. D IAMOND. Proceedings of Symposia in Pure Mathematics 24, American Mathematical
Society, Providence RI, 91–101. [466]
G. G ALLO and B. M ISHRA (1991), Wu-Ritt Characteristic sets and Their Complexity. In Discrete and
Computational Geometry: Papers from the DIMACS Special Year, eds. JACOB E. G OODMAN, R ICHARD
P OLLACK, and W ILLIAM S TEIGER. DIMACS Series in Discrete Mathematics and Theoretical Computer
Science 6, American Mathematical Society and ACM, 111–136. [619]
É. G ALOIS (1830), Sur la théorie des nombres. Bulletin des sciences mathématiques Férussac 13, 428–435.
See also Journal de Mathématiques Pures et Appliquées 11 (1846), 398–407, and Écrits et mémoires
d’Évariste Galois, eds. ROBERT B OURGNE and J.-P. A ZRA, Gauthier-Villars, Paris, 1962, 112–128.
[198, 418, 421, 724, 728]
TAHER E L G AMAL (1985), A Public Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms.
IEEE Transactions on Information Theory IT-31(4), 469–472. [580]
S HUHONG G AO (2003), Factoring multivariate polynomials via partial differential equations. Mathematics of
Computation 72(242), 801–822. [420]
S HUHONG G AO and J OACHIM VON ZUR G ATHEN (1994), Berlekamp’s and Niederreiter’s Polynomial
Factorization Algorithms. In Finite Fields: Theory, Applications and Algorithms, eds. G. L. M ULLEN
and P. J.-S. S HIUE. Contemporary Mathematics 168, American Mathematical Society, 101–115. [420]
S HUHONG G AO, J OACHIM VON ZUR G ATHEN, and DANIEL PANARIO (1998), Gauss periods: orders and
cryptographical applications. Mathematics of Computation 67(221), 343–352. With microfiche
supplement. [88, 580]
S HUHONG G AO, J OACHIM VON ZUR G ATHEN, DANIEL PANARIO, and V ICTOR S HOUP (2000), Algorithms
for Exponentiation in Finite Fields. Journal of Symbolic Computation 29(6), 879–889. [88, 580]
S HUHONG G AO and DANIEL PANARIO (1997), Tests and Constructions of Irreducible Polynomials over Finite
Fields. In Foundations of Computational Mathematics, eds. F ELIPE C UCKER and M ICHAEL S HUB,
346–361. Springer Verlag. [419, 421]
M ICHAEL R. G AREY and DAVID S. J OHNSON (1979), Computers and intractability: A Guide to the Theory of
NP-Completeness. W. H. Freeman and Co., San Francisco CA. [509, 722]
H ARVEY L. G ARNER (1959), The Residue Number System. IRE Transactions on Electronic Computers,
140–147. [132]
J OACHIM VON ZUR G ATHEN (1984a), Hensel and Newton methods in valuation rings. Mathematics of
Computation 42(166), 637–661. [419, 466, 497, 500]
J OACHIM VON ZUR G ATHEN (1984b), Parallel algorithms for algebraic problems. SIAM Journal on
Computing 13(4), 802–824. [197, 199]
J OACHIM VON ZUR G ATHEN (1985), Irreducibility of Multivariate Polynomials. Journal of Computer and
System Sciences 31(2), 225–264. [466, 497, 498, 724]
J OACHIM VON ZUR G ATHEN (1986), Representations and parallel computations for rational functions. SIAM
Journal on Computing 15(2), 432–452. [131]
J OACHIM VON ZUR G ATHEN (1987), Factoring polynomials and primitive elements for special primes.
Theoretical Computer Science 52, 77–89. [421]
J OACHIM VON ZUR G ATHEN (1988), Algebraic complexity theory. Annual Review of Computer Science 3,
317–347. [352]
J OACHIM VON ZUR G ATHEN (1990a), Functional Decomposition of Polynomials: the Tame Case. Journal of
Symbolic Computation 9, 281–299. [286, 580, 581]
J OACHIM VON ZUR G ATHEN (1990b), Functional Decomposition of Polynomials: the Wild Case. Journal of
Symbolic Computation 10, 437–452. [580]
J OACHIM VON ZUR G ATHEN (1991a), Tests for permutation polynomials. SIAM Journal on Computing 20(3),
591–602. [497]
J OACHIM VON ZUR G ATHEN (1991b), Values of polynomials over finite fields. Bulletin of the Australian
Mathematical Society 43, 141–146. [425]
J OACHIM VON ZUR G ATHEN and J ÜRGEN G ERHARD (1996), Arithmetic and Factorization of Polynomials
over F2 . In Proceedings of the 1996 International Symposium on Symbolic and Algebraic Computation
ISSAC ’96, Zürich, Switzerland, ed. L AKSHMAN Y. N., ACM Press, 1–9. Technical report
746 References
C ARL F RIEDRICH G AUSS (1866), Theoria interpolationis methodo nova tractata. In Werke III, Nachlass,
265–330. Königliche Gesellschaft der Wissenschaften, Göttingen. Reprinted by Georg Olms Verlag,
Hildesheim New York, 1973. [90, 247]
L EOPOLD G EGENBAUER (1884), Asymptotische Gesetze der Zahlentheorie. Denkschriften der kaiserlichen
Akademie der Wissenschaften Wien 49, 37–80. [62]
W. M. G ENTLEMAN and G. S ANDE (1966), Fast Fourier transforms—for fun and profit. In Proceedings of the
Fall Joint Computer Conference, San Francisco CA. AFIPS Conference Proceedings 29, Spartan books,
Washington DC, 563–578. [247]
F RANÇOIS G ENUYS (1958), Dix mille décimales de π. Chiffres 1, 17–22. [82]
J OSEPH D IAZ G ERGONNE (1822), De la recherche des facteurs rationnels des polynomes. Annales de
mathématiques pures et appliquées 12, 309–316. [465]
J ÜRGEN G ERHARD (1998), High degree solutions of low degree equations. In Proceedings of the 1998
International Symposium on Symbolic and Algebraic Computation ISSAC ’98, Rostock, Germany, ed.
O LIVER G LOOR, ACM Press, 284–289. [674]
J ÜRGEN G ERHARD (2001a), Fast Modular Algorithms for Squarefree Factorization and Hermite Integration.
Applicable Algebra in Engineering, Communication and Computing 11(3), 203–226. [470, 640]
J ÜRGEN G ERHARD (2001b), Modular algorithms in symbolic summation and symbolic integration. Lecture
Notes in Computer Science 3218, Springer-Verlag, Berlin, Heidelberg. [641, 670]
J. G ERHARD, M. G IESBRECHT, A. S TORJOHANN, and E. V. Z IMA (2003), Shiftless Decomposition and
Polynomial-time Rational Summation. In Proceedings of the 2003 International Symposium on Symbolic
and Algebraic Computation ISSAC2003, Philadelphia PA, ed. J. R. S ENDRA, ACM Press, 119–126. [671]
M. G IESBRECHT, A. L OBO, and B. D. S AUNDERS (1998), Certifying Inconsistency of Sparse Linear Systems.
In Proceedings of the 1998 International Symposium on Symbolic and Algebraic Computation
ISSAC ’98, Rostock, Germany, ed. O LIVER G LOOR, ACM Press, 113–119. [353]
M ARK G IESBRECHT, A RNE S TORJOHANN, and G ILLES V ILLARD (2003), Algorithms for Matrix Canonical
Forms. In Computer Algebra Handbook – Foundations, Applications, Systems, eds. J OHANNES
G RABMEIER, E RICH K ALTOFEN, and VOLKER W EISPFENNING, 38–41. Springer-Verlag, Berlin,
Heidelberg, New York. [353]
J OHN G ILL (1977), Computational complexity of probabilistic Turing machines. SIAM Journal on
Computing 6(4), 675–695. [198]
A LESSANDRO G IOVINI, T EO M ORA, G IANFRANCO N IESI, L ORENZO ROBBIANO, and C ARLO T RAVERSO
(1991), “One sugar cube, please” or Selection strategies in the Buchberger algorithm. In Proceedings of
the 1991 International Symposium on Symbolic and Algebraic Computation ISSAC ’91, Bonn, Germany,
ed. S TEPHEN M. WATT, ACM Press, 49–54. [619]
M. G IUSTI (1984), Some effectivity problems in polynomial ideal theory. In Proceedings of EUROSAM ’84,
Cambridge, UK, ed. J OHN F ITCH, Lecture Notes in Computer Science 174, 159–171. Springer-Verlag,
Berlin. [618]
M ARC G IUSTI and J OOS H EINTZ (1991), Algorithmes – disons rapides – pour la décomposition d’une variété
algébrique en composantes irréductibles et équidimensionnelles. In Proceedings of Effective Methods in
Algebraic Geometry MEGA ’90, eds. T EO M ORA and C ARLO T RAVERSO. Progress in Mathematics 94,
Birkhäuser Verlag, Basel, 169–193. [619]
N OBUHIRO G Ō and H AROLD A. S CHERAGA (1970), Ring Closure and Local Conformational Deformations of
Chain Molecules. Macromolecules 3(2), 178–187. [698]
H ERMANN H. G OLDSTINE (1977), A History of Numerical Analysis from the 16th through the 19th Century.
Studies in the History of Mathematics and Physical Sciences 2, Springer-Verlag, New York. [286]
R. M. F. G OODMAN and A. J. M C AULEY (1984), A New Trapdoor Knapsack Public Key Cryptosystem.
In Advances in Cryptology: Proceedings of EUROCRYPT 1984, Paris, France, eds. T. B ETH, N. C OT,
and I. I NGEMARSSON. Lecture Notes in Computer Science 209, Springer-Verlag, Berlin, 150–158. [509]
PAUL G ORDAN (1885), Vorlesungen über Invariantentheorie. Erster Band: Determinanten. B. G. Teubner,
Leipzig. Herausgegeben von G EORG K ERSCHENSTEINER. [199, 332]
DANIEL M. G ORDON (1993), Discrete logarithms in GF(p) using the number field sieve. SIAM Journal on
Discrete Mathematics 6(1), 124–138. [579]
R. W ILLIAM G OSPER , J R . (1978), Decision procedure for indefinite hypergeometric summation. Proceedings
of the National Academy of Sciences of the USA 75(1), 40–42. [641, 662, 670, 671, 675]
R. G ÖTTFERT (1994), An acceleration of the Niederreiter factorization algorithm in characteristic 2.
Mathematics of Computation 62(206), 831–839. [420]
X AVIER G OURDON (1996), Combinatoire, Algorithmique et Géométrie des Polynômes. PhD thesis, École
Polytechnique, Paris. [419]
R. L. G RAHAM, D. E. K NUTH, and O. PATASHNIK (1994), Concrete Mathematics. Addison-Wesley,
Reading MA, 2nd edition. First edition 1989. [571, 669, 670, 717, 720]
J. P. G RAM (1883), Ueber die Entwickelung reeller Functionen in Reihen mittelst der Methode der kleinsten
Quadrate. Journal für die reine und angewandte Mathematik 94, 41–73. [496]
748 References
A NDREW G RANVILLE (1990), Bounding the Coefficients of a Divisor of a Given Polynomial. Monatshefte für
Mathematik 109, 271–277. [198]
D. Y U . G RIGOR ’ EV (1988), Complexity of deciding Tarski algebra. Journal of Symbolic Computation 4(1/2).
[619]
D IMA Y U . G RIGORIEV, M AREK K ARPINSKI, and M ICHAEL F. S INGER (1990), Fast parallel algorithms for
sparse multivariate polynomial interpolation over finite fields. SIAM Journal on Computing 19(6),
1059–1063. [498]
D IMA G RIGORIEV, M AREK K ARPINSKI, and M ICHAEL F. S INGER (1994), Computational complexity of
sparse rational interpolation. SIAM Journal on Computing 23(1), 1–11. [498]
H. F. DE G ROOTE (1987), Lectures on the Complexity of Bilinear Problems. Lecture Notes in Computer
Science 245, Springer-Verlag. [352]
M ARTIN G RÖTSCHEL, L ÁSZLÓ L OVÁSZ, and A LEXANDER S CHRIJVER (1993), Geometric Algorithms and
Combinatorial Optimization. Algorithms and Combinatorics 2, Springer-Verlag, Berlin, Heidelberg,
2nd edition. First edition 1988. [496]
L. J. G UIBAS and A. M. O DLYZKO (1980), Long Repetitive Patterns in Random Sequences. Zeitschrift für
Wahrscheinlichkeitstheorie und verwandte Gebiete 53, 241–262. [205]
R ICHARD K. G UY (1975), How to factor a number. In Proceedings of the Fifth Manitoba Conference on
Numerical Mathematics, 49–89. [568, 569]
WALTER H ABICHT (1948), Eine Verallgemeinerung des Sturmschen Wurzelzählverfahrens. Commentarii
Mathematici Helvetici 21, 99–116. [199]
J. H ADAMARD (1893), Résolution d’une question relative aux déterminants. Bulletin des Sciences
Mathématiques 17, 240–246. [496]
J. H ADAMARD (1896), Sur la distribution des zéros de la fonction ζ(s) et ses conséquences arithmétiques.
Bulletin de la Société mathématique de France 24, 199–220. [533]
A RMIN H AKEN (1985), The intractability of resolution. Theoretical Computer Science 39, 297–308. [678]
PAUL R. H ALMOS (1985), I want to be a mathematician. Springer-Verlag. [533]
J OHN H. H ALTON (1970), A retrospective and prospective survey of the Monte Carlo method. SIAM
Review 12(1), 1–63. [198]
R ICHARD W. H AMMING (1986), Coding and Information Theory. Prentice-Hall, Inc., Englewood Cliffs NJ,
2nd edition. First edition 1980. [308]
G. H. H ARDY (1937), The Indian Mathematician Ramanujan. The American Mathematical Monthly 44,
137–155. Collected Papers, volume VII, Clarendon Press, Oxford, 1979, 612–630. [535]
G ODFREY H AROLD H ARDY (1940), A mathematician’s apology. Cambridge University Press,
Cambridge, UK. [26, 726, 728]
G. H. H ARDY and E. M. W RIGHT (1985), An introduction to the theory of numbers. Clarendon Press, Oxford,
5th edition. First edition 1938. [62, 421, 532, 534]
W ILLIAM H ART, M ARK VAN H OEIJ, and A NDREW N OVOCIN (2011), Practical Polynomial Factoring in
Polynomial Time. In Proceedings of the 2011 International Symposium on Symbolic and Algebraic
Computation ISSAC2011, San Jose CA, ed. A NTON L EYKIN, ACM Press, 163–170. [497]
ROBIN H ARTSHORNE (1977), Algebraic Geometry. Graduate Texts in Mathematics 52, Springer-Verlag,
New York. [568]
M. W. H ASKELL (1891/92), Note on resultants. Bulletin of the New York Mathematical Society 1, 223–224.
[332]
H ELMUT H ASSE (1933), Beweis des Analogons der Riemannschen Vermutung für die Artinschen und F. K.
Schmidtschen Kongruenzzetafunktionen in gewissen elliptischen Fällen. Vorläufige Mitteilung.
Nachrichten von der Gesellschaft der Wissenschaften zu Göttingen, Mathematisch-Physikalische
Klasse 42, 253–262. [568]
J OHAN H ÅSTAD and M ATS N ÄSLUND (1998), The Security of Individual RSA Bits. In Proceedings of the 39th
Annual IEEE Symposium on Foundations of Computer Science, Palo Alto CA, IEEE Computer Society
Press, Los Alamitos CA, 510–519. [580]
T IMOTHY F. H AVEL and I GOR NAJFELD (1995), A new system of equations, based on geometric algebra,
for the ring closure in cyclic molecules. In Computer Algebra in Science and Engineering, Bielefeld,
Germany, August 1994, eds. J. F LEISCHER, J. G RABMEIER, F. W. H EHL, and W. K ÜCHLIN, World
Scientific, Singapore, 243–259. [698]
P. H AZEBROEK and L. J. O OSTERHOFF (1951), The isomers of cyclohexane. Discussions of the Faraday
Society 10, 88–93. [698]
T HOMAS L. H EATH, ed. (1925), The thirteen books of Euclid’s elements , vol. 1. Dover Publications, Inc.,
New York, Second edition. First edition appeared 1908. Translated from the text of Heiberg. [24, 25]
M ICHAEL T. H EIDEMAN, D ON H. J OHNSON, and C. S IDNEY B URRUS (1984), Gauss and the history of the
Fast Fourier Transform. IEEE ASSP Magazine, 14–21. [247]
H. H EILBRONN (1968), On the average length of a class of finite continued fractions. In Abhandlungen aus
Zahlentheorie und Analysis. Zur Erinnerung an Edmund Landau (1877–1938), ed. PAUL T ÚRAN, 87–96.
References 749
VEB Deutscher Verlag der Wissenschaften, Berlin. Also in Number Theory and Analysis, a Collection of
Papers in Honor of Edmund Landau (1877–1938), Plenum Press, New York, 1969. [61]
J OOS H EINTZ, TOMAS R ECIO, and M ARIE -F RANÇOISE ROY (1991), Algorithms in Real Algebraic Geometry
and Applications to Computational Geometry. In Discrete and Computational Geometry: Papers from the
DIMACS Special Year, eds. JACOB E. G OODMAN, R ICHARD P OLLACK, and W ILLIAM S TEIGER.
DIMACS Series in Discrete Mathematics and Theoretical Computer Science 6, American Mathematical
Society and ACM, 137–163. [619]
J OOS H EINTZ and M ALTE S IEVEKING (1981), Absolute Primality of Polynomials is Decidable in Random
Polynomial Time in the Number of Variables. In Proceedings of the 8th International Colloquium on
Automata, Languages and Programming ICALP 1981, Acre (‘Akko), Israel. Lecture Notes in Computer
Science 115, Springer-Verlag, 16–27. [497]
P ETER A. H ENDRIKS and M ICHAEL F. S INGER (1999), Solving Difference Equations in Finite Terms. Journal
of Symbolic Computation 27, 239–259. [671]
K URT H ENSEL (1918), Eine neue Theorie der algebraischen Zahlen. Mathematische Zeitschrift 2, 433–452.
[444, 466]
G RETE H ERMANN (1926), Die Frage der endlich vielen Schritte in der Theorie der Polynomideale.
Mathematische Annalen 95, 736–788. [616]
C. H ERMITE (1872), Sur l’intégration des fractions rationnelles. Annales de Mathématiques, 2 ème série 11,
145–148. [640]
N ICHOLAS J. H IGHAM (1990), Exploiting Fast Matrix Multiplication Within the Level 3 BLAS. ACM
Transactions on Mathematical Software 16(4), 352–368. [337]
DAVID H ILBERT (1890), Ueber die Theorie der algebraischen Formen. Mathematische Annalen 36, 473–534.
[586, 616, 618]
DAVID H ILBERT (1892), Ueber die Irreducibilität ganzer rationaler Functionen mit ganzzahligen Coefficienten.
Journal für die reine und angewandte Mathematik 110, 104–129. [495, 586]
DAVID H ILBERT (1893), Ueber die Transcendenz der Zahlen e und π. Mathematische Annalen 43, 216–219.
Nachrichten von der Königlichen Gesellschaft der Wissenschaften und der Georg-Augusts-Universität zu
Göttingen 2 (1893), 113–116. Reprinted in Berggren, Borwein & Borwein (1997), 226–229. [90]
DAVID H ILBERT (1900), Mathematische Probleme. Nachrichten von der Königlichen Gesellschaft der
Wissenschaften zu Göttingen, 253–297. Archiv für Mathematik und Physik, 3. Reihe 1 (1901), 44–63 and
213–237. English translation: Mathematical Problems, Bulletin of the American Mathematical Society 8
(1902), 437–479. [587, 726]
DAVID H ILBERT (1930), Probleme der Grundlegung der Mathematik. Mathematische Annalen 102, 1–9. [419]
H EISUKE H IRONAKA (1964), Resolution of singularities of an algebraic variety over a field of characteristic
zero. Annals of Mathematics 79(1), I: 109–203, II: 205–326. [591]
A. H OCQUENGHEM (1959), Codes correcteurs d’erreurs. Chiffres 2, 147–156. [215]
M ARK VAN H OEIJ (1998), Rational Solutions of Linear Difference Equations. In Proceedings of the 1998
International Symposium on Symbolic and Algebraic Computation ISSAC ’98, Rostock, Germany, ed.
O LIVER G LOOR, ACM Press, 120–123. [671]
M ARK VAN H OEIJ (1999), Finite singularities and hypergeometric solutions of linear recurrence equations.
Journal of Pure and Applied Algebra 139, 109–131. [671]
M ARK VAN H OEIJ (2002), Factoring polynomials and the knapsack problem. Journal of Number Theory 96(2),
167–189. [497]
J ORIS VAN DER H OEVEN (1997), Lazy Multiplication of Formal Power Series. In Proceedings of the 1997
International Symposium on Symbolic and Algebraic Computation ISSAC ’97, Maui HI, ed.
W OLFGANG W. K ÜCHLIN, ACM Press, 17–20. [469]
C. M. H OFFMAN, J. R. S ENDRA, and F. W INKLER, eds. (1997), Parametric Algebraic Curves and
Applications. Special Issue of the Journal of Symbolic Computation 23(2/3). [618]
D. G. H OFFMAN, D. A. L EONARD, C. C. L INDNER, K. T. P HELPS, C. A. RODGER, and J. R. WALL (1991),
Coding Theory: The Essentials. Marcel Dekker, Inc., New York. [215]
E LLIS H OROWITZ (1971), Algorithms for partial fraction decomposition and rational function integration.
In Proceedings 2nd ACM Symposium on Symbolic and Algebraic Manipulation, Los Angeles CA, ed.
S. R. P ETRICK, ACM Press, 441–457. [627]
E LLIS H OROWITZ (1972), A fast method for interpolation using preconditioning. Information Processing
Letters 1, 157–163. [306]
J EREMY H ORWITZ and R AMARATHNAM V ENKATESAN (2002), Random Cayley Digraphs and the Discrete
Logarithm. In Algorithmic Number Theory Symposium V, ANTS-V, eds. C LAUS F IEKER and DAVID R.
KOHEL. Lecture Notes in Computer Science 2369, Springer-Verlag, 100–114. [567]
M ING -D EH A. H UANG (1985), Riemann Hypothesis and Finding Roots over Finite Fields. In Proceedings of
the Seventeenth Annual ACM Symposium on Theory of Computing, Providence RI, ACM Press,
121–130. [421]
750 References
M ING -D EH H UANG and Y IU -C HUNG W ONG (1998), Extended Hilbert Irreducibility and its Applications.
In Proceedings of the 9th Annual ACM-SIAM Symposium on Discrete Algorithms SODA ’98, 50–58.
[498]
X IAOHAN H UANG and V ICTOR Y. PAN (1998), Fast Rectangular Matrix Multiplication and Applications.
Journal of Complexity 14, 257–299. [353, 405, 420]
DAVID A. H UFFMAN (1952), A Method for the Construction of Minimum-Redundancy Codes. Proceedings of
the I.R.E. 40(9), 1098–1101. [307, 368]
C HRISTIANUS H UGENIUS [C HRISTIAAN H UYGENS ] (1703), Descriptio Automati Planetarii. In Opuscula
postuma, quae continent: Dioptricam. Commentarios de vitris figurandis. Dissertationem de corona &
parheliis. Tractatum de motu/de vi centrifuga. Descriptionem automati planetarii. Cornelius Boutesteyn,
Leyden. [89]
T HOMAS W. H UNGERFORD (1990), Abstract Algebra: An Introduction. Saunders College Publishing,
Philadelphia PA. [703]
A. H URWITZ (1891), Ueber die angenäherte Darstellung der Irrationalzahlen durch rationale Brüche.
Mathematische Annalen 39, 279–284. [90]
D UNG T. H UYNH (1986), A Superexponential Lower Bound for Gröbner Bases and Church-Rosser
Commutative Thue Systems. Information and Control 68(1–3), 196–206. [618]
C. G. J. JACOBI (1836), De eliminatione variabilis e duabus aequationibus algebraicis. Journal für die reine und
angewandte Mathematik 15, 101–124. [197]
C. G. J. JACOBI (1846), Über die Darstellung einer Reihe gegebner Werthe durch eine gebrochne rationale
Function. Journal für die reine und angewandte Mathematik 30, 127–156. [132, 197]
C. G. J. JACOBI (1868), Allgemeine Theorie der kettenbruchähnlichen Algorithmen, in welchen jede Zahl aus
drei vorhergehenden gebildet wird. Journal für die reine und angewandte Mathematik 69, 29–64. [91]
T UDOR J EBELEAN (1997), Practical Integer Division with Karatsuba Complexity. In Proceedings of the 1997
International Symposium on Symbolic and Algebraic Computation ISSAC ’97, Maui HI, ed.
W OLFGANG W. K ÜCHLIN, ACM Press, 339–341. [286]
DAVID S. J OHNSON (1990), A Catalog of Complexity Classes. In Handbook of Theoretical Computer Science,
vol. A, ed. J. VAN L EEUWEN, 67–161. Elsevier Science Publishers B.V., Amsterdam, and The MIT Press,
Cambridge MA. [724]
W ILLIAM J ONES (1706), Synopsis Palmariorum Matheseos: or, a New Introduction to the Mathematics,
London. [90]
C HARLES J ORDAN (1965), Calculus of finite differences. Chelsea Publishing Company, New York. First
edition Röttig and Romwalter, Sopron, Hungary, 1939. [669]
N ORBERT K AJLER and N EIL S OIFFER (1998), A Survey of User Interfaces for Computer Algebra Systems.
Journal of Symbolic Computation 25, 127–159. [21]
K. K ALORKOTI (1993), Inverting polynomials and formal power series. SIAM Journal on Computing 22(3),
552–559. [286]
E. K ALTOFEN (1982), Factorization of Polynomials. In Computer Algebra, Symbolic and Algebraic
Computation, eds. B. B UCHBERGER, G. E. C OLLINS, and R. L OOS, 95–113. Springer-Verlag,
New York, 2nd edition. [419]
E RICH K ALTOFEN (1983), On the Complexity of Finding Short Vectors in Integer Lattices. In Proceedings of
EUROCAL 1983, London, UK. Lecture Notes in Computer Science 162, Springer-Verlag, Berlin /
New York, 236–244. [497]
E RICH K ALTOFEN (1984), A Note on the Risch Differential Equation. In Proceedings of EUROSAM ’84,
Cambridge, UK, ed. J OHN F ITCH. Lecture Notes in Computer Science 174, Springer-Verlag, Berlin,
359–366. [641]
E RICH K ALTOFEN (1985a), Polynomial-time reductions from multivariate to bi- and univariate integral
polynomial factorization. SIAM Journal on Computing 14(2), 469–489. [497]
E RICH K ALTOFEN (1985b), Effective Hilbert Irreducibility. Journal of Computer and System Sciences 66,
123–137. [498]
E. K ALTOFEN (1989), Factorization of Polynomials Given by Straight-Line Programs. In Randomness and
Computation, ed. S. M ICALI, JAI Press, Greenwich CT, 375–412. [495, 497]
E. K ALTOFEN (1990), Polynomial factorization 1982–1986. In Computers in Mathematics, eds. D. V.
C HUDNOVSKY and R. D. J ENKS, Marcel Dekker, Inc., New York, 285–309. [419]
E. K ALTOFEN (1992), Polynomial Factorization 1987–1991. In Proceedings of LATIN ’92, São Paulo, Brazil,
ed. I. S IMON. Lecture Notes in Computer Science 583, Springer-Verlag, 294–313. [419]
E RICH K ALTOFEN (1995a), Effective Noether Irreducibility Forms and Applications. Journal of Computer and
System Sciences 50(2), 274–295. [498]
E RICH K ALTOFEN (1995b), Analysis of Coppersmith’s block Wiedemann algorithm for the parallel solution of
sparse linear systems. Mathematics of Computation 64(210), 777–806. [353]
References 751
E RICH K ALTOFEN (2000), Challenges of Symbolic Computation: My Favourite Open Problems. Journal of
Symbolic Computation 29(6), 891–919. With an Additional Open Problem By ROBERT M. C ORLESS
and DAVID J. J EFFREY. [353]
E RICH K ALTOFEN and L AKSHMAN YAGATI (1988), Improved Sparse Multivariate Polynomial Interpolation
Algorithms. In Proceedings of the 1988 International Symposium on Symbolic and Algebraic
Computation ISSAC ’88, Rome, Italy, ed. P. G IANNI. Lecture Notes in Computer Science 358,
Springer-Verlag, 467–474. [498]
E. K ALTOFEN and A. L OBO (1994), Factoring High-Degree Polynomials by the Black Box Berlekamp
Algorithm. In Proceedings of the 1994 International Symposium on Symbolic and Algebraic Computation
ISSAC ’94, Oxford, UK, eds. J. VON ZUR G ATHEN and M. G IESBRECHT, ACM Press, 90–98. [404, 405]
E RICH K ALTOFEN, DAVID R. M USSER, and B. DAVID S AUNDERS (1983), A generalized class of polynomials
that are hard to factor. SIAM Journal on Computing 12(3), 473–483. [465]
E RICH K ALTOFEN and H EINRICH ROLLETSCHEK (1989), Computing greatest common divisors and
factorizations in quadratic number fields. Mathematics of Computation 53(188), 697–720. [132]
E RICH K ALTOFEN and B. DAVID S AUNDERS (1991), On Wiedemann’s Method of Solving Sparse Linear
Systems. In Algebraic Algorithms and Error-Correcting Codes: AAECC-10, San Juan de Puerto Rico.
Lecture Notes in Computer Science 539, Springer-Verlag, 29–38. [340, 351, 404]
E RICH K ALTOFEN and V ICTOR S HOUP (1997), Fast Polynomial Factorization Over High Algebraic Extensions
of Finite Fields. In Proceedings of the 1997 International Symposium on Symbolic and Algebraic
Computation ISSAC ’97, Maui HI, ed. W OLFGANG W. K ÜCHLIN, ACM Press, 184–188. [420]
E RICH K ALTOFEN and V ICTOR S HOUP (1998), Subquadratic-Time Factoring of Polynomials over Finite
Fields. Mathematics of Computation 67(223), 1179–1197. Extended Abstract in Proceedings of the
Twenty-seventh Annual ACM Symposium on the Theory of Computing, Las Vegas NV, ACM Press,
1995, 398–406. [401, 405, 406, 420]
E RICH K ALTOFEN and BARRY M. T RAGER (1990), Computing with Polynomials Given By Black Boxes for
Their Evaluations: Greatest Common Divisors, Factorization, Separation of Numerators and
Denominators. Journal of Symbolic Computation 9, 301–320. [496, 498]
M ICHAEL K AMINSKI, DAVID G. K IRKPATRICK, and NADER H. B SHOUTY (1988), Addition Requirements for
Matrix and Transposed Matrix Products. Journal of Algorithms 9, 354–364. [353]
YASUMASA K ANADA (1988), Vectorization of Multiple-Precision Arithmetic Program and 201, 326, 000
Decimal Digits of π Calculation. In Supercomputing ’88, Volume II: Science and Applications, 117–128.
Reprinted in Berggren, Borwein & Borwein (1997), 576–587. [247]
R AVI K ANNAN (1987), Algorithmic geometry of numbers. Annual Review of Computer Science 2, 231–267.
[496]
A. A. K ARATSUBA (1995), The Complexity of Computations. Proceedings of the Steklov Institute of
Mathematics 211, 169–183. Translated from Trudy Matematiqeskogo Instituta imeni
V. A. Steklova 211 (1995), 186–202. [247]
A. Karacuba i . Ofman (1962), Umnoжenie mnogoznaqnyh qisel na avtomatah.
Doklady Akademii Nauk SSSR 145, 293–294. A. K ARATSUBA and Y U . O FMAN, Multiplication
of multidigit numbers on automata, Soviet Physics–Doklady 7 (1963), 595–596. [223, 245]
A LAN H. K ARP and P ETER M ARKSTEIN (1997), High-Precision Division and Square Root. ACM
Transactions on Mathematical Software 23(4), 561–589. [286]
R ICHARD M. K ARP (1972), Reducibility among combinatorial problems. In Complexity of computer
computations, eds. R AYMOND E. M ILLER and JAMES W. T HATCHER, 85–103. Plenum Press, New York.
[509, 722]
M ICHAEL K ARR (1981), Summation in Finite Terms. Journal of the ACM 28(2), 305–350. [671]
M ICHAEL K ARR (1985), Theory of Summation in Finite Terms. Journal of Symbolic Computation 1, 303–315.
[671]
K IRAN S. K EDLAYA and C HRISTOPHER U MANS (2008), Fast modular composition in any characteristic.
In Proceedings of the 49th Annual IEEE Symposium on Foundations of Computer Science,
Philadelphia, PA, IEEE Computer Society Press, 146–155. [751]
K IRAN S. K EDLAYA and C HRISTOPHER U MANS (2009), Fast polynomial factorization and modular
composition. Merged work of Kedlaya & Umans (2008) and Umans (2008). SIAM Journal on Computing,
to appear. Conference version in Proceedings of the 49th Annual IEEE Symposium on Foundations of
Computer Science, Philadelphia, PA, 481-490. IEEE Computer Society Press. [339, 405, 406, 408, 420]
WALTER K ELLER -G EHRIG (1985), Fast algorithms for the characteristic polynomial. Theoretical Computer
Science 36, 309–317. [352]
H. K EMPFERT (1969), On the Factorization of Polynomials. Journal of Number Theory 1, 116–120. [417, 466]
T HORSTEN K LEINJUNG, K AZUMARO AOKI, J ENS F RANKE, A RIEN K. L ENSTRA, E MMANUEL T HOMÉ,
J OPPE W. B OS, P IERRICK G AUDRY, A LEXANDER K RUPPA P ETER L. M ONTGOMERY, DAG A RNE
O SVIK, H ERMAN TE R IELE, A NDREY T IMOFEEV and PAUL Z IMMERMANN (2010), Factorization of a
768-Bit RSA Modulus. In Advances in Cryptology: Proceedings of CRYPTO ’10, Santa Barbara, CA,
752 References
ed. TAL R ABIN. Lecture Notes in Computer Science 6223, Springer-Verlag, Berlin, Heidelberg, New
York, 333–350. [542]
A RNOLD K NOPFMACHER (1995), Enumerating basic properties of polynomials over a finite field. South
African Journal of Science 91, 10–11. [419]
A RNOLD K NOPFMACHER and J OHN K NOPFMACHER (1993), Counting irreducible factors of polynomials over
a finite field. Discrete Mathematics 112, 103–118. [419]
A RNOLD K NOPFMACHER and R ICHARD WARLIMONT (1995), Distinct degree factorizations for polynomials
over a finite field. Transactions of the American Mathematical Society 347(6), 2235–2243. [419]
D ONALD E. K NUTH (1970), The analysis of algorithms. In Proceedings of the International Congress of
Mathematicians 1970, Nice, France, vol. 3, 269–274. [332, 724]
D ONALD E. K NUTH (1993), Johann Faulhaber and sums of powers. Mathematics of Computation 61(203),
277–294. [670]
D ONALD E. K NUTH (1997), The Art of Computer Programming, vol. 1, Fundamental Algorithms.
Addison-Wesley, Reading MA, 3rd edition. First edition 1969. [308]
D ONALD E. K NUTH (1998), The Art of Computer Programming, vol. 2, Seminumerical Algorithms.
Addison-Wesley, Reading MA, 3rd edition. First edition 1969.
[25, 40, 61, 62, 88, 90, 247, 286, 417, 505, 531, 567]
D ONALD E. K NUTH and L UIS T RABB PARDO (1976), Analysis of a simple factorization algorithm.
Theoretical Computer Science 3(3), 321–348. [567]
N EAL KOBLITZ (1987a), A Course in Number Theory and Cryptography. Graduate Texts in Mathematics 114,
Springer-Verlag, New York. [531, 568]
N EAL KOBLITZ (1987b), Elliptic Curve Cryptosystems. Mathematics of Computation 48(177), 203–209. [580]
H ELGE VON KOCH (1904), Sur une courbe continue sans tangente obtenue par une construction géométrique
élémentaire. Arkiv för matematik, astronomi och fysik 1, 681–702. [287]
W OLFRAM KOEPF (1995), Algorithms for m-fold Hypergeometric Summation. Journal of Symbolic
Computation 20, 399–417. [671]
W OLFRAM KOEPF (1998), Hypergeometric Summation. Advanced Lectures in Mathematics, Friedrich Vieweg
& Sohn, Braunschweig / Wiesbaden. [670, 697]
J ÁNOS KOLLÁR (1988), Sharp effective Nullstellensatz. Journal of the American Mathematical Society 1(4),
963–975. [618]
A LWIN KORSELT (1899), Problème chinois. L’Intermédiaire des Mathématiciens 6, p. 143. [532]
H ENRIK KOY and C LAUS P ETER S CHNORR (2001a), Segment LLL-Reduction of Lattice Bases.
In Cryptography and Lattices, International Conference (CaLC 2001), Providence RI, ed. J OSEPH H.
S ILVERMAN. Lecture Notes in Computer Science 2146, Springer-Verlag, 67–80. [497]
H ENRIK KOY and C LAUS P ETER S CHNORR (2001b), Segment LLL-Reduction with Floating Point
Orthogonalization. In Cryptography and Lattices, International Conference (CaLC 2001), Providence RI,
ed. J OSEPH H. S ILVERMAN. Lecture Notes in Computer Science 2146, Springer-Verlag, 81–96. [497]
D EXTER KOZEN and S USAN L ANDAU (1986), Polynomial Decomposition Algorithms. Technical Report
86-773, Department of Computer Science, Cornell University, Ithaca NY. [752]
D EXTER KOZEN and S USAN L ANDAU (1989), Polynomial Decomposition Algorithms. Journal of Symbolic
Computation 7, 445–456. An earlier version was published as Kozen & Landau (1986). [576, 581]
L EON G. K RAFT , J R . (1949), A Device for Quantizing, Grouping, and Coding Amplitude Modulated Pulses.
M.Sc. thesis, Electrical Engineering Department, M.I.T. [307]
M. K RAÏTCHIK (1926), Théorie des Nombres, vol. II. Gauthier-Villars, Paris. [567, 727, 728]
J. K RAJÍ ČEK (1995), Bounded arithmetic, propositional logic and complexity theory. Encyclopedia of
Mathematics and its Applications 60, Cambridge University Press, Cambridge, UK. [697]
L. K RONECKER (1873), Die verschiedenen Sturm schen Reihen und ihre gegenseitigen Beziehungen.
Monatsberichte der Königlich Preussischen Akademie der Wissenschaften, Berlin, 117–154. [197]
L. K RONECKER (1878), Über Sturm sche Functionen. Monatsberichte der Königlich Preussischen Akademie
der Wissenschaften, Berlin, 95–121. Werke, Zweiter Band, ed. K. H ENSEL, Leipzig, 1897, 37–70.
Reprint by Chelsea Publishing Co., New York, 1968. [197]
L. K RONECKER (1881a), Zur Theorie der Elimination einer Variabeln aus zwei algebraischen Gleichungen.
Monatsberichte der Königlich Preussischen Akademie der Wissenschaften, Berlin, 535–600. Werke,
Zweiter Band, ed. K. H ENSEL, Leipzig, 1897, 113–192. Reprint by Chelsea Publishing Co., New York,
1968. [132, 137, 353]
L. K RONECKER (1881b), Auszug aus einem Briefe des Herrn Kronecker an E. Schering. Nachrichten der
Akademie der Wissenschaften, Göttingen, 271–279. [197]
L. K RONECKER (1882), Grundzüge einer arithmetischen Theorie der algebraischen Grössen. Journal für die
reine und angewandte Mathematik 92, 1–122. Werke, Zweiter Band, ed. K. H ENSEL, Leipzig, 1897,
237–387. Reprint by Chelsea Publishing Co., New York, 1968. [247, 465]
L EOPOLD K RONECKER (1883), Die Zerlegung der ganzen Grössen eines natürlichen Rationalitäts-Bereichs in
ihre irreductibeln Factoren. Journal für die reine und angewandte Mathematik 94, 344–348. Werke,
References 753
Zweiter Band, ed. K. H ENSEL, Leipzig, 1897, 409–416. Reprint by Chelsea Publishing Co., New York,
1968. [465]
A. N. Krylov [A. N. K RYLOV ] (1931), O qislennom rexenii uravneni, kotorym v
tehniqeskih voprosah opredel ts qastoty malyh kolebani i materialьnyh
sistem (On numerical solutions which determine the frequencies of small oscillations of material
systems in technical problems). Izvesti Akademii Nauk SSSR, Otdelenie
Matematiqeskih i estestvennyh nauk (Bulletin de l’académie des sciences de l’URSS, Classe
des sciences mathématiques et naturelles) 4, 491–539. [353]
Y. H. K U and X IAOGUANG S UN (1992), The Chinese Remainder Theorem. Journal of the Franklin
Institute 329, 93–97. [131]
K LAUS K ÜHNLE and E RNST W. M AYR (1996), Exponential Space Computation of Gröbner Bases.
In Proceedings of the 1996 International Symposium on Symbolic and Algebraic Computation
ISSAC ’96, Zürich, Switzerland, ed. L AKSHMAN Y. N., ACM Press, 63–71. [616, 617]
H. T. K UNG (1974), On Computing Reciprocals of Power Series. Numerische Mathematik 22, 341–348. [286]
J. C. L AFON (1983), Summation in Finite Terms. In Computer Algebra, Symbolic and Algebraic Computation,
eds. B. B UCHBERGER, G. E. C OLLINS, and R. L OOS, 71–77. Springer-Verlag, New York, 2nd edition.
[671]
J. C. L AGARIAS (1982a), Best simultaneous Diophantine approximations. I. Growth rates of best approximation
denominators. Transactions of the American Mathematical Society 272(2), 545–554. [509]
J. C. L AGARIAS (1982b), Best simultaneous Diophantine approximations. II. Behavior of consecutive best
approximations. Pacific Journal of Mathematics 102(1), 61–88. [509]
J. C. L AGARIAS (1985), The computational complexity of simultaneous Diophantine approximation problems.
SIAM Journal on Computing 14(1), 196–209. [506, 509]
J. C. L AGARIAS (1990), Pseudorandom Number Generators in Cryptography and Number Theory.
In Cryptology and Computational Number Theory, ed. C ARL P OMERANCE. Proceedings of Symposia in
Applied Mathematics 42, American Mathematical Society, 115–143. [509, 580]
J. C. L AGARIAS and A. M. O DLYZKO (1977), Effective Versions of the Chebotarev Density Theorem.
In Algebraic Number Fields, ed. A. F RÖHLICH, 409–464. Academic Press, London. [443]
J. C. L AGARIAS and A. M. O DLYZKO (1985), Solving Low-Density Subset Sum Problems. Journal of
the ACM 32(1), 229–246. [509]
J OSEPH L OUIS DE L AGRANGE (1759), Recherches sur la méthode de maximis et minimis. Miscellanea
Taurinensia 1. Œuvres, publiées par J.-A. S ERRET, vol. 1, 1867, Gauthier-Villars, Paris, 1–20. [131]
J OSEPH L OUIS DE L AGRANGE (1769), Sur la résolution des équations numériques. Mémoires de l’Académie
des Sciences et Belles-Lettres de Berlin 23. Œuvres, publiées par J.-A. S ERRET, vol. 2, 1868,
Gauthier-Villars, Paris, 539–578. [419]
J OSEPH L OUIS DE L AGRANGE (1770a), Additions au mémoire sur la résolution des équations numériques.
Mémoires de l’Académie des Sciences et Belles-Lettres de Berlin 24. Œuvres, publiées par J.-A.
S ERRET, vol. 2, 1868, Gauthier-Villars, Paris, 581–652. [90]
J OSEPH L OUIS DE L AGRANGE (1770b), Nouvelle méthode pour résoudre les problèmes indéterminés en
nombres entiers. Mémoires de l’Académie des Sciences et Belles-Lettres de Berlin 24. Œuvres, publiées
par J.-A. S ERRET, vol. 2, 1868, Gauthier-Villars, Paris, 655–726. [131]
J OSEPH L OUIS DE L AGRANGE (1795), Sur l’usage des courbes dans la solution des Problèmes. In Leçons
élémentaires sur les mathématiques, Leçon cinquième. École Polytechnique, Paris. Œuvres, publiées par
J.-A. S ERRET, vol. 7, 1877, Gauthier-Villars, Paris, 271–287. [131, 728]
J OSEPH L OUIS DE L AGRANGE (1798), Additions aux éléments d’algèbre d’Euler. Analyse indéterminée.
In L EONHARD E ULER, Éléments d’algèbre, St. Petersburg. Œuvres, publiées par J.-A. S ERRET, vol. 7,
1877, Gauthier-Villars, Paris, 5–180. [90, 91]
L AKSHMAN Y. N. (1990), On the Complexity of Computing a Gröbner Basis for the Radical of a Zero
Dimensional Ideal. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of
Computing, Baltimore MD, ACM Press, 555–563. [618]
B. A. L A M ACCHIA and A. M. O DLYZKO (1990), Solving large sparse linear systems over finite fields.
In Advances in Cryptology: Proceedings of CRYPTO ’90, Santa Barbara, CA. Lecture Notes in Computer
Science 537, Springer-Verlag, Berlin and New York, 109–133. [353]
L ARRY A. L AMBE, ed. (1997), Special Issue on Applications of Symbolic Computation to Research and
Education. Journal of Symbolic Computation 23(5/6). [21]
L AMBERT (1761), Mémoire sur quelques propriétés remarquables des quantités transcendentes circulaires et
logarithmiques. Histoire de l’Académie Royale des Sciences et des Belles-Lettres de Berlin 17, 265–322.
Reprint of pages 265–276 in Berggren, Borwein & Borwein (1997), 129–140. [82]
G ABRIEL L AMÉ (1844), Note sur la limite du nombre des divisions dans la recherche du plus grand commun
diviseur entre deux nombres entiers. Comptes Rendus de l’Académie des Sciences Paris 19, 867–870.
[61]
754 References
C. L ANCZOS (1952), Solutions of systems of linear equations by minimized iterations. Journal of Research of
the National Bureau of Standards 49, 33–53. [353]
E. L ANDAU (1905), Sur quelques théorèmes de M. Petrovitch relatifs aux zéros des fonctions analytiques.
Bulletin de la Société Mathématique de France 33, 251–261. [165]
F. L ANDRY (1880), Note sur la décomposition du nombre 264 + 1 (Extrait). Comptes Rendus de l’Académie des
Sciences Paris 91, p. 138. [542]
S ERGE L ANG (1983), Fundamentals of Diophantine Geometry . Springer-Verlag, New York. [498]
TANJA L ANGE and A RNE W INTERHOF (2000), Factoring polynomials over arbitrary finite fields. Theoretical
Computer Science 234, 301–308. [421]
DE LA P LACE (1772), Recherches sur le calcul intégral et sur le système du monde. Mémoires de l’Académie
Royale des Sciences II. Œuvres complètes de Laplace, vol. 8, Gauthier-Villars, Paris, 1891, 367–501.
[724]
DANIEL L AUER (2000), Effiziente Algorithmen zur Berechnung von Resultanten und Subresultanten. Berichte
aus der Informatik, Shaker Verlag, Aachen. PhD thesis, University of Bonn, Germany. [198, 466]
D. L AZARD and R. R IOBOO (1990), Integration of Rational Functions: Rational Computation of the
Logarithmic Part. Journal of Symbolic Computation 9, 113–115. [640]
V.-A. L EBESGUE (1847), Sur le symbole ba et quelques-unes de ses applications. Journal de Mathématiques
Pures et Appliquées 12, 497–517. [533]
A. M. L EGENDRE (1785), Recherches d’analyse indéterminée. Mémoires de l’Académie Royale des Sciences,
465–559. [198, 418, 420, 466, 468, 569]
A. M. LE G ENDRE (1798, An VI), Essai sur la théorie des nombres. Duprat, Paris. [418, 533, 728]
D. J. L EHMANN (1982), On primality tests. SIAM Journal on Computing 11, 374–375. [537]
D. H. L EHMER (1930), An extended theory of Lucas’ functions. Annals of Mathematics, Series II 31, 419–448.
[530]
D. H. L EHMER (1935), On Lucas’s test for the primality of Mersenne’s numbers. Journal of the London
Mathematical Society 10, 162–165. [530]
D. H. L EHMER (1938), Euclid’s algorithm for large numbers. The American Mathematical Monthly 45,
227–233. [332]
D. H. L EHMER and R. E. P OWERS (1931), On factoring large numbers. Bulletin of the American Mathematical
Society 37, 770–776. [569]
G OTTFRIED W ILHELM L EIBNIZ (1683), Draft letter to Tschirnhaus. In Der Briefwechsel von Gottfried
Wilhelm Leibniz mit Mathematikern, Erster Band, ed. C. I. G ERHARDT, 446–450. Mayer & Müller,
Berlin, 1899. Reprinted by Georg Olms Verlag, Hildesheim, 1987. [197]
G OTTFRIED W ILHELM L EIBNIZ (1697), Nova algebrae promotio. Undated manuscript, c. 1697.
In Mathematische Schriften, vol. 7, ed. C. I. G ERHARDT, 154–189. Halle, 1863. In: Gesammelte Werke
aus den Handschriften der Königlichen Bibliothek zu Hannover, Band VII, Kapitel XV, reprinted by
Georg Olms Verlag, Hildesheim, 1971. [88]
G OTTFRIED W ILHELM L EIBNIZ (1701), Initia mathematica. De ratione et proportione. Undated manuscript,
c. 1701. In Mathematische Schriften, vol. 7, ed. C. I. G ERHARDT, 1863, 40–49. Reprinted by Georg
Olms Verlag, Hildesheim, 1971. [89]
G OTHOFREDUS W ILHELMUS L EIBNITZ [G OTTFRIED W ILHELM L EIBNIZ ] (1703), Continuatio analyseos
quadraturarum rationalium. Acta eruditorum, 19–26. [640]
F RANZ L EMMERMEYER (1995), The Euclidean algorithm in algebraic number fields. Expositiones
Mathematicae 13, 385–416. [724]
A RJEN K. L ENSTRA (1984), Factoring Polynomials over Algebraic Number Fields. In Proceedings of the 11th
International Symposium Mathematical Foundations of Computer Science 1984, Praha, Czechoslovakia.
Lecture Notes in Computer Science 176, 389–396. [465]
A RJEN K. L ENSTRA (1987), Factoring multivariate polynomials over algebraic number fields. SIAM Journal
on Computing 16, 591–598. [465]
A RJEN K. L ENSTRA (1990), Primality Testing. In Cryptology and Computational Number Theory, ed. C ARL
P OMERANCE. Proceedings of Symposia in Applied Mathematics 42, American Mathematical Society,
13–25. [531]
A RJEN K. L ENSTRA and H ENDRIK W. L ENSTRA , J R . (1990), Algorithms in Number Theory. In Handbook of
Theoretical Computer Science, vol. A, ed. J. VAN L EEUWEN, 673–715. Elsevier Science Publishers B.V.,
Amsterdam, and The MIT Press, Cambridge MA. [531]
A RJEN K. L ENSTRA and H ENDRIK W. L ENSTRA , J R ., eds. (1993), The development of the number field sieve.
Lecture Notes in Mathematics 1554, Springer-Verlag, Berlin. [569]
A. K. L ENSTRA, H. W. L ENSTRA , J R ., and L. L OVÁSZ (1982), Factoring Polynomials with Rational
Coefficients. Mathematische Annalen 261, 515–534. [474, 497, 506]
A RJEN K. L ENSTRA, H ENDRIK W. L ENSTRA , J R ., M. S. M ANASSE, and J. M. P OLLARD (1990),
The number field sieve. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of
Computing, Baltimore MD, ACM Press, 564–572. [569]
References 755
É DOUARD L UCAS (1878), Théorie des fonctions numériques simplement périodiques. American Journal of
Mathematics 1, I: 184–240, II: 289–321. [530]
PAUL L UCKEY (1951), Die Rechenkunst bei Ǧamšı̄d b. Mas֒ūd al-Kāšı̄ . Abhandlungen für die Kunde des
Morgenlandes, XXXI,1, Kommissionsverlag Franz Steiner GmbH, Wiesbaden. Herausgegeben von der
Deutschen Morgenländischen Gesellschaft. [725]
P. L UCKEY (1953), Der Lehrbrief über den Kreisumfang (Ar-risāla al-muh.ı̄tı̄ya) von Ǧamšı̄d B. Mas֒ūd
Al-Kāšı̄ . Abhandlungen der Deutschen Akademie der Wissenschaften zu Berlin, Klasse für Mathematik
und allgemeine Naturwissenschaften 6, Akademie-Verlag, Berlin. [90]
J. VAN DE L UNE, H. J. J. TE R IELE, and D. T. W INTER (1986), On the Zeros of the Riemann Zeta Function in
the Critical Strip. IV. Mathematics of Computation 46(174), 667–681. [533]
K EJU M A and J OACHIM VON ZUR G ATHEN (1990), Analysis of Euclidean Algorithms for Polynomials over
Finite Fields. Journal of Symbolic Computation 9, 429–455. [62]
F. S. M ACAULAY (1902), Some formulæ in elimination. Proceedings of the London Mathematical Society 35,
3–27. [197, 619]
F. S. M ACAULAY (1916), The algebraic theory of modular systems. Cambridge University Press,
Cambridge, UK. Reissued 1994. [197, 619, 728, 729]
F. S. M ACAULAY (1922), Note on the resultant of a number of polynomials of the same degree. Proceedings of
the London Mathematical Society, Second Series 21, 14–21. [197, 619]
D. M ACK (1975), On rational integration. Technical Report UCP-38, Department of Computer Science,
University of Utah. [642]
C OLIN M ACLAURIN (1742), A treatise of fluxions. 2 volumes, Edinburgh. 2nd ed., London, 1801; French
translation Paris, 1749. [286]
F. J. M AC W ILLIAMS and N. J. A. S LOANE (1977), The Theory of Error-Correcting Codes. Mathematical
Library 16, North-Holland, Amsterdam. [215]
D IETRICH M AHNKE (1912/13), Leibniz auf der Suche nach einer allgemeinen Primzahlgleichung. Bibliotheca
Mathematica, Serie 3, 13, 29–61. [88, 531]
Y IU -K WONG M AN (1993), On Computing Closed Forms for Indefinite Summations. Journal of Symbolic
Computation 16, 355–376. [671]
B ENOÎT B. M ANDELBROT (1977), The fractral geometry of nature. Freeman. [278]
. I. Manin (1956), O sravnenih tretьe i stepeni po prostomu modul . Izvesti
Akademii Nauk SSSR, Seri Matematiqeska 20, 673–678. Y U . I. M ANIN, On cubic
congruences to a prime modulus, American Mathematical Society Translations, Series 2, 13 (1960), 1–7.
[568]
J. L. M ASSEY (1965), Step by step decoding of the Bose-Chaudhuri-Hocquenghem codes. IEEE Transactions
on Information Theory IT-11, 580–585. [215]
. V. Matiseviq (1970), Diofantovostь pereqislimih mnoжestv. Doklady Akademii
Nauk SSSR 191(2), 279–282. Y U . V. M ATIYASEVICH, Enumerable sets are Diophantine, Soviet
Mathematics Doklady 11(2), 354–358. [89]
rii V. Matiseviq (1993), Desta problema Gilьberta. Nauka, Moscow. Y URI V.
M ATIYASEVICH, Hilbert’s Tenth Problem, Foundations of Computing Series, The MIT Press,
Cambridge MA, 1993. [89, 640]
U ELI M. M AURER and S TEFAN W OLF (1999), The relationship between breaking the Diffie-Hellman protocol
and computing discrete logarithms. SIAM Journal on Computing 28(5), 1689–1721. [580]
E RNST W. M AYR (1984), An algorithm for the general Petri net reachability problem. SIAM Journal on
Computing 13(3), 441–460. [697]
E RNST M AYR (1989), Membership in Polynomial Ideals over Q Is Exponential Space Complete.
In Proceedings of the 6th Annual Symposium on Theoretical Aspects of Computer Science STACS ’89,
Paderborn, Germany, eds. B. M ONIEN and R. C ORI. Lecture Notes in Computer Science 349,
Springer-Verlag, 400–406. [616]
E RNST W. M AYR (1992), Polynomial ideals and applications. Mitteilungen der Mathematischen Gesellschaft in
Hamburg 12(4), 1207–1215. Festschrift zum 300jährigen Bestehen der Gesellschaft. [616, 697]
E RNST W. M AYR (1995), On Polynomial Ideals, Their Complexity, and Applications. In Proceedings of the
10th International Conference on Fundamentals of Computation Theory FCT ’95, Dresden, Germany, ed.
H ORST R EICHEL. Lecture Notes in Computer Science 965, Springer-Verlag, 89–105. [616, 697]
E RNST W. M AYR (1997), Some complexity results for polynomial ideals. Journal of Complexity 13, 303–325.
[618]
E RNST W. M AYR and A LBERT R. M EYER (1982), The Complexity of the Word Problems for Commutative
Semigroups and Polynomial Ideals. Advances in Mathematics 46, 305–329. [616, 617, 618]
E RNST W. M AYR and S TEPHAN R ITSCHER (2010), Degree Bounds for Gröbner Bases of Low-Dimensional
Polynomial Ideals. Proceedings of the 2010 International Symposium on Symbolic and Algebraic
Computation ISSAC2010, Munich, Germany, 21–27. [617]
References 757
K EVIN S. M C C URLEY (1990), The Discrete Logarithm Problem. In Cryptology and Computational Number
Theory, ed. C ARL P OMERANCE. Proceedings of Symposia in Applied Mathematics 42, American
Mathematical Society, 49–74. [580]
ROBERT J. M C E LIECE (1969), Factorization of Polynomials over Finite Fields. Mathematics of
Computation 23, 861–867. [419]
A LFRED M ENEZES (1993), Elliptic curve public key cryptosystems. Kluwer Academic Publishers, Boston MA.
[580]
R ALPH C. M ERKLE and M ARTIN E. H ELLMAN (1978), Hiding information and signatures in trapdoor
knapsacks. IEEE Transactions on Information Theory IT-24(5), 525–530. [503, 504, 509, 576]
M ARIN M ERSENNE (1636), Harmonie universelle contenant la théorie et la pratique de la musique. Sebastien
Cramoisy, Paris. Reprinted by Centre National de la Recherche Scientifique, Paris, 1975. [86]
F. M ERTENS (1897), Über eine zahlentheoretische Function. Sitzungsberichte der Akademie der
Wissenschaften, Wien, Mathematisch-Naturwissenschaftliche Classe 106, 761–830. [508]
N ICHOLAS M ETROPOLIS and S. U LAM (1949), The Monte Carlo Method. Journal of the American Statistical
Association 44, 335–341. [198]
S HAWNA M EYER E IKENBERRY and J ONATHAN P. S ORENSON (1998), Efficient algorithms for computing the
Jacobi symbol. Journal of Symbolic Computation 26(4), 509–523. [533]
M. M IGNOTTE (1974), An Inequality About Factors of Polynomials. Mathematics of Computation 28(128),
1153–1157. [198]
M. M IGNOTTE (1982), Some Useful Bounds. In Computer Algebra, Symbolic and Algebraic Computation, eds.
B. B UCHBERGER, G. E. C OLLINS, and R. L OOS, 259–263. Springer-Verlag, New York, 2nd edition.
[198]
M AURICE M IGNOTTE (1988), An Inequality about Irreducible Factors of Integer Polynomials. Journal of
Number Theory 30, 156–166. [198]
M AURICE M IGNOTTE (1989), Mathématiques pour le calcul formel. Presses Universitaires de France, Paris.
English translation: Mathematics for Computer Algebra, Springer-Verlag, New York, 1992. [198]
M AURICE M IGNOTTE and P HILIPPE G LESSER (1994), On the Smallest Divisor of a Polynomial. Journal of
Symbolic Computation 17, 277–282. [198]
M AURICE M IGNOTTE and C. S CHNORR (1988), Calcul des racines d-ièmes dans un corps fini. Comptes
Rendus de l’Académie des Sciences Paris 290, 205–206. [421]
X. E. Mikeladze [S H . E. M IKELADZE ] (1948), O razloжenii opredelitel, зlementami
kotorogo sluжat polinomy (On the expansion of a determinant whose entries are polynomials).
Prikladna matematika i mehanika (Prikladnaya matematika i mekhanika) 12, 219–222. [132]
G ARY L. M ILLER (1976), Riemann’s Hypothesis and Tests for Primality. Journal of Computer and System
Sciences 13, 300–317. [532]
V ICTOR S. M ILLER (1986), Use of Elliptic Curves in Cryptography. In Advances in Cryptology: Proceedings
of CRYPTO ’85, Santa Barbara, CA, ed. H UGH C. W ILLIAMS. Lecture Notes in Computer Science 218,
Springer-Verlag, Berlin, 417–426. [580]
H. M INKOWSKI (1910), Geometrie der Zahlen. B. G. Teubner, Leipzig. [496]
R. T. M OENCK (1973), Fast computation of gcd’s. In Proceedings of the Fifth Annual ACM Symposium on
Theory of Computing, Austin TX, ACM Press, 142–151. [332]
ROBERT T. M OENCK (1976), Practical Fast Polynomial Multiplication. In Proceedings of the 1976 ACM
Symposium on Symbolic and Algebraic Computation SYMSAC ’76, Yorktown Heights NY, ed. R. D.
J ENKS, ACM Press, 136–148. [247]
ROBERT T. M OENCK (1977a), On the Efficiency of Algorithms for Polynomial Factoring. Mathematics of
Computation 31(137), 235–250. [421]
ROBERT M OENCK (1977b), On computing closed forms for summation. In Proceedings of the 1977
MACSYMA Users Conference, Berkeley CA, NASA, Washington DC, 225–236. [671, 673]
R. M OENCK and A. B ORODIN (1972), Fast modular transform via division. In Proceedings of the 13th Annual
IEEE Symposium on Switching and Automata Theory, Yorktown Heights NY, IEEE Press, New York,
90–96. [306]
M ICHAEL M OELLER (1999), Good non-zeros of polynomials. ACM SIGSAM Bulletin 33(3), 10–11. [199]
H. M ICHAEL M ÖLLER and F ERDINANDO M ORA (1984), Upper and lower bounds for the degree of Gröbner
bases. In Proceedings of EUROSAM ’84, Cambridge, UK, ed. J OHN F ITCH. Lecture Notes in Computer
Science 174, Springer-Verlag, New York, 172–183. [618]
L OUIS M ONIER (1980), Evaluation and comparison of two efficient probabilistic primality testing algorithms.
Theoretical Computer Science 12, 97–108. [532, 533]
P ETER L. M ONTGOMERY (1985), Modular Multiplication Without Trial Division. Mathematics of
Computation 44(170), 519–521. [288]
P ETER L. M ONTGOMERY (1991), Factorization of X 216091 + X + 1 mod 2—A problem of Herb Doughty.
Manuscript. [280]
758 References
P ETER L AWRENCE M ONTGOMERY (1992), An FFT Extension of the Elliptic Curve Method of Factorization.
PhD thesis, University of California, Los Angeles CA.
http://research.microsoft.com/en-us/um/people/petmon/thesis.pdf. [287, 308]
P ETER L. M ONTGOMERY (1995), A Block Lanczos Algorithm for Finding Dependencies over GF(2).
In Advances in Cryptology: Proceedings of EUROCRYPT 1995, Saint-Malo, France, eds. L OUIS C.
G UILLOU and J EAN -JACQUES Q UISQUATER. Lecture Notes in Computer Science 921, Springer-Verlag,
106–120. [353]
E LIAKIM H ASTINGS M OORE (1896), A doubly-infinite system of simple groups. In Mathematical papers read
at the International Mathematical Congress: held in connection with the World’s Columbian exposition,
Chicago, 1893, Macmillan, New York, 208–242. [88]
ROBERT E DOUARD M ORITZ (1914), Memorabilia Mathematica. The Mathematical Association of America.
[729]
M ICHAEL A. M ORRISON and J OHN B RILLHART (1971), The factorization of F7 . Bulletin of the American
Mathematical Society 77(2), p. 264. [542, 568]
M ICHAEL A. M ORRISON and J OHN B RILLHART (1975), A Method of Factoring and the Factorization of F7 .
Mathematics of Computation 29(129), 183–205. [541, 568]
J OEL M OSES and DAVID Y. Y. Y UN (1973), The EZGCD Algorithm. In Proceedings of the ACM National
Conference, Atlanta GA, 159–166. [198, 466]
R AJEEV M OTWANI and P RABHAKAR R AGHAVAN (1995), Randomized Algorithms. Cambridge University
Press, Cambridge, UK. [88, 198]
T HOM M ULDERS (1997), A note on subresultants and the Lazard/Rioboo/Trager formula in rational function
integration. Journal of Symbolic Computation 24(1), 45–50. [199, 640]
T. M ULDERS and A. S TORJOHANN (2000), On Lattice Reduction for Polynomial Matrices. Technical
Report 356, Department of Computer Science, ETH Zürich. 26 pages,
ftp://ftp.inf.ethz.ch/pub/publications/tech-reports/3xx/356.ps.gz. [501]
R. C. M ULLIN, I. M. O NYSZCHUK, S. A. VANSTONE, and R. M. W ILSON (1989), Optimal normal bases in
GF(pn ). Discrete Applied Mathematics 22, 149–161. [88]
DAVID R. M USSER (1971), Algorithms for Polynomial Factorization. PhD thesis, Computer Science
Department, University of Wisconsin. Technical Report #134, 174 pages. [465]
M ATS N ÄSLUND (1998), Bit Extraction, Hard-Core Predicates, and the Bit Security of RSA. PhD thesis,
Department of Numerical Analysis and Computing Science, Kungl Tekniska Högskolan (Royal Institute
of Technology), Stockholm. [580]
I SAAC N EWTON (1691/92), De quadratura curvarum. The revised and augmented treatise. Unpublished
manuscript. In: D EREK T. W HITESIDE, The mathematical papers of Isaac Newton vol. VII, Cambridge
University Press, Cambridge, UK, 1976, pp. 48–128. [641]
I SAAC N EWTON (1707), Arithmetica Universalis, sive de compositione et resolutione arithmetica liber.
J. Senex, London. English translation as Universal Arithmetick: or, A Treatise on Arithmetical
composition and Resolution, translated by the late Mr. Raphson and revised and corrected by Mr. Cunn,
London, 1728. Reprinted in: D EREK T. W HITESIDE, The mathematical works of Isaac Newton, Johnson
Reprint Co, New York, 1967, p. 4 ff. [61, 203, 725, 726]
I SAAC N EWTON (1710), Quadrature of Curves. In Lexicon Technicum. Or, an Universal Dictionary of Arts and
Sciences, vol. 2, John Harris. Reprinted in: D EREK T. W HITESIDE, The mathematical works of Isaac
Newton, vol. 1, Johnson Reprint Co, New York, 1967. [286]
P HONG Q. N GUYEN and JACQUES S TERN (2001), The Two Faces of Lattices in Cryptology. In Cryptography
and Lattices, International Conference (CaLC 2001), Providence RI, ed. J OSEPH H. S ILVERMAN. Lecture
Notes in Computer Science 2146, Springer-Verlag, 146–180. [509, 580]
T HOMAS R. N ICELY (1996), Enumeration to 1014 of the Twin Primes and Brun’s Constant. Virginia Journal of
Science 46(3), 195–204. [83]
H. N IEDERREITER (1986), Knapsack-type cryptosystems and algebraic coding theory. Problems of Control and
Information Theory 15, 159–166. [509]
H ARALD N IEDERREITER (1993a), A New Efficient Factorization Algorithm for Polynomials over Small Finite
Fields. Applicable Algebra in Engineering, Communication and Computing 4, 81–87. [420]
H. N IEDERREITER (1993b), Factorization of Polynomials and Some Linear Algebra Problems over Finite
Fields. Linear Algebra and its Applications 192, 301–328. [420]
H ARALD N IEDERREITER (1994a), Factoring polynomials over finite fields using differential equations and
normal bases. Mathematics of Computation 62(206), 819–830. [420]
H ARALD N IEDERREITER (1994b), New deterministic factorization algorithms for polynomials over finite
fields. In Finite fields: theory, applications and algorithms, eds. G. L. M ULLEN and P. J.-S. S HIUE.
Contemporary Mathematics 168, American Mathematical Society, 251–268. [420]
H ARALD N IEDERREITER and R AINER G ÖTTFERT (1993), Factorization of Polynomials over Finite Fields and
Characteristic Sequences. Journal of Symbolic Computation 16, 401–412. [420]
References 759
H ARALD N IEDERREITER and R AINER G ÖTTFERT (1995), On a new factorization algorithm for polynomials
over finite fields. Mathematics of Computation 64(209), 347–353. [420]
P EDRO N UÑEZ (1567), Libro de algebra en arithmetica y geometrica. Iuan Stelfio, widow and heirs, Anvers.
[41]
A. M. O DLYZKO (1990), The Rise and Fall of Knapsack Cryptosystems. In Cryptology and Computational
Number Theory, ed. C ARL P OMERANCE. Proceedings of Symposia in Applied Mathematics 42,
American Mathematical Society, 75–88. [497, 509]
A. M. O DLYZKO (1995a), Asymptotic Enumeration Methods. In Handbook of Combinatorics, eds.
R. G RAHAM, M. G RÖTSCHEL, and L. L OVÁSZ. Elsevier Science Publishers B.V., Amsterdam,
and The MIT Press, Cambridge MA. [697]
A NDREW M. O DLYZKO (1995b), The Future of Integer Factorization. CryptoBytes 1(2), 5–12. [580]
A NDREW M. O DLYZKO (1995c), Analytic computations in number theory. In Mathematics of Computation
1943–1993: A Half-Century of Computational Mathematics, ed. WALTER G AUTSCHI. Proceedings of
Symposia in Applied Mathematics 48, American Mathematical Society, 451–463. [533]
A. M. O DLYZKO and H. J. J. TE R IELE (1985), Disproof of the Mertens conjecture. Journal für die reine und
angewandte Mathematik 357, 138–160. [508]
A. M. O DLYZKO and A. S CHÖNHAGE (1988), Fast algorithms for multiple evaluations of the Riemann zeta
function. Transactions of the American Mathematical Society 309(2), 797–809. [533]
J OSEPH O ESTERLÉ (1979), Versions effectives du théorème de Chebotarev sous l’hypothèse de Riemann
généralisée. Société Mathématique de France, Astérisque 61, 165–167. [443]
H. O NG, C. P. S CHNORR, and A. S HAMIR (1984), An efficient signature scheme based on quadratic equations.
In Proceedings of the Sixteenth Annual ACM Symposium on Theory of Computing, Washington DC,
ACM Press, 208–216. [509]
L UITZEN J OHANNES O OSTERHOFF (1949), Restricted free rotation and cyclic molecules. PhD thesis,
Rijksuniversiteit te Leiden. [698]
A LAN V. O PPENHEIM and RONALD W. S CHAFER (1975), Digital Signal Processing. Prentice-Hall, Inc.,
Englewood Cliffs NJ. [368]
A LAN V. O PPENHEIM, A LAN S. W ILLSKY, and I AN T. YOUNG (1983), Signals and Systems. Prentice-Hall
signal processing series, Prentice-Hall, Inc., Englewood Cliffs NJ. [368]
M. O STROGRADSKY (1845), De l’intégration des fractions rationnelles. Bulletin de la classe physico-
mathématique de l’Académie Impériale des Sciences de Saint-Pétersbourg 4(82/83), 145–167. [640]
H. PADÉ (1892), Sur la représentation approchée d’une fonction par des fractions rationnelles. Annales
Scientifiques de l’Ecole Normale Supérieure, 3e série 9, Supplément S3-S93. [132]
V. . Pan (1966), O sposobah vyqisleni znaqenii mnogoqlenov. Uspehi
Matematiqeskih Nauk 21(1(127)), 103–134. V. YA . PAN, Methods of computing values of
polynomials, Russian Mathematical Surveys 21 (1966), 105–136. [306]
V. YA . PAN (1984), How to multiply matrices faster. Lecture Notes in Computer Science 179, Springer-Verlag,
New York. [352]
V ICTOR Y. PAN (1997), Faster Solution of the Key Equation for Decoding BCH Error-Correcting Codes.
In Proceedings of the Twenty-ninth Annual ACM Symposium on Theory of Computing, El Paso TX,
ACM Press, 168–175. [332]
V ICTOR Y. PAN and X INMAO WANG (2004), On Rational Number Reconstruction and Approximation. SIAM
Journal on Computing 33(2), 502–503. [327]
DANIEL N ELSON PANARIO RODRIGUEZ (1997), Combinatorial and Algebraic Aspects of Polynomials over
Finite Fields. PhD thesis, Department of Computer Science, University of Toronto. Technical Report
306/97, 154 pages. [419]
DANIEL PANARIO, X AVIER G OURDON, and P HILIPPE F LAJOLET (1998), An Analytic Approach to Smooth
Polynomials over Finite Fields. In Algorithmic Number Theory, Third International Symposium,
ANTS-III, Portland, Oregon, USA, ed. J. P. B UHLER. Lecture Notes in Computer Science 1423,
Springer-Verlag, 226–236. [419]
DANIEL PANARIO and B RUCE R ICHMOND (1998), Analysis of Ben-Or’s Polynomial Irreducibility Test.
Random Structures and Algorithms 13(3/4), 439–456. [419, 421]
DANIEL PANARIO and A LFREDO V IOLA (1998), Analysis of Rabin’s polynomial irreducibility test.
In Proceedings of LATIN ’98, Campinas, Brazil, eds. C LÁUDIO L. L UCCHESI and A RNALDO V.
M OURA. Lecture Notes in Computer Science 1380, Springer-Verlag, 1–10. [419, 421]
C HRISTOS H. PAPADIMITRIOU (1993), Computational complexity. Addison-Wesley, Reading MA. [721]
DAVID PARSONS and J OHN C ANNY (1994), Geometric Problems in Molecular Biology and Robotics.
In Proceedings 2nd International Conference on Intelligent Systems for Molecular Biology, Palo Alto CA,
322–330. [698]
P ETER PAULE (1994), Short and Easy Computer Proofs of the Rogers-Ramanujan Identities and of Identities of
Similar Type. The Electronic Journal of Combinatorics 1(# R10). 9 pages. [697]
760 References
P ETER PAULE (1995), Greatest Factorial Factorization and Symbolic Summation. Journal of Symbolic
Computation 20, 235–268. [670, 671]
P ETER PAULE and VOLKER S TREHL (1995), Symbolic summation — some recent developments. In Computer
Algebra in Science and Engineering, Bielefeld, Germany, August 1994, eds. J. F LEISCHER,
J. G RABMEIER, F. W. H EHL, and W. K ÜCHLIN, World Scientific, Singapore, 138–162. [671]
H EINZ -OTTO P EITGEN, H ARTMUT J ÜRGENS, and D IETMAR S AUPE (1992), Chaos and Fractals:
New Frontiers of Sience. Springer-Verlag, New York. [278]
W ILLIAM B. P ENNEBAKER and J OAN C. M ITCHELL (1993), JPEG still image data compression standard.
Van Nostrand Reinhold, New York. [368]
n
P EPIN (1877), Sur la formule 22 + 1. Comptes Rendus des Séances de l’Académie des Sciences, Paris 85,
329–331. [530, 538]
O SKAR P ERRON (1929), Die Lehre von den Kettenbrüchen. B. G. Teubner, Leipzig, 2nd edition. Reprinted by
Chelsea Publishing Co., New York. First edition 1913. [90]
JAMES L. P ETERSON (1981), Petri net theory and the modeling of systems . Prentice-Hall, Inc., Englewood
Cliffs NJ. [697]
M ARKO P ETKOVŠEK (1992), Hypergeometric solutions of linear recurrences with polynomial coefficients.
Journal of Symbolic Computation 14, 243–264. [671, 675]
M ARKO P ETKOVŠEK (1994), A generalization of Gosper’s algorithm. Discrete Mathematics 134, 125–131.
[671]
M ARKO P ETKOVŠEK and B RUNO S ALVY (1993), Finding All Hypergeometric Solutions of Linear Differential
Equations. In Proceedings of the 1993 International Symposium on Symbolic and Algebraic Computation
ISSAC ’93, Kiev, ed. M ANUEL B RONSTEIN, ACM Press, 27–33. [641]
M ARKO P ETKOVŠEK, H ERBERT S. W ILF, and D ORON Z EILBERGER (1996), A=B. A K Peters,
Wellesley MA. [697, 729]
K AREL P ETR (1937), Über die Reduzibilität eines Polynoms mit ganzzahligen Koeffizienten nach einem
Primzahlmodul. Časopis pro pěstování matematiky a fysiky 66, 85–94. [402, 420]
C. A. P ETRI (1962), Kommunikation mit Automaten. PhD thesis, Universität Bonn. [679]
E CKHARD P FLÜGEL (1997), An Algorithm for Computing Exponential Solutions of First Order Linear
Differential Systems. In Proceedings of the 1997 International Symposium on Symbolic and Algebraic
Computation ISSAC ’97, Maui HI, ed. W OLFGANG W. K ÜCHLIN, ACM Press, 164–171. [641]
R. G. E. P INCH (1993), Some Primality Testing Algorithms. Notices of the American Mathematical
Society 40(9), 1203–1210. [532]
R. P IRASTU (1992), Algorithmen zur Summation rationaler Funktionen. Diplomarbeit, Universität
Erlangen-Nürnberg, Germany. [670, 673]
ROBERTO P IRASTU (1996), On Combinatorial Identities: Symbolic Summation and Umbral Calculus.
PhD thesis, Johannes Kepler Universität, Linz. [671]
R. P IRASTU and V. S TREHL (1995), Rational Summation and Gosper-Petkovšek Representation. Journal of
Symbolic Computation 20, 617–635. [671]
TONIANN P ITASSI (1997), Algebraic Propositional Proof Systems. In Descriptive Complexity and Finite
Models: Proceedings of a DIMACS Workshop, January 14–17, 1996, Princeton NJ, eds. N EIL
I MMERMAN and P HOKION G. KOLAITIS. DIMACS Series in Discrete Mathematics and Theoretical
Computer Science 31, American Mathematical Society, Providence RI, 215–244. [697]
H. C. P OCKLINGTON (1917), The Direct Solution of the Quadratic and Cubic Binomial Congruences with
Prime Moduli. Proceedings of the Cambridge Philosophical Society 19, 57–59. [88, 198]
J OHN M. P OLLARD (1971), The Fast Fourier Transform in a Finite Field. Mathematics of
Computation 25(114), 365–374. [247, 280]
J OHN M. P OLLARD (1974), Theorems on factorization and primality testing. Proceedings of the Cambridge
Philosophical Society 76, 521–528. [198, 541, 567]
J OHN M. P OLLARD (1975), A Monte Carlo method for factorization. BIT 15, 331–334. [198, 541, 545, 568]
C. P OMERANCE (1982), Analysis and comparison of some integer factoring algorithms. In Computational
Methods in Number Theory, Part 1, eds. H. W. L ENSTRA , J R . and R. T IJDEMAN, Mathematical Centre
Tracts 154, 89–139. Mathematisch Centrum, Amsterdam. [557, 567, 569]
C ARL P OMERANCE (1985), The quadratic sieve factoring algorithm. In Advances in Cryptology: Proceedings
of EUROCRYPT 1984, Paris, France, eds. T. B ETH, N. C OT, and I. I NGEMARSSON. Lecture Notes in
Computer Science 209, Springer-Verlag, Berlin, 169–182. [557]
C ARL P OMERANCE (1990), Factoring. In Cryptology and Computational Number Theory, ed. C ARL
P OMERANCE. Proceedings of Symposia in Applied Mathematics 42, American Mathematical Society,
27–47. [520, 567]
C. P OMERANCE, J. L. S ELFRIDGE, and S. S. WAGSTAFF , J R . (1980), The pseudoprimes to 25 · 109 .
Mathematics of Computation 35, 1003–1025. [532]
C ARL P OMERANCE and S. S. WAGSTAFF , J R . (1983), Implementation of the continued fraction integer
factoring algorithm. Congressus Numerantium 37, 99–118. [569]
References 761
A LFRED VAN DER P OORTEN (1978), A proof that Euler missed . . . Apéry’s proof of the irrationality of ζ(3).
The Mathematical Intelligencer 1, 195–203. [697]
A LF VAN DER P OORTEN (1996), Notes on Fermat’s Last Theorem . Canadian Mathematical Society series of
monographs and advanced texts, John Wiley & Sons, New York. [514]
E UGENE P RANGE (1959), An algorism for factoring X n − 1 over a finite field. Technical Report
AFCRC-TN-59-775, Air Force Cambridge Research Center, Bedford MA. [419, 430]
PAUL P RITCHARD (1983), Fast Compact Prime Number Sieves (among Others). Journal of Algorithms 4,
332–344. [533]
PAUL P RITCHARD (1987), Linear prime-number sieves: a family tree. Science of Computer Programming 9,
17–35. [533]
G EORGE B. P URDY (1974), A high-security log-in procedure. Communications of the ACM 17(8), 442–445.
[581]
M ICHAEL O. R ABIN (1976), Probabilistic algorithms. In Algorithms and Complexity, ed. J. F. T RAUB,
Academic Press, New York, 21–39. [532]
M ICHAEL O. R ABIN (1980a), Probabilistic Algorithms for Testing Primality. Journal of Number Theory 12,
128–138. [532]
M ICHAEL O. R ABIN (1980b), Probabilistic algorithms in finite fields. SIAM Journal on Computing 9(2),
273–280. [421, 424]
M ICHAEL O. R ABIN (1989), Efficient Dispersal of Information for Security, Load Balancing, and Fault
Tolerance. Journal of the Association for Computing Machinery 36(2), 335–348. [131, 215]
J. L. R ABINOWITSCH (1930), Zum Hilbertschen Nullstellensatz. Mathematische Annalen 102, p. 520. [618]
BARTOLOMÉ R AMOS (1482), De musica tractatus. Bologna. [86]
J OSEPH R APHSON (1690), Analysis Æquationum Universalis seu Ad Æquationes Algebraicas Resolvendas
Methodus Generalis, et Expedita, Ex nova Infinitarum serierum Doctrina Deducta ac Demonstrata. Abel
Swalle, London. [219]
A LEXANDER A. R AZBOROV (1998), Lower bounds for the polynomial calculus. computational
complexity 7(4), 291–324. [697]
C ONSTANCE R EID (1970), Hilbert . Springer-Verlag, Heidelberg, 1st edition. Third Printing 1978. [587]
DANIEL R EISCHERT (1995), Schnelle Multiplikation von Polynomen über GF(2) und Anwendungen.
Diplomarbeit, Institut für Informatik II, Rheinische Friedrich-Wilhelm-Universität Bonn, Germany. [279]
DANIEL R EISCHERT (1997), Asymptotically Fast Computation of Subresultants. In Proceedings of the 1997
International Symposium on Symbolic and Algebraic Computation ISSAC ’97, Maui HI, ed.
W OLFGANG W. K ÜCHLIN, ACM Press, 233–240. [332]
W OLFGANG R EISIG (1985), Petri Nets: An Introduction . EATCS Monographs on Theoretical Computer
Science 4, Springer-Verlag, Berlin. Translation of the German edition Petrinetze: eine Einführung,
Springer-Verlag, 1982. [697]
G EORGE W. R EITWIESNER (1950), An ENIAC Determination of π and e to more than 2000 Decimal Places.
Mathematical Tables and other Aids to Computation 4, 11–15. Reprinted in Berggren, Borwein &
Borwein (1997), 277–281. [82]
JAMES R ENEGAR (1991), Recent Progress on the Complexity of the Decision Problem for the Reals.
In Discrete and Computational Geometry: Papers from the DIMACS Special Year, eds. JACOB E.
G OODMAN, R ICHARD P OLLACK, and W ILLIAM S TEIGER. DIMACS Series in Discrete Mathematics
and Theoretical Computer Science 6, American Mathematical Society and ACM, 287–308. [619]
JAMES R ENEGAR (1992a), On the Computational Complexity of the First-order Theory of the Reals. Part I:
Introduction. Preliminaries. The Geometry of Semi-algebraic Sets. The Decision Problem for the
Existential Theory of the Reals. Journal of Symbolic Computation 13(3), 255–299. [619]
JAMES R ENEGAR (1992b), On the Computational Complexity of the First-order Theory of the Reals. Part II:
The General Decision Problem. Preliminaries for Quantifier Elimination. Journal of Symbolic
Computation 13(3), 301–327. [619]
JAMES R ENEGAR (1992c), On the Computational Complexity of the First-order Theory of the Reals. Part III:
Quantifier Elimination. Journal of Symbolic Computation 13(3), 329–352. [619]
R EYNAUD (1824), Traité d’arithmétique à l’usage des élèves qui se destinent à l’école royale polytechnique à
l’école spéciale militaire et à l’école de marine. Courcier, Paris, 12th edition. [61]
DANIEL R ICHARDSON (1968), Some undecidable problems involving elementary functions of a real variable.
Journal of Symbolic Logic 33(4), 514–520. [640]
G EORG F RIEDRICH B ERNHARD R IEMANN (1859), Ueber die Anzahl der Primzahlen unter einer gegebenen
Grösse. Monatsberichte der Berliner Akademie, 145–153. Gesammelte Mathematische Werke, ed.
H EINRICH W EBER, Teubner Verlag, Leipzig, 1892, 177-185. [533]
ROBERT H. R ISCH (1969), The problem of integration in finite terms. Transactions of the American
Mathematical Society 139, 167–189. [640, 641]
ROBERT H. R ISCH (1970), The solution of the problem of integration in finite terms. Bulletin of the American
Mathematical Society 76(3), 605–608. [640, 641]
762 References
J. F. R ITT (1948), Integration in Finite Terms. Columbia University Press, New York. [640]
J OSEPH F ELS R ITT (1950), Differential Algebra. AMS Colloquium Publications XXXIII, American
Mathematical Society, Providence RI. Reprint by Dover Publications, Inc., New York, 1966. [619]
R. L. R IVEST, A. S HAMIR, and L. M. A DLEMAN (1978), A Method for Obtaining Digital Signatures and
Public-Key Cryptosystems. Communications of the ACM 21(2), 120–126. [576]
S TEVEN ROMAN (1984), The umbral calculus. Pure and applied mathematics 111, Academic Press,
Orlando FL. [669]
L AJOS R ÓNYAI (1988), Factoring Polynomials over Finite Fields. Journal of Algorithms 9, 391–400. [421]
L AJOS R ÓNYAI (1989), Galois groups and factoring over finite fields. In Proceedings of the 30th Annual IEEE
Symposium on Foundations of Computer Science, Research Triangle Park NC, IEEE Computer Society
Press, Los Alamitos CA, 99–104. [421]
F REDERIC ROSEN (1831), The Algebra of Mohammed ben Musa . Oriental Translation Fund, London. Reprint
by Georg Olms Verlag, Hildesheim, 1986. [726]
J. BARKLEY ROSSER and L OWELL S CHOENFELD (1962), Approximate formulas for some functions of prime
numbers. Illinois Journal of Mathematics 6, 64–94. [527, 532, 536]
M ICHAEL ROTHSTEIN (1976), Aspects of symbolic integration and simplification of exponential and primitive
functions. PhD thesis, University of Wisconsin-Madison. [640, 641]
M ICHAEL ROTHSTEIN (1977), A new algorithm for the integration of exponential and logarithmic functions.
In Proceedings of the 1977 MACSYMA Users Conference, Berkeley CA, NASA, Washington DC,
263–274. [640, 641]
J OHN H. ROWLAND and J OHN R. C OWLES (1986), Small Sample Algorithms for the Identification of
Polynomials. Journal of the ACM 33(4), 822–829. [199]
H. S ACHSE (1890), Ueber die geometrischen Isomerien der Hexamethylenderivate. Berichte der Deutschen
Chemischen Gesellschaft 23, 1363–1370. [698]
H. S ACHSE (1892), Über die Konfigurationen der Polymethylenringe. Zeitschrift für physikalische Chemie 10,
203–241. [698]
B RUNO S ALVY (1991), Asymptotique automatique et fonctions génératrices. PhD thesis, École Polytechnique,
Paris. [697]
E RHARD S CHMIDT (1907), Zur Theorie der linearen und nichtlinearen Integralgleichungen, I. Teil:
Entwicklung willkürlicher Funktionen nach Systemen vorgeschriebener. Mathematische Annalen 63,
433–476. Reprint of Erhard Schmidt’s Dissertation, Göttingen, 1905. [496]
C. P. S CHNORR (1982), Refined Analysis and Improvements on Some Factoring Algorithms. Journal of
Algorithms 3, 101–127. [567]
C. P. S CHNORR (1987), A hierarchy of polynomial time lattice basis reduction algorithms. Theoretical
Computer Science 53, 201–224. [497]
C. P. S CHNORR (1988), A More Efficient Algorithm for Lattice Basis Reduction. Journal of Algorithms 9,
47–62. [497]
C. P. S CHNORR and M. E UCHNER (1991), Lattice Basis Reduction: Improved Practical Algorithms and
Solving Subset Sum Problems. In Proceedings of the 8th International Conference on Fundamentals of
Computation Theory 1991, Gosen, Germany, ed. L OTHAR B UDACH. Lecture Notes in Computer
Science 529, Springer-Verlag, 68–85. [497]
A. S CHÖNHAGE (1966), Multiplikation großer Zahlen. Computing 1, 182–196. [247]
A. S CHÖNHAGE (1971), Schnelle Berechnung von Kettenbruchentwicklungen. Acta Informatica 1, 139–144.
[332]
A. S CHÖNHAGE (1977), Schnelle Multiplikation von Polynomen über Körpern der Charakteristik 2. Acta
Informatica 7, 395–398. [245, 247, 253]
A RNOLD S CHÖNHAGE (1984), Factorization of univariate integer polynomials by Diophantine approximation
and an improved basis reduction algorithm. In Proceedings of the 11th International Colloquium on
Automata, Languages and Programming ICALP 1984, Antwerp, Belgium. Lecture Notes in Computer
Science 172, Springer-Verlag, 436–447. [497]
A RNOLD S CHÖNHAGE (1985), Quasi-GCD Computations. Journal of Complexity 1, 118–137. [202]
A. S CHÖNHAGE (1988), Probabilistic Computation of Integer Polynomial GCDs. Journal of Algorithms 9,
365–371. [202]
A RNOLD S CHÖNHAGE, A NDREAS F. W. G ROTEFELD, and E KKEHART V ETTER (1994), Fast Algorithms –
A Multitape Turing Machine Implementation . BI Wissenschaftsverlag, Mannheim. [279, 286, 292, 727]
A. S CHÖNHAGE and V. S TRASSEN (1971), Schnelle Multiplikation großer Zahlen. Computing 7, 281–292.
[221, 222, 243, 245, 247, 254, 283]
F RIEDRICH T HEODOR VON S CHUBERT (1793), De inventione divisorum. Nova Acta Academiae Scientiarum
Imperalis Petropolitanae 11, 172–186. [465]
J. T. S CHWARTZ (1980), Fast Probabilistic Algorithms for Verification of Polynomial Identities. Journal of
the ACM 27(4), 701–717. [198, 332]
References 763
Š TEFAN S CHWARZ (1939), Contribution à la réductibilité des polynômes dans la théorie des congruences.
Věstník Královské České Společnosti Nauk, Třída Matemat.-Př Ročník Praha, 1–7. [420]
Š TEFAN S CHWARZ (1940), Sur le nombre des racines et des facteurs irréductibles d’une congruence donnée.
Časopis pro pěstování matematiky a fysiky 69, 128–145. [420]
Š TEFAN S CHWARZ (1956), On the reducibility of polynomials over a finite field. Quarterly Journal of
Mathematics Oxford 7(2), 110–124. [420]
Xtefan Xvarc [Š TEFAN S CHWARZ ] (1960), Ob odnom klasse mnogoqlenov nad koneqnym
telom (On a class of polynomials over a finite field). Matematicko-Fyzikálny Časopis 10, 68–80. [420]
Xtefan Xvarc [Š TEFAN S CHWARZ ] (1961), O qisle neprivodimyh faktorov dannogo
mnogoqlena nad koneqnym polem (On the number of irreducible factors of a polynomial over a
finite field). Qehoslovackii matematiqeskii жurnal (Czechoslovak Mathematical
Journal) 11(86), 213–225. [420]
DANIEL S CHWENTER (1636), Deliciæ Physico-Mathematicæ. Jeremias Dümler, Nürnberg. Reprint by Keip
Verlag, Frankfurt am Main, 1991. [61, 131, 697]
ROBERT S EDGEWICK and P HILIPPE F LAJOLET (1996), An Introduction to the Analysis of Algorithms.
Addison-Wesley, Reading MA. [697]
J.-A. S ERRET (1866), Cours d’algèbre supérieure. Gauthier-Villars, Paris, 3rd edition. [418]
J EFFREY S HALLIT (1990), On the Worst Case of Three Algorithms for Computing the Jacobi Symbol. Journal
of Symbolic Computation 10, 593–610. [533]
J EFFREY S HALLIT (1994), Origins of the Analysis of the Euclidean Algorithm. Historia Mathematica 21,
401–419. [61]
A DI S HAMIR (1979), How to Share a Secret. Communications of the ACM 22(11), 612–613. [131]
A DI S HAMIR (1984), A polynomial-time algorithm for breaking the basic Merkle-Hellman cryptosystem. IEEE
Transactions on Information Theory IT-30(5), 699–704. [503, 509]
A. S HAMIR (1993), On the Generation of Polynomials which are Hard to Factor. In Proceedings of the
Twenty-fifth Annual ACM Symposium on Theory of Computing, San Diego CA, ACM Press, 796–804.
[469]
A DI S HAMIR and R ICHARD E. Z IPPEL (1980), On the Security of the Merkle-Hellman Cryptographic Scheme.
IEEE Transactions on Information Theory IT-26(3), 339–340. [509]
DANIEL S HANKS and J OHN W. W RENCH , J R . (1962), Calculation of π to 100,000 Decimals. Mathematics of
Computation 16, 76–99. [82]
W ILLIAM S HANKS (1853), Contributions to Mathematics Comprising Chiefly the Rectification of the Circle to
607 Places of Decimals. G. Bell, London. Excerpt reprinted in Berggren, Borwein & Borwein (1997),
147–161. [82, 90, 729]
C. E. S HANNON (1948), A Mathematical Theory of Communication. Bell System Technical Journal 27,
379–423 and 623–656. Reprinted in C LAUDE E. S HANNON and WARREN W EAVER, The Mathematical
Theory Of Communication, University of Illinois Press, Urbana IL, 1949. [209, 215, 307]
S HEN K ANGSHENG (1988), Historical Development of the Chinese Remainder Theorem. Archive of the
History of Exact Sciences 38, 285–305. [131]
L. A. S HEPP and S. P. L LOYD (1966), Ordered cycle lengths in a random permutation. Transactions of the
American Mathematical Society 121, 340–357. [421]
V ICTOR S HOUP (1990), On the deterministic complexity of factoring polynomials over finite fields.
Information Processing Letters 33, 261–267. [421]
V ICTOR S HOUP (1991), Topics in the theory of computation. Lecture Notes for CSC 2429, Spring term,
Department of Computer Science, University of Toronto. [205]
V ICTOR S HOUP (1994), Fast Construction of Irreducible Polynomials over Finite Fields. Journal of Symbolic
Computation 17, 371–391. [421]
V ICTOR S HOUP (1995), A New Polynomial Factorization Algorithm and its Implementation. Journal of
Symbolic Computation 20, 363–397. [246, 279, 462]
V ICTOR S HOUP (1999), Efficient Computation of Minimal Polynomials in Algebraic Extensions of Finite
Fields. In Proceedings of the 1999 International Symposium on Symbolic and Algebraic Computation
ISSAC ’99, Vancouver, Canada, ed. S AM D OOLEY, ACM Press, 53–58. [354]
I GOR E. S HPARLINSKI (1992), Computational and Algorithmic Problems in Finite Fields. Mathematics and Its
Applications 88, Kluwer Academic Publishers. [419]
I GOR E. S HPARLINSKI (1999), Finite Fields: Theory and Computation. Mathematics and Its Applications,
Kluwer Academic Publishers, Dordrecht/Boston/London. [419]
A MIR S HPILKA and A MIR Y EHUDAYOFF (2010), Arithmetic Circuits: a survey of recent results and open
questions. Foundations and Trends in Theoretical Computer Science 5(3-4), 207–388. [199]
M. S IEVEKING (1972), An Algorithm for Division of Powerseries. Computing 10, 153–156. [286]
J OSEPH H. S ILVERMAN (1986), The Arithmetic of Elliptic Curves. Graduate Texts in Mathematics 106,
Springer-Verlag, New York. [568]
764 References
J. J. S YLVESTER (1840), A method of determining by mere inspection the derivatives from two equations of
any degree. Philosophical Magazine 16, 132–135. Mathematical Papers 1, Chelsea Publishing Co.,
New York, 1973, 54–57. [197, 199]
J. J. S YLVESTER (1853), On the explicit values of Sturm’s quotients. Philosophical Magazine VI, 293–296.
Mathematical Papers 1, Chelsea Publishing Co., New York, 1973, 637–640. [197, 727]
J. J. S YLVESTER (1881), On the resultant of two congruences. Johns Hopkins University Circulars 1, p. 131.
Mathematical Papers 3, Chelsea Publishing Co., New York, 1973, p. 475. [197]
N ICHOLAS S. S ZABÓ and R ICHARD I. TANAKA (1967), Residue arithmetic and its applications to computer
technology. McGraw-Hill, New York. [132]
G. TARRY (1898), Question 1401. Le problème chinois. L’Intermédiaire des Mathématiciens 5, 266–267.
Solution by Korselt. [531]
A LFRED TARSKI (1948), A decision method for elementary algebra and geometry. The Rand Corporation,
Santa Monica CA, 2nd edition. Project Rand, R-109. [619]
B ROOK TAYLOR (1715), Methodus Incrementorum Directa & Inversa. Gul. Innys, London. [286]
R ICHARD TAYLOR and A NDREW W ILES (1995), Ring-theoretic properties of certain Hecke algebras. Annals
of Mathematics 141, 553–572. [514]
G ÉRALD T ENENBAUM (1995), Introduction to analytic and probabilistic number theory. Cambridge studies in
advanced mathematics 46, Cambridge University Press, Cambridge, UK. [536]
A. T HUE (1902), Et par andtydninger til en talteoretisk methode. Videnskabers Selskab Forhandlinger
Christiana 7. [132]
A. L. Toom (1963), O sloжnosti shemy iz funkcionalьnyh зlementov,
realiziru we i umnoжenie celyh qisel. Doklady Akademii Nauk SSSR 150(3),
496–498. A. L. TOOM, The complexity of a scheme of functional elements realizing the multiplication of
integers, Soviet Mathematics Doklady 4 (1963), 714–716. [247]
BARRY M. T RAGER (1976), Algebraic Factoring and Rational Function Integration. In Proceedings of the 1976
ACM Symposium on Symbolic and Algebraic Computation SYMSAC ’76, Yorktown Heights NY, ed.
R. D. J ENKS, ACM Press, 219–226. [466, 640]
C ARLO T RAVERSO (1988), Gröbner trace algorithms. In Proceedings of the 1988 International Symposium on
Symbolic and Algebraic Computation ISSAC ’88, Rome, Italy, ed. P. G IANNI. Lecture Notes in
Computer Science 358, Springer-Verlag, Berlin, 125–138. [619]
J OHANNES T ROPFKE (1902), Geschichte der Elementar-Mathematik, vol. 1. Veit & Comp., Leipzig. [88]
N ICOLA T RUDI (1862), Teoria de’ determinanti e loro applicazioni. Libreria Scientifica e Industriale de
B. Pellerano, Napoli. [199]
A. M. T URING (1937), On computable numbers, with an application to the Entscheidungsproblem. Proceedings
of the London Mathematical Society, Second Series, 42, 230–265, and 43, 544–546. [419]
C HRISTOPHER U MANS (2008), Fast Polynomial Factorization and Modular Composition in Small
Characteristic. In Proceedings of the Fourtieth Annual ACM Symposium on Theory of Computing,
Victoria, BC, Canada, ACM Press, 481–490. Invited to the STOC 2008 special issue of SICOMP.
[339, 751]
A LASDAIR U RQUHART (1995), The complexity of propositional proofs. The Bulletin of Symbolic Logic 1(4),
425–467. [697]
G IOVANNI VACCA (1894), Intorno alla prima dimostrazione di un teorema di Fermat. Bibliotheca Mathematica,
Serie 2, 8, 46–48. [88]
B RIGITTE VALLÉE (2003), Dynamical Analysis of a Class of Euclidean Algorithms. Theoretical Computer
Science 297, 447–486. [61]
C H .-J. DE LA VALLÉE P OUSSIN (1896), Recherches analytiques sur la théorie des nombres premiers. Annales
de la Société Scientifique de Bruxelles 20, 183–256 and 281–397. [533]
R. C. VAUGHAN (1974), Bounds for the coefficients of cyclotomic polynomials. Michigan Mathematical
Journal 21, 289–295. [198]
G. S. V ERNAM (1926), Cipher Printing Telegraph Systems. Journal of the American Institute of Electrical
Engineers 45, 109–115. [580]
G. V ILLARD (1997), Further Analysis of Coppersmith’s Block Wiedemann Algorithm for the Solution of
Sparse Linear Systems. In Proceedings of the 1997 International Symposium on Symbolic and Algebraic
Computation ISSAC ’97, Maui HI, ed. W OLFGANG W. K ÜCHLIN, ACM Press, 32–39. [353]
J EFFREY S COTT V ITTER and P HILIPPE F LAJOLET (1990), Average-Case Analysis of Algorithms and Data
Structures. In Handbook of Theoretical Computer Science, vol. A, ed. J. VAN L EEUWEN, 431–524.
Elsevier Science Publishers B.V., Amsterdam, and The MIT Press, Cambridge MA. [697]
L. G. WADE , J R . (1995), Organic Chemistry. Prentice-Hall, Inc., Englewood Cliffs NJ, 3rd edition. [698]
BARTEL L. VAN DER WAERDEN (1930a), Eine Bemerkung über die Unzerlegbarkeit von Polynomen.
Mathematische Annalen 102, 738–739. [419]
766 References
B. L. VAN DER WAERDEN (1930b), Moderne Algebra, Erster Teil. Die Grundlehren der mathematischen
Wissenschaften in Einzeldarstellungen 33, Julius Springer, Berlin. English translation: Algebra,
Volume I., Springer Verlag, 1991. [586, 703]
B. L. VAN DER WAERDEN (1931), Moderne Algebra, Zweiter Teil. Die Grundlehren der mathematischen
Wissenschaften in Einzeldarstellungen 34, Julius Springer, Berlin. English translation: Algebra,
Volume II., Springer Verlag, 1991. [349, 586, 703]
B. L. VAN DER WAERDEN (1934), Die Seltenheit der Gleichungen mit Affekt. Mathematische Annalen 109,
13–16. [465]
B. L. VAN DER WAERDEN (1938), Eine Bemerkung zur numerischen Berechnung von Determinanten und
Inversen von Matrizen. Jahresberichte der DMV 48, 29–30. [352]
S AMUEL S. WAGSTAFF , J R . (1983), Divisors of Mersenne numbers. Mathematics of Computation 40(161),
385–397. [534]
G REGORY K. WALLACE (1991), The JPEG Still Picture Compression Standard. Communications of the
ACM 34(4), 30–44. [368]
D. WAN (1993), A p-adic lifting lemma and its applications to permutation polynomials. In Proceedings 1992
Conference on Finite Fields, Coding Theory, and Advances in Communications and Computing, eds.
G. L. M ULLEN and P. J.-S. S HIUE. Lecture Notes in Pure and Applied Mathematics 141, Marcel Dekker,
Inc., 209–216. [425]
X INMAO WANG and V ICTOR Y. PAN (2003), Acceleration of Euclidean algorithm and rational number
reconstruction. SIAM Journal on Computing 32(2), 548–556. [327]
E DWARD WARING (1770), Meditationes Algebraicæ. J. Woodyer, Cambridge, England, second edition. English
translation by D ENNIS W EEKS, American Mathematical Society, 1991. [286]
E DWARD WARING (1779), Problems concerning Interpolations. Philosophical Transactions of the Royal
Society of London 69(7), 59–67. [131]
S TEPHEN M. WATT and H ANS J. S TETTER, eds. (1998), Symbolic-Numeric Algebra for Polynomials. Special
Issue of the Journal of Symbolic Computation 26(6). [41]
I NGO W EGENER (1987), The Complexity of Boolean Functions . Wiley-Teubner Series in Computer Science,
B. G. Teubner, Stuttgart, and John Wiley & Sons. [721]
B. M. M. DE W EGER (1989), Algorithms for Diophantine equations. CWI Tract no. 65, Centrum voor
Wiskunde en Informatica, Amsterdam. 212 pages. [497]
A NDRÉ W EIL (1984), Number theory: An approach through history; From Hammurapi to Legendre .
Birkhäuser Verlag. xxi+375 pages. [513]
A NDRÉ W EILERT (2000), (1 + i)-ary GCD Computation in Z[i] as an Analogue to the Binary GCD Algorithm.
Journal of Symbolic Computation 30(5), 605–617. [61]
A NDREAS W ERCKMEISTER (1691), Musicalische Temperatur. Theodorus Philippus Calvisius, Franckfurt und
Leipzig. First edition 1686/87. Reprint edited by G UIDO B IMBERG and R ÜDIGER P FEIFFER, Denkmäler
der Musik in Mitteldeutschland: Ser. 2., Documenta theoretica musicae; Bd. 1: Werckmeister-Studien.
Verlag Die Blaue Eule, Essen, 1996. [86]
D OUGLAS H. W IEDEMANN (1986), Solving Sparse Linear Equations Over Finite Fields. IEEE Transactions on
Information Theory IT-32(1), 54–62. [340, 346, 351, 352, 355, 556]
A NDREW W ILES (1995), Modular elliptic curves and Fermat’s Last Theorem. Annals of Mathematics 142,
443–551. [514]
H ERBERT S. W ILF (1994), generatingfunctionology. Academic Press, 2nd edition. First edition 1990.
[466, 697]
H ERBERT S. W ILF and D ORON Z EILBERGER (1990), Rational functions certify combinatorial identities.
Journal of the American Mathematical Society 3(1), 147–158. [697]
H ERBERT S. W ILF and D ORON Z EILBERGER (1992), An algorithmic proof theory for hypergeometric
(ordinary and “q”) multisum/integral identities. Inventiones mathematicae 108, 575–633. [671, 697]
M ICHAEL W ILLETT (1978), Factoring polynomials over a finite field. SIAM Journal on Applied
Mathematics 35, 333–337. [419]
H. C. W ILLIAMS (1982), A p + 1 Method of Factoring. Mathematics of Computation 39(159), 225–234. [568]
H. C. W ILLIAMS (1993), How was F6 factored? Mathematics of Computation 61(203), 463–474. [542]
H. C. W ILLIAMS and H ARVEY D UBNER (1986), The primality of R1031. Mathematics of
Computation 47(176), 703–711. [530]
H. C. W ILLIAMS and M. C. W UNDERLICH (1987), On the Parallel Generation of the Residues for the
Continued Fraction Factoring Algorithm. Mathematics of Computation 48(177), 405–423. [569]
L ELAND H. W ILLIAMS (1961), Algebra of Polynomials in Several Variables for a Digital Computer. Journal of
the ACM 8, 29–40. [20]
V IRGINIA VASSILEVSKA W ILLIAMS (2011), Breaking the Coppersmith-Winograd barrier.
http://www.cs.berkeley.edu/∼virgi/. Last visited 08 December 2011. 72 pp. [352]
S. W INOGRAD (1971), On Multiplication of 2 × 2 matrices. Linear Algebra and its Applications 4, 381–388.
[352]
References 767
W EN - TSÜN W U (1994), Mechanical Theorem Proving in Geometries: Basic Principles. Texts and Monographs
in Symbolic Computation, Springer-Verlag, Wien and New York. English translation by X IAOFAN J IN
and D ONGMING WANG. Originally published as “Basic Principles of Mechanical Theorem Proving in
Geometry” in Chinese language by Science Press, Beijing, 1984, XIV and 288 pp. [618, 619]
C HEE K. YAP (1991), A New Lower Bound Construction for Commutative Thue Systems with Applications.
Journal of Symbolic Computation 12, 1–27. [618]
A LEXANDER J. Y EE and S HIGERU KONDO (2011), Pi - 10 Trillion Digits. Last visited 16 October 2011. [90]
DAVID Y. Y. Y UN (1976), On Square-free Decomposition Algorithms. In Proceedings of the 1976 ACM
Symposium on Symbolic and Algebraic Computation SYMSAC ’76, Yorktown Heights NY, ed. R. D.
J ENKS, ACM Press, 26–35. [419, 466]
DAVID Y. Y. Y UN (1977a), Fast algorithm for rational function integration. In Information
Processing 77—Proceedings of the IFIP Congress 77, ed. B. G ILCHRIST, North-Holland, Amsterdam,
493–498. [640]
DAVID Y. Y. Y UN (1977b), On the equivalence of polynomial gcd and squarefree factorization problems.
In Proceedings of the 1977 MACSYMA Users Conference, Berkeley CA, NASA, Washington DC, 65–70.
[425]
H ANS Z ASSENHAUS (1969), On Hensel Factorization, I. Journal of Number Theory 1, 291–311.
[417, 444, 466]
D ORON Z EILBERGER (1990a), A holonomic systems approach to special function identities. Journal of
Computational and Applied Mathematics 32, 321–368. [671, 697]
D ORON Z EILBERGER (1990b), A fast algorithm for proving terminating hypergeometric identities. Discrete
Mathematics 80, 207–211. [671, 697]
D ORON Z EILBERGER (1991), The Method of Creative Telescoping. Journal of Symbolic Computation 11,
195–204. [671, 697]
D ORON Z EILBERGER (1993), Theorems for a Price: Tomorrow’s Semi-Rigorous Mathematical Culture.
Notices of the American Mathematical Society 40(8), 978–981. [697]
PAUL Z IMMERMANN (1991), Séries génératrices et analyse automatique d’algorithmes. PhD thesis, École
Polytechnique, Paris. [697]
P HILIP R. Z IMMERMANN (1996), The Official PGP User’s Guide. MIT Press. [18]
R ICHARD Z IPPEL (1979), Probabilistic Algorithms for sparse Polynomials. In Proceedings of EUROSAM ’79,
Marseille, France. Lecture Notes in Computer Science 72, Springer-Verlag, 216–226. [198, 498]
R ICHARD Z IPPEL (1993), Effective polynomial computation. Kluwer Academic Publishers, Boston MA. [204]
List of notation
N, N>n set of nonnegative integers, set of integers greater than n ∈ N
Z ring of integers
Q, Q>0 field of rational numbers, set of positive rational numbers
R, R>r field of real numbers, set of real numbers greater than r ∈ R
C field of complex numbers
Ø empty set
A∪B union of the sets A and B
A∩B intersection of the sets A and B
A\B set-theoretic difference of A and B
A×B Cartesian product of the sets A and B
An vectors of length n ∈ N over the set A
AN countably infinite sequences over the set A, page 341
#A cardinality (number of elements) of the set A
hAi subgroup, ideal, or subspace generated by the elements of A, pages 704, 706, 714
A∼ =B A and B are isomorphic groups or rings, pages 704, 705
R× group of units of the ring R, page 707
R[x] ring of polynomials in the variable x over the ring R, page 708
R[x1 , . . ., xn ] ring of polynomials in n variables over the ring R, page 709
R[[x]] ring of power series in the variable x over the ring R, page 708
Rn×m ring of n × m matrices over the ring R for n, m ∈ N
R/I residue class ring of the ring R modulo the ideal I ⊆ R, page 706
F(x) field of rational functions in the variable x over the field F, page 710
F((x)) field of Laurent series in the variable x over the field F, page 91
exp x exponential function, ex for x ∈ R
ln x natural (base e) logarithm of x ∈ R>0
log x binary (base 2) logarithm of x ∈ R>0
ℜa real part of a ∈ C
ℑa imaginary part of a ∈ C
|a| absolute value of a ∈ C
sign(a) sign of a ∈ R
⌊a⌋ greatest integer less or equal to a ∈ R
⌈a⌉ smallest integer greater or equal to a ∈ R
⌈a⌋ nearest integer to a ∈ R, ⌊a + 1/2⌋, page 478
||a||1 1-norm of a vector or polynomial a, page 717
||a||2 Euclidean norm of a vector or a polynomial a, page 717
||a||∞ max-norm of a vector or polynomial a, page 717
a⋆b inner product of vectors a and b, page 717
a|b a divides b, ∃c b = ac
a∤b a does not divide b
f′ formal derivative of the polynomial or rational function f , page 266
∂ f /∂x formal derivative of the multivariate polynomial f with respect to x
fm mth rising factorial power for m ∈ Z, f · E f · · · E m−1 f if m ∈ N, page 646
m
f n mth falling factorial power for m ∈ Z, f · E −1 f · · · E 1−m f if m ∈ N, page 647
binomial coefficient for n, k ∈ N
h nk i
Stirling number of the first kind for n, k ∈ N, page 672
nkn o
Stirling number of the second kind for n, k ∈ N, page 650
k
[q1 , q2 , . . ., qn ] continued fraction q1 + 1/(q2 + 1/(· · · + 1/qn ) · · ·), page 79
←− assignment in algorithm
∗ , ∗∗ , −→ ranking of exercises: medium, difficult, lengthy (no mark = easy)
✷ end of proof
✸ end of example
768
Index
A page number is underlined (for example: 667) when it represents the definition or the main source of
information about the index entry. For several key words that appear frequently only ranges of pages or the
most important occurrences are indexed.
769
770 Index
B-number . . . . . . . . . . . . . 550, 551, 553, 556, 557, 568 Berman, Benjamin P. . . . . . . . . . . . . . . . . . . . . . . 640, 737
Babai, László . . . . . . . . . . . . . . . . . . . . . . . . 198, 724, 736 Bernardin, Laurent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Babbage, Charles . . . . . . . . . . 312, 676, 725, 727, 729 Bernoulli, Jakob (1654–1705)
baby step/giant step strategy . . . . . . . . . . . . . . . . . . . . . 544 number . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650, 669, 672
Babylonians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286, 291 random variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
Bach, Carl Eric 6, 61, 287, 421, 529, 531–535, 568, Bernoulli, Johann (1667–1748) . . . . . . . . . . . . 640, 737
736 Bernstein, Daniel Julius . . . . . . . . . 247, 287, 353, 737
Bach, Johann Sebastian . . . . . . . . . . . . . . . . . . . . . 86, 736 Bernstein, Jeremy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
Bachet, Claude Gaspard, sieur de Méziriac . 61, 513, Bert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
736 Bertossi, Leopoldo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Bachmann, Paul Gustav Heinrich . . . . . . . . . 531, 724 Bertrand, Joseph Louis François, postulate . . . . . . 525
back-tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678 Beschorner, Andreas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Bacon, Lord Francis . . . . . . . . . . . . . . . . . . . . . . . . . 0, 725 Beth, Thomas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747, 760
Bailey, David Harold . . . . . . . . . . . 2, 83, 337, 736, 737 Bézier, Pierre Étienne . . . . . . . . . . . . . . . . . . . . . 138, 737
Baker, George Allen, Jr. . . . . . . . . . . . . . . . . . . . 132, 736 curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Ball, Walter William Rouse . . . . . . . . . . 531, 534, 736 spline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Barbour, James Murray . . . . . . . . . . . . . . . . . . . . . 91, 736 Bézout, Étienne . . . . . . . 172, 197, 590, 724, 728, 737
Bareiss, Erwin Hans . . . . . . . . . . . . . . . . . . . . . . 132, 736 -coprime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450, 471
Barnett, Michael . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 coefficients . 58, 62, 141, 153, 155, 161, 197, 325,
Barrau, Théophile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725 326
Barrow, Isaac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197, 201
basis theorem . . . . . . . 157, 172, 173, 175, 198, 560, 692
Gröbner ∼ . . . . . . . . . . . . . . . . . . . . . see Gröbner basis Bible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 219, 711
Hilbert ∼ theorem . . 586, 601, 604, 605, 606, 618 Biermann, Gottlieb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
normal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76, 580 big Oh, O(·) 2, 30, 32, 703, 715, 720, 721, 723, 724
of a lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473, 477 big prime modular algorithm . see modular algorithm
of a vector space . . . . 209, 212, 475, 714, 715, 717 bijective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704, 705
of an ideal . . . . . . . . . . . . . . . . . . . . 593, 601, 608, 706 bilinear
orthogonal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475, 717 complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337, 338
reduced ∼ . . . . . . . . . . . . . . . . . . . . . . . see reduced basis map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
reduction 475, 478, 479, 480, 484, 488, 492, 493, Bimberg, Guido . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
496, 497, 499, 500, 503, 505–509, 576, 580 binary
standard ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Bauer, Andrej . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671, 736 Euclidean Algorithm . . . . . . . . . . . . . . . . . 61, 65, 738
Baur, Walter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352, 736 rational . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Bayer, David . . . . . . . . . . . . . . . . . . . . . . . . . 618, 619, 736 representation . . . . 75, 88, 100, 262, 283, 408, 504
BCH code . . . . 3, 209, 210, 211, 212–215, 325, 332, tree . . . . . . . . . . . . . . . . . . . . . . 296, 303, 305–307, 309
377, 412, 416, 417, 756 Binet, Jacques Philippe Marie . . . . . . . . . . . . . . . 61, 737
designed distance of a ∼ . . . . . . . . . . . . . . . . 212, 213 Bini, Dario Andrea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
generator polynomial of a ∼ . . . 211, 212, 214, 215, binomial . . . . . . . . . . . . . . . . . . . . . . . . 230, 463, 616, 681
416 coefficient . 76, 166, 658–660, 669, 670, 684, 713,
Beame, Paul William . . . . . . . . . . . . . . . . . . . . 6, 697, 736 768
Becker, Thomas . . . . . . . . . . . . . . . . . . . . . . . . . . . 618, 736 ideal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616, 681, 697
Beiler, Albert H. . . . . . . . . . . . . . . . . . . . . . . . . . . 534, 736 theorem . . . . . . . . . . . . . . . . . . . . . . . . 76, 667, 669, 673
Bell, Eric Temple (John Taine) . . . . 10, 96, 219, 644, B I P OL A R . . . . . . . . . . . . . . . 3, 279, 281–283, 461, 462
725, 726, 729, 736 Birch, Thomas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
Beltrami, Eugenio . . . . . . . . . . . . . . . . . . . . . . . . . 729, 734 birthday problem . . . . . . . . . . . . . . . . . . . . . . . . . . 546, 548
Benecke, Christof . . . . . . . . . . . . . . . . . . . . . . . . . 698, 736 bit operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Ben-Or, Michael . 410, 411, 421, 498, 619, 736, 737, bivariate
759 factorization . . . 433, 457, 459, 493, 496, 497, 586
Berenstein, Carlos Alberto . . . . . . . . . . . . . . . . 618, 737 interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Berggren, Lennart . 90, 729, 735, 737, 749, 751, 753, modular
761, 763 gcd . . . . . . . . . . . . . . . . . . . . . . . . . . . see modular gcd
Berkeley, George . . . . . . . . . . . . . . . . . . . . . . . . . . 622, 729 EEA . . . . . . . . . . . . . . . . . . . . . . . . see modular EEA
Berlekamp, Elwyn Ralph . . . 198, 215, 335, 340, 352, polynomial . . . . 141, 162, 178, 182, 186, 203, 205,
401, 402, 404, 406, 417, 419–421, 428, 462, 465, 206, 246, 254, 289, 332, 457, 473, 493
467, 530, 737 black box . . . . . . . . 101, 340, 351–353, 355, 496, 498
algebra . . . 401, 402, 403, 420, 423, 427, 428, 430 linear algebra . . . . . . . 335, 340, 346, 352, 404, 407
algorithm 161, 198, 335, 402, 403, 404, 405, 407, representation of a polynomial . . . . . . . . . . . . . . . . 496
420, 424, 427, 428, 530, 745, 751 Black, John Richard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
-Massey algorithm . . . . . . . . . . . . . . . . . . . . . . 325, 742 Blake, Ian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580, 737
matrix . . . . . . . . . . . . . . . . see Petr-Berlekamp matrix Blakley, George Robert (Bob) . . . . . . . . . . . . . 131, 735
Index 771
Blau, Peter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Bürgisser, Peter . 7, 88, 222, 286, 338, 352, 616, 739
blocking strategy . . . . . . . . . . . . . . . . . . . . . . . . . . 422, 461 Burnikel, Christoph . . . . . . . . . . . . . . . . . . . . . . . 286, 739
Blömer, Johannes Friedrich . . . . . . . . . . . . . . . 215, 735 Burrus, Charles Sydney . . . . . . . . . . . . . . . . . . . 247, 748
boat conformation . . . see cyclohexane conformation Buss, Samuel Rudolph . . . . . . . . . . . . . . . . . . . . 697, 739
Bob . . . . . . . . . . . . . . . . . 16, 17, 503, 573, 574, 577–580 Butler, Michael Charles Richard . . . . . . . . . . 420, 739
du Bois-Reymond, Emil . . . . . . . . . . . . . . . . . . . . . . . . . 588 butterfly operation . . . . . . . . . . . . . . . . . . . . . . . . 234, 235
Boltzmann, Ludwig . . . . . . . . . . . . . . . . . . . . . . . 622, 728 Büttner, J. G. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Bolyai, Wolfgang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Bolyai de Bolya, János (Johann) . . . . . . . . . . . . . . . . 374 C, field of complex numbers . . . . . . . . . . . . . . . . . . . . 768
Bombieri, Enrico . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90, 737 Cade, John Joseph . . . . . . . . . . . . . . . . . . . . . . . . 576, 739
Bonn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i, 8 Caesar, Gaius Julius . . . . . . . . . . . . . . . . . . . . . 83, 84, 575
Bonnet, Ossian Pierre . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 cipher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573, 574, 580
Bonorden, Olaf . . . . . . . . . . . . . . . . . . . . . . . . . . . 461, 737 Caldwell, Chris Kelly . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Boole, George . . . . . . . . . . . . . . . . . . . . . . . 669, 737, 766 calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 69, 83
Boolean Gregorian ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84, 91
circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Julian ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83, 84, 91
variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
lunar ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Borodin, Allan Bertram . . 6, 286, 306, 498, 737, 757
lunisolar ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Borwein, Jonathan Michael . . 83, 90, 729, 735, 737,
Camion, Paul Frédéric Roger . . . . . . . . . 419, 420, 739
749, 751, 753, 761, 763
cancellation law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706
Borwein, Peter Benjamin . . . . . 83, 90, 729, 735, 737,
Canfield, Earl Rodney . . . . . . . . . . . . . . . . . . . . . 567, 739
749, 751, 753, 761, 763
Caniglia, Leandro . . . . . . . . . . . . . . . . . . . . 618, 619, 739
Bos, Joppe Willem . . . . . . . . . . . . . . . . . . . . . . . . 542, 751
Bose, Nirmal Kumar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 Cannon, John . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Bose, Raj Chandra . . . . . . . . . . . . . . . . . . . 215, 737, 756 Canny, John Francis . . . . . . . . . . . . . 619, 698, 739, 759
Bosma, Wiebren . . . . . . . . . . . . . . . . . . . . . . . . 6, 737, 739 canonical
bound form
Hasse ∼ . . . . . . . . . . . . . . . . . . 508, 562, 564, 565, 740 of a rational function . . 116, 117, 119, 121, 122,
Mignotte ∼ . . . . . . . . . . . . . . . . . . see Mignotte bound 124, 138
Weil ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568, 736 of a rational number . . . . . . . . . . . . . . . . . . 126, 127
Bourgne, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745 representative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Bouyer, Martine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 ring homomorphism . . . . . . . 72, 104, 110, 706, 709
Boyar, Joan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505, 737 Cantor, David Geoffrey . . . . 245, 247, 280–282, 287,
Boyle, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 726 405, 406, 417, 418, 466, 739
BPP . . . . . . . . . . . . . . . . . 496, 532, 616, 721, 722, 724 and Zassenhaus algorithm . . . . . . . . . . . . . . 382, 407
Brassard, Gilles . . . . . . . . . . . . . . . . . . . . . . . . 41, 720, 737 multiplication algorithm . . . . . . . . . . . 281, 282, 287
Bratley, Paul . . . . . . . . . . . . . . . . . . . . . . . . . . . 41, 720, 737 Carathéodory, Constantin . . . . . . . . . . . . . . . . . . . . . . . 586
Brauer, Alfred Theodor . . . . . . . . . . . . . . . . . . . . . . . . . 737 cardinality, # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704, 768
Bremner, Murray Ronald . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Carlitz, Leonard . . . . . . . . . . . . . . . . . . . . . . . . . . 426, 739
Brent, Richard Peirce . . . 61, 90, 332, 353, 354, 542, Carlyle, Thomas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
567, 738 Carmichael, Robert Daniel . . . . . . . . . . . . . . . . 531, 739
Brickell, Ernest Francis . . . . . . . . . . . . . . . . . . . 509, 738 function, λ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Brieskorn, Egbert . . . . . . . . . . . . . . . . . . . . . . . . . 568, 738 number . . . 520, 521–523, 531, 532, 535, 537, 735
Brillhart, John David . . . . . . . 541, 542, 568, 738, 758 Carmody, Phil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Broda, Engelbert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 Caron, Thomas R. . . . . . . . . . . . . . . . . . . . . 531, 567, 739
Bronstein, Manuel . . . . 640–642, 671, 735, 738, 760 le Carré, John (David John Moore Cornwell) . . . 220,
Brook, Clifford Hardman (Clive) . . . . . . . . . . . . . . . . 729 727
Brown, William Stanley . . . . . . 62, 197–199, 332, 738 Carroll, Lewis (Rev. Charles Lutwidge Dodgson)
Brownawell, Woodrow Dale . . . . . . . . . . . . . . 618, 738 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28, 726
Brun, Viggo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758 carry
Bruns, Winfried . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 flag . . . . . . . . . . . . . . . . . . . . . 30, 41, 42, 222, 262, 280
AJk
Bshouty, Nader Hanna ( úGñ
. PXAK ) . . . 353, 751 look-ahead addition . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
bubble sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 de Casteljau, Paul de Faget . . . . . . . . . . . . . . . . 138, 739
Bucciarelli, Louis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Castelnuovo, Guido, -Mumford regularity . . . . . . . 618
Buchberger, Bruno 21, 591, 609, 618, 738, 740, 750, Cataldi, Pietro Antonio . . . . . . . . . . . . . . . . . . . . . . 89, 739
753, 757 Cauchy, Augustin Louis . . . . 131, 132, 197, 286, 373,
algorithm . 591, 608, 609, 610, 611, 612, 617, 747 739, 740, 755
Buchmann, Johannes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 interpolation . . . 118, 121, 137, 138, 190, 325, 331
Budach, Lothar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 762 -Schwarz inequality . . . . . . . . . . . . . . . 485, 500, 555
Buffon, Georges Louis Leclerc, Comte de . . . . . . . 198 sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Buhler, Joe Peter . . . . . . . . . . . . . . . . . . . . . . . . . . 759, 764 Cavalieri, Bonaventura . . . . . . . . . . . . . . . . . . . . . . . . . . 622
Bunch, James Raymond . . . . . . . . . . . . . . . . . . . 352, 738 Caviness, Bob Forrester . . . . . . . . . . . . . . . . . . . 640, 740
772 Index
content, cont(·) . . 147, 148, 149, 150–152, 162, 192, ElGamal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579, 580
199, 200, 433, 695 elliptic curve ∼ . . . . . . . . . . . . . . . . . . . . . . . . . 573, 580
continuant polynomial . . . . . . . . . . . . . . . . . . . . . . . 65, 93 key in a ∼ . . . . . . . . . 16, 18, 505, 509, 573, 573–582
continued fraction . . 3, 69, 79–81, 84, 87, 89–91, 93, knapsack ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503, 509
94, 132, 542, 768 Rabin ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573, 579
expansion . . . . . . . . . . . . . 79, 80, 81, 84, 87, 90, 568 RSA ∼ . . . . . . . . . . . . . . . . . . . . see RSA cryptosystem
factoring method . . . . . . . . . . . . . . . . . . . . . . . 541, 568 short vector ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
control point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 subset sum ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
convergent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 symmetric ∼ . . . . . . . . . . . . . . . . . . . . . . . . . 16, 575, 578
convex cubic spline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 Cucker, Felipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
hull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Cunn, Samuel . . . . . . . . . . . . . . . . . . . . . . . . 725, 726, 758
convolution Cunningham, Lt.-Col. Allan Joseph Champneys
cyclic ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230, 231 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541, 543, 741
fast ∼ . . . . . 235, 240, 244, 250, 251, 252, 253, 254 number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222, 542
negative wrapped ∼ . . . . . . . . . . . . . . . . . . . . . 238, 239 project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541, 542, 569
of polynomials . . . . . . . . . . . . . . . 230, 235, 237, 252 curve
of signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368, 369 algebraic ∼ . . . . . . . . . . . . . . . . 11, 172, 174, 175, 696
property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Bézier ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Vandermonde ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672 elliptic ∼ . . . . . . . . . . . . . . . . . . . . . . . . see elliptic curve
Conway, John Horton . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 Gauß bell ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Cook, Stephen Arthur . . . . . . . . . 6, 247, 286, 722, 741 nonsingular ∼ . . . . . . . . . . . . . . . . . . . . . . 559, 568, 571
Cookie Monster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 plane ∼ . . . . . . . . . . . . . . . . . . 173, 198, 203, 594, 615
Cooley, James William . . . . . 233, 247, 294, 727, 741 projective ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567, 568
Coppersmith, Don 352, 353, 420, 741, 742, 750, 765 cycle structure of a permutation . . . . . . . . . . . . . . . . . 465
coprime . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 55, 450, 707 cyclic
Bézout-∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450, 471 code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Cori, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756 convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230, 231
Corless, Robert Malcolm . . . . . . . 7, 41, 287, 741, 751 group . . . . . . . . . . 250, 251, 349, 422, 578, 704, 713
Cormen, Thomas H. . . . . . . . . . . . . . . . . . . . 41, 368, 741 module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349, 350
co-RP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532, 722, 723 cycloheptane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694, 698
de Correa, Isabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 cyclohexane 11, 12, 14, 16, 494, 619, 685–699, 725
coset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704, 715 conformation of ∼ 11, 12, 15, 685, 687, 689, 698,
cyclotomic ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 699
of an ideal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 boat ∼ . . . . . . . . . . . . 12, 13, 15, 16, 690, 691, 696
cosine theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 chair ∼ . . . . . . . . . . . . . . . 12, 13, 16, 686, 692, 693
Cot, Norbert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747, 760
flexible ∼ . . . . . . . . . . . . . . . . . . 12, 15, 16, 696, 698
Courant, Richard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
rigid ∼ . . . . . . . . . . . . . . . . . . . . . . . . . 12, 15, 16, 698
Cowie, James . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569, 741
cyclotomic
Cowles, John Richard . . . . . . . . . . . . . . . . . . . . . 199, 762
coset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Cox, David Archibald . . . . . . 568, 614, 617, 618, 741
polynomial, Φn . . . . . 164, 201, 211, 253, 412, 413,
Coxeter, Harold Scott Macdonald . . . . 531, 534, 736
414, 416, 421, 441, 442, 467, 568
CRA . . . . . . . . . . . . see Chinese Remainder Algorithm
Cramer, Gabriel . . . . . . . . . . . . . . . . . . . . . . 198, 724, 741
rule 116, 136, 157, 183, 186, 200, 204, 205, 485, D, differential operator . . . . . . . . . . 624, 633, 669, 673
716 D, division time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Cray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 D’Alembert, Jean le Rond . . . . . . . . . . . . . . . . . 676, 729
Creutzig, Christopher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Damgård, Ivan Bjerre . . . . . . . . . . . . . . . . . . . . . 532, 742
Crichton, Michael . . . . . . . . . . . . . . . . . . . . . . . . . 208, 726 Das, Abhijit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
critical line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 data
Cromwell, Oliver . . . . . . . . . . . . . . . . . . . . . . . . . 208, 726 compression . . . . . . . . . . . . . . . . . . . . . . . 307, 363–366
Crossley, John Newsome . . . . . . . . . . . . . . . . . . 727, 741 structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 493
crossover point . . . 221, 222, 241, 251, 279, 281, 282, database integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
337 Datta, Ruchira Sreemati . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
CRT . . . . . . . . . . . . . . see Chinese Remainder Theorem Daubert, Katja Elisabeth . . . . . . . . . . . . . . . . . . . . . . . . . . 7
cryptanalysis . . . . . . . . . . . . . . . . . . . . . . . . . 503, 504, 575 Davenport, James Harold . . . . . . . . . . . . . . . . . 641, 742
cryptography . . . . 11, 16, 18, 37, 209, 503, 505, 509, Davies, Charles . . . . . . . . . . . . . . . . . . . . . . . . . . . 432, 728
517, 523, 525, 573–582 Davis, Martin David, -Putnam procedure . . . . . . . . 678
public key ∼ . . . . . . . . . . . . 3, 17, 503, 575, 573–582 DCT, Discrete Cosine Transform 363, 364, 363–369
cryptosystem . . . . . . . . 3, 17, 503, 504, 541, 542, 573, Dean, Basil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
573–582 Dèbes, Pierre . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498, 742
asymmetric ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17, 575 de Casteljau, Paul de Faget . . . . . . . . . . . . . . . . 138, 739
774 Index
decimal representation . . . 31, 37, 40, 70, 71, 82, 92, difference
100, 505 equation . . . . . . . . . . . . . . . . . . . . . . 660, 669, 671, 675
decision problem . . . . . . . . . . . . . . . . . . . . . . . . . . 721, 722 field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659, 660, 675
hard ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 operator, ∆ . . . . . . . . . . . . . . 646, 647, 660, 671, 673
instance of a ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 differential
Decker, Wolfram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 algebra . . . . . . . . . . . . . . . . . . . . . . . 623, 624, 640, 641
de Correa, Isabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 equation . . . 1, 4, 90, 353, 428, 633, 640–643, 653,
decryption . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17, 573–582 669, 684
Dedekind, Julius Wilhelm Richard . . . 373, 419, 742, Risch ∼ . . . . . . . . . . . . . . . . . . . . 641, 738, 742, 750
746 field . . . . . . . . . . . . . . . . . . . . . . . . . . 624, 625, 633, 641
Degeyter, Pierre-Chrétien . . . . . . . . . . . . . . . . . . . . . . . 727 operator, D . . . . . . . . . . . . . . . . . . . 624, 633, 669, 673
degree Diffie, Bailey Whitfield 503, 575, 576, 578, 581, 742
formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 -Hellman
function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63, 94 key exchange . . . . . . . . . . . . . . 573, 578, 579, 756
of a field extension . . . . . . . . . . . . . . . . 384, 710, 711 Problem . . . . . . . . . . . . . . . . . . . . . . . . 579, 580, 582
of a polynomial, deg . . . . . . . . . . . . . . . . 32, 708, 709 digital
of an algebraic element . . . . . . . . . . . . . . . . . . . . . . . 710 filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
sequence . . . 92, 93, 142, 178–181, 187, 188, 190, signal . . . . . . . . . . . . . . . . . . . . . . . . 247, 359, 363, 368
204, 314, 329, 333 signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
normal ∼ . 51, 53, 59, 60, 65, 93, 195, 314, 317, dimension
319, 321–324, 326, 330, 333 formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
total ∼ . . . . 157, 172, 176, 493, 597, 616, 689, 709 of a code . . . . . . . . . . . . . . . . . . . . . . . . . . 209, 210, 211
valuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91, 94, 274 of a lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474, 480
de Groote, Hans Friedrich . . . . . . . . . . . . . . . . . 352, 748 of a vector space . . . . 349, 401, 674, 685, 687, 688,
Delaunay, Charles Eugène . . . . . . . . . . . . . . . . . . . . . . . 20 698, 710, 711, 714
∆, difference operator . . . . . 646, 647, 660, 671, 673 Diophantine
DeMillo, Richard Allan . . . . . . . . . . . . . . . . 88, 198, 742 approximation . . 3, 79, 80, 87, 473, 497, 505, 762
de Moivre, Abraham . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 simultaneous ∼ . . . . . 87, 503, 505, 507–509, 753
De Morgan, Augustus . . . . . 44, 68, 96, 622, 726, 729 equation . . . . . . . . . . . . . . . . . . . . . . . . . . . 512, 764, 766
Deng, Yuefan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352, 740 linear . . . . . . . . . . . . . . . . . . . . . . . . 69, 77, 79, 89, 93
dense representation . . . . . . . . . . . . 101, 231, 493, 494 Diophantus of Alexandria (Διόφαντος
derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197, 624 ᾿Αλεξανδρέως) . . . . . . . . . . . . . . 513, 514, 754, 756
derivative . . 113, 114, 122, 133, 156, 213, 259, 265, direct product
266, 267, 289–291, 300, 394, 623, 624, 633, 642, of finite probability spaces . . . . . . . . . . . . . . . . . . . . 718
647, 667, 768 of groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Hasse-Teichmüller ∼ . . . . . . see Hasse-Teichmüller of rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706
logarithmic ∼ . . . . . . . . . . . . 633, 635, 636, 639, 641 directed graph . . . . . . . . . . . . . . . . . . . . . . . . 423, 468, 679
trivial ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624, 642 Lejeune Dirichlet, Johann Peter Gustav . . . . . 62, 506,
D ERIVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 507, 509, 528, 588, 707, 742
de Sainte-Croix, Jumeau . . . . . . . . . . . . . . . . . . . . . . . . 669 Schubfachprinzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
Descartes, René, du Perron . 334, 512, 622, 727, 729, DISCO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
796 Discrete
designed distance of a BCH code . . . . . . . . . . 212, 213 Cosine Transform (DCT) . . . . . 363, 364, 363–369
determinant, det . . . 50, 100, 109–111, 113, 136, 157, Inverse ∼ (IDCT) . . . . . . . . . . . . . . . 363, 366, 369
172, 197–199, 204, 205, 328, 329, 335, 337, 688, Fourier Transform (DFT) . . . . . 229, 221–254, 262,
715, 716 340, 352, 362, 359–369
Gramian ∼ . . . . . . . . . . . . . . . . . . . . . . . . . 482, 484, 717 Logarithm Problem (DL) . . . . . . . . . . 579, 580, 582
modular ∼ . . . . . . . . . . . . . . . . . . . . 109, 113, 132, 525 signal . . . . . . . . . . . . . . . . . . . 359, 360–364, 368, 369
big prime ∼ . . . . . . . . . . . 110, 113, 168, 460, 526 discriminant, disc 156, 207, 435, 441, 443, 454, 455,
small primes ∼ . . . . . . . see modular determinant 466, 467, 470, 471, 537, 689
de Weger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . see Weger dispersion, dis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
DFT . . . . . . . . . . . . . . . . see Discrete Fourier Transform distinct-degree
DH . . . . . . . . . . . . . . . . . . . . see Diffie-Hellman problem decomposition . . . . . . . . . . . . . . . . 381, 392, 400, 422
Diamond, Harold George . . . . . . . . . . . . . . . . . . . . . . . 745 factorization . . . . . . . . 373, 381, 377–421, 461, 462
diatonic scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85, 86 distributed
Díaz, Angel Luis . . . . . . . . . . . . . . . . . . . . . 199, 498, 742 computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19, 99, 567
Dickman, Karl Daniel, ρ-function . . . . . . . . . . . . . . . 553 data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 19
Dickson, Leonard Eugene . . . . . . . . . . . . . . 88, 591, 742 divide-and-conquer . . . 286, 289, 298, 300, 309, 317,
lemma . . . . . . . . . . . . . . . . . . . . . . . . 602, 603, 604, 620 353
Didymos of Alexandria (Δίδυμος ᾿Αλεξανδρέως) division
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 exact ∼ . . . . . . . . . . . . . . 42, 202, 251, 261, 289, 310
Index 775
property . . . . . . . . . . . . . . . . . . . . . . . . . . . 706, 707, 709 elliptic curve . . . . . . . . . . 508, 558, 557–568, 571, 580
pseudo-∼ . . 38, 183, 190, 191, 197, 199, 204–206 cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . . . . 573, 580
time, D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 factoring method . . . 287, 541, 542, 563, 557–567,
trial ∼ . . . . . . . . . . . . . . . . . . . 389, 541, 543, 544, 552 571
with remainder . . . . . . 2, 26, 37, 38, 39, 41, 45, 51, size of an ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561, 565
59–62, 100, 131, 257, 261, 262, 282, 283, 314, smooth ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559, 560
407, 445 Emiris, Ioannis Zacharias (᾿Εμίρης, ᾿Ιωάννης
fast ∼ . . . . . . . . . . . . 221, 261, 264, 282, 287, 339 Ζαχαρίου) . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 698, 743
multivariate ∼ . . . . 595, 598, 599, 600, 604, 605 Encarnación, Mark James . . . . . . . . . . . . . . . . . 465, 741
Dixon, Alfred Cardew . . . . . . . . . . . . . . . . . . . . . 671, 743 Encke, Johann Franz . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746
Dixon, John Douglas . . . . . . . . . . . . . . 61, 568, 569, 742 encoding map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
random squares method . 340, 541, 549, 550, 551, encryption . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17, 573–582
556, 558, 567, 569, 570, 579 endomorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714, 715
DL, Discrete Logarithm Problem . . . . . 579, 580, 582 Frobenius ∼ . . . . 398, 402, 404, 427, 428, 713, 746
Dodson, Bruce . . . . . . . . . . . . . . . . . . . . . . . 569, 741, 742 Eneström, Gustav . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
Don Quixote de la Mancha . . . . . . . . . . . . . . . . . . 90, 740 Engel, Friedrich . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
Dooley, Samuel Sean . . . . . . . . . . . . . . . . 738, 746, 763 E NIGMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Dörge, Karl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466, 742 entropy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298, 324, 452
Dornstetter, Jean Louis . . . . . . . . . . . . . . . . . . . . 215, 742 equal-degree
double-precision integer . . . . . . . . . . . . . . . . . . . . . . . . . . 29 factorization . . . 387, 377–421, 424, 461, 462, 554,
Doughty, Herb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757 579
Doyle, Sir Arthur Conan . . . . . . . . 572, 702, 728, 729 splitting . . . . . . . . . . . . . . . . . . . . . . 385, 387, 423, 424
Dozier, Lamont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 equivalence relation . . . . 92, 314, 332, 430, 673, 707
Dreker, Stefan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Erasmus of Rotterdam . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Dresden, Arnold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 erasure code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 215
Dress, Andreas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498, 741 Eratosthenes of Cyrene (᾿Ερατοσθένης ὁ
Drobisch, Moritz Wilhelm . . . . . . . . . . . . . . . . . . 91, 742 Κυρηναι̃ος) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 518
Dubé, Thomas Willliam . . . . . . . . . . . . . . . . . . . 618, 742 sieve . . . . . . . . . . . . . . . 171, 527, 531, 533, 552, 557
Dubner, Harvey Allen . . . . . . . . . . . . . . . . . . . . . 530, 766 Erdmann, Johann Eduard . . . . . . . . . . . . . . . . . . . . . . . . 726
Dubois, Raymond . . . . . . . . . . . . . . . . . . . . . . . . . 532, 742 Erdős, Pál . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512, 567, 739
du Bois-Reymond, Emil . . . . . . . . . . . . . . . . . . . . . . . . . 588 ERH . . . . . . . . . . . . see Extended Riemann Hypothesis
Ducos, Lionel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199, 742 Ernie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Dupré, Athanase . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61, 742 error
Durucan, Emrullah . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 correcting code . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 209
dynamical systems theory . . . . . . . . . . . . . . . . . . . . . . . 276 locator polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Euchner, Martin . . . . . . . . . . . . . . . . . . . . . . . . . . . 497, 762
Euclid (Εὐκλείδης) . . . . 3, 24, 25, 26, 44, 61, 73, 93,
E, shift operator . . . . . . . . . . . . 646, 648, 659, 660, 671 518, 531, 724, 725, 748
early abort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 Euclidean
Eberly, Wayne Michael . . . . . . . . . . . . . . . . . 6, 353, 742 Algorithm . . 3, 4, 25, 45–207, 313–333, 530, 612,
Edmonds, Jeffrey Allen . . . . . . . . . 215, 679, 735, 741 616, 707, 738, 742, 754, 756, 763, 765, 766
Edmonds, John Robert (Jack) . . . . . . . . . . . . . 132, 742 binary ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61, 65, 738
EEA . . . . . . . . . . . . see Extended Euclidean Algorithm Extended ∼ (EEA) . . . . see Extended Euclidean
effective univariate factorization . . . . see factorization fast ∼ . . 3, 7, 178, 263, 325, 313–333, 345, 626
eigenvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716 monic ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . see monic
Einstein, Albert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 primitive ∼ . . 190, 191, 192, 194–197, 199, 206
Eisenbrand, Friedrich . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 quotient in the ∼ . . . . . . . . . . . . . . . . . . . see quotient
Eisenbud, David . . . . . . . . . . . . . . . . 617, 697, 742, 743 remainder in the ∼ . . . . . . . . . . . . . . . see remainder
Eisenstein, Ferdinand Gotthold Max . 373, 533, 743 traditional ∼ . . . . . . . . . . . . . . . . . . . . . see traditional
theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 with least absolute remainders . . . . . . . . . . . . . . . 66
Ekhad, Shalosh B. . . . . . . . . . . . . . . . . . . . . . . . . 697, 743 domain . . 45, 45–95, 97, 104, 106, 135, 147, 158,
Eleatics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 159, 186, 257, 352, 595, 707, 708–711
Electronic Frontier Foundation . . . . . . . . . . . . . . . . . . 517 engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
elementary function . . . . . . . . . . . . . 46, 47, 48, 61–64, 257, 707
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623 minimal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 63
symmetric polynomial . . . . . . . . . . . . . . . . . . . . . . . . 166 norm, two-norm, || · ||2 . . . . 12, 157, 164, 473, 474,
Elements (Euclid) 24, 25, 26, 61, 518, 531, 724, 725 480, 487, 497, 717, 768
ElGamal, Taher ( ÈAÒm.Ì '@ QëA£) . . . . . . . . . . . . see Gamal number field . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724, 755
elimination of variables . . . . . . . . . . . . . . . . . . . . . . . . . 172 representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Elkenbracht-Huizing, Reina Marije . . . . . . . . 569, 741 Eudoxus of Cnidus (Εὔδοξος Αἰσχίνου Κνίδιος)
ellipsoid method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
776 Index
Euler, Leonhard . . 62, 76, 88–91, 131, 132, 134, 197, modular ∼ . . . . . . . . . . . . . . see modular factorization
198, 372, 418, 513, 520, 533, 542, 586, 644, 670, of integers . . . . 3, 17, 18, 198, 222, 335, 340, 352,
735, 743, 753, 761 353, 505, 513, 517, 521, 531–533, 541,
constant, γ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534, 651 541–571, 577–579
number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 of multivariate polynomials . . . . . . . . 493, 497, 501
theorem . . . . . . . . . . . . . . . . . . . 17, 518, 519, 577, 704 of polynomials . . 2, 4, 15, 20, 148, 271, 282, 286,
totient function, ϕ . . . . 17, 75, 108, 131, 136, 250, 372, 373, 377, 377–501, 505, 513, 586, 588
412, 518, 535, 577 over Z and Q . . . . . 37, 100, 164, 257, 373, 440,
evaluation 433–471, 473, 474, 487–501, 525, 528
homomorphism . . . . . . . . . . . . . . . . . . . . . . . . . 107, 709 over finite fields 3, 77, 279, 283, 340, 352, 389,
map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103, 215, 295 377–430, 461–463, 488, 493, 569, 724
multipoint ∼ 19, 97–103, 231–233, 280, 281, 295, of sparse polynomials . . . . . . . . . . . . . . . . . . . . . . . . 497
296, 299, 300, 302, 309, 333, 339, 399, 407, pattern . . . 435, 442, 443, 444, 462, 465, 467, 468
460 prime ∼ . . 106, 131, 291, 292, 518, 529, 535, 550,
fast ∼ . . . . . . . 231, 295, 298, 299, 308, 399, 544 554
of a matrix . . . . . . . . . . . . . . 340, 346, 348, 352, 353 squarefree ∼ . . . 377, 379, 389, 393, 395, 397, 416,
Evdokimov, Sergeı̆ Alekseevich (Evdokimov 426, 658
Serge i Alekseeviq) . . . . . . . . . . . . . . 421, 743 unique ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706, 707
Eve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 573, 580, 582 domain (UFD) see unique factorization domain
event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 Faddeev, Dmitriı̆ Konstantinovich (Faddeev
eventually positive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720 Dmitri i Konstantinoviq) . . . . 132, 419,
exact division . . . . . . . . . . 42, 202, 251, 261, 289, 310 744
exp, exponential function . . . . . . . . . . . . . . . . . . . . . . . 768 Faddeeva, Vera Nikola’evna (Faddeeva Vera
expected value . . . . . . . . . . . . . 184, 205, 411, 682, 718 Nikolaьevna) . . . . . . . . . . . . . . . . . . . . . . 132, 744
EX PEX PT IME . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 Fahle, Torsten Klemens . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
explicit linear algebra . . . . . . . . . . . . . . . . 335, 352, 407 falling factorial . . 647, 649, 654, 669, 670, 673, 768
EX PSPA CE . . . . . . . . . . . . . . . . . . . . . . . 616, 697, 723 Fano, Robert Mario . . . . . . . . . . . . . . . . . . . . . . . 307, 744
EX PT IME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 fast
Extended convolution . . . . 235, 240, 244, 250, 251, 252, 253,
Euclidean Algorithm (EEA) . . 17, 48, 57, 45–207, 254
214, 242, 283, 304, 313–333, 344, 407, 448, CRA . . . . . . . . . see Chinese Remainder Algorithm
450–452, 505, 577, 710 division with remainder . . . . . . . . . . . . . . see division
big prime modular ∼ . . . . . . . 189, 190, 195, 206 Euclidean Algorithm . . . see Euclidean Algorithm
bivariate modular ∼ . . . . . . . . . . . . . . . . . . . . . . . . 189 exponentiation . . . . . . . . . . . . . . . . . . . . . . . . . . 373, 580
modular ∼ . . . . . . . . . . . . . 183, 186, 206, 326, 331 integer multiplication . . . . . . . . . . . . . . . . . . . . 221–254
primitive ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 interpolation . . . . . . . . . . . . . 231, 301, 295–310, 331
small primes modular ∼ . . . . . see modular EEA matrix multiplication . . . . . . . . . . . . . . 336, 337, 340
traditional ∼ . . . . . . . . . . . . . . . . . . . . . see traditional modular composition . . . . . . . . . . . . . . 338, 339, 405
Riemann Hypothesis (ERH) . . 421, 532, 533, 743, multipoint evaluation . . . . . . . . . . . . . . see evaluation
759 polynomial multiplication . . . . . . . . . . . . . . . 221–254
extension field . . . . . . . . . . . . . . . . . . . see field extension sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
EZ-GCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460, 466 Fast Fourier Transform (FFT) . . . 3, 19, 82, 211, 233,
221–254, 281, 363, 364, 373, 741, 744, 747, 748,
factor 760
base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550, 557 arithmetic circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
combination . . . 434–436, 441, 453, 455, 458, 462, Fermat number ∼ . . . . . . . . . . . . . . . . . . . . . . . . 284–286
465, 489, 492, 496, 497 multiplication . . . 3, 101, 238, 243, 247, 250, 251,
group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704 262, 279, 280, 283, 286, 333
factorial support the ∼ . . . . . . . . . . . . 237, 245, 251, 296, 333
falling ∼ . . . . . . . 647, 649, 654, 669, 670, 673, 768 3-adic ∼ . . . . . . . . . . . . . . . . . . . . . . 242, 247, 252, 253
greatest ∼ factorization, gff . see greatest factorial three primes ∼ . . . . . . 243, 246, 247, 283, 284, 286
ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 Fateman, Richard Jay . . . . . . . . . . . . . . . . . . . . . 640, 737
rising ∼ . . . . . . . . . . . . . . . . . . . . . . . 647, 670, 673, 768 Faugère, Jean-Charles . . . . . . . . . . . . . . . . . . . . . 619, 744
factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2, 20 Faulhaber, Johann . . . . . . . . . . . . . . . . . . . . . . . . . 670, 752
bivariate ∼ . . . . . 433, 457, 459, 493, 496, 497, 586 feasible matrix multiplication exponent . . . . 337, 338,
by continued fraction method . . . . . . . . . . . 541, 568 352
by elliptic curve method . . . . . . . . see elliptic curve Feisel, Sandra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 7
distinct-degree ∼ . . . . 373, 381, 377–421, 461, 462 Felkel, Anton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
effective univariate ∼ . . . . 457, 459, 473, 493, 501 Feller, William . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717, 744
equal-degree ∼ . . . . . see equal-degree factorization Ferdinand, Duke of Braunschweig . . . . . . . . . . . . . . 372
greatest factorial ∼ , gff . . . . . see greatest factorial Ferdinand von Fürstenberg . . . . . . . . . . . . . . . . 514, 725
irreducible ∼ . . . . . . . . . see irreducible factorization Fermat, Clément-Samuel de . . . . . . . . . . . . . . . 514, 725
Index 777
Fermat, Pierre de . . 3, 7, 24, 76, 88, 89, 93, 218, 512, Flajolet, Philippe Patrick Michel 419, 697, 744, 759,
513, 514, 520, 530, 550, 622, 669, 725, 739, 741, 763, 765
743, 744, 764, 765 Fleischer, Jochem . . . . . . . . . . . . . . . . . . . . 736, 748, 760
last theorem . . . . . . . . . . . . . . . . . . 514, 595, 761, 766 flexible conformation see cyclohexane conformation
liar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519, 534 floating point
little theorem . . . . 77, 88, 379, 380, 398, 513, 518, arithmetic . . . . . . . . . . . . . . . . . . . . . . . 20, 82, 283, 497
520, 531, 704, 712, 713, 742, 743 number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32, 286, 337
number, Fn . 76, 88, 246, 513, 520, 530, 538, 542, representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
738, 755 Floyd, Robert W. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
FFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284–286 cycle detection trick . . . . . . . . . . 546, 547, 548, 567
polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493 fluxions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
primality test . . . . . . . . . . . . 519, 520, 521, 523, 534 FOCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
prime . . . . . . . . . . . . . . . . . . . . . . . . . 228, 251, 530, 536 Folkerts, Menso . . . . . . . . . . . . . . . . . . . . . . 286, 727, 744
witness . . . . . . . . . . . . . . . . . . 519, 520, 522, 523, 534 Ford, Garrett . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
Feynman, Richard Phillips . . . . . . 220, 540, 727, 728 Fourier, Jean Baptiste Joseph . . . . 247, 358, 727, 744
FFT . . . . . . . . . . . . . . . . . . . . . see Fast Fourier Transform coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362, 369
Fibonacci, Leonardo Pisano, son of Bonaccio prime . . . . . . . . . . . . . . . . 99, 243, 246, 528, 529, 536
number . . . . . . . . . . . . . . . . . . . 53, 54, 61, 66, 89, 742 series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361, 741
sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66, 341, 343 Transform . . . . . . . . . . 247, 359, 361–363, 369, 513
Fich, Faith Ellen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Continuous ∼ . . . . . . . . . . . . . . . . . . . 359, 361, 362
Fiduccia, Charles (Chuck) Michael . . . 306, 353, 744 Discrete ∼ (DFT) . . . . . . . . . see Discrete Fourier
Fieker, Claus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 Fast ∼ (FFT) . . . . . . . see Fast Fourier Transform
field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32, 708, 710, 711 F p , finite prime field . . . 73, 421, 427, 428, 462, 471,
algebraic number ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 568
difference ∼ . . . . . . . . . . . . . . . . . . . . . . . 659, 660, 675 Fq , finite field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73, 712
differential ∼ . . . . . . . . . . . . . . . . . 624, 625, 633, 641 fractal . . . . . . . . . . . . . . . . . . . . . 226, 273, 276–278, 287
extension . . . . . . . 74, 398, 408, 411, 633, 663, 710, Franke, Jens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542, 751
711–713 Fredet, Anne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641, 738
algebraic ∼ . . 175, 343, 378, 384, 493, 627, 630, Freeman, Timothy Scott . . . . . . . . . . . . . . . . . . . 498, 744
710, 711 Frege, Friedrich Ludwig Gottlob . . . . . . . . . . 588, 739
degree of a ∼ . . . . . . . . . . . . . . . . . . . . 384, 710, 711 -Hilbert proof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
finite ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 Freivalds, Rùsiņš . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88, 744
Galois ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 Frénicle de Bessy, Bernard . . . . . . . . . . . . . . . . . . . . . . 513
normal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 frequency . . . . . . 84–86, 359, 360, 361–363, 365, 366
finite ∼ , Fq . . . . . . . . . . . . . . . . . . . . . . . . see finite field analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Hilbertian ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 Friedman, Philip . . . . . . . . . . . . . . . . . . . . . 472, 572, 728
of constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627, 659 Frieze, Alan Michael . . . . . . . . . . . . . . . . . . . . . . 505, 744
of fractions . 42, 79, 147, 149, 150, 152, 157, 177, FRISCO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
186, 191, 200, 275, 292, 433, 500, 710 Frisé, Adolf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
operation . . . . . . . . . . . . . . . . see arithmetic operation Frobenius, Ferdinand Georg . . . . . 132, 197, 441, 465,
perfect ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 744, 745
splitting ∼ 177, 426, 429, 441, 627, 628, 630, 711 automorphism . . . . . . . . . . . . . . . . 398, 420, 465, 713
Fields, John Charles, medal . . . . . . . . . . . . . . . . . . . . . 591 density theorem . . . . . . . . . . . . . . 441, 442, 443, 465
Finck, Pierre Joseph Étienne . . . . . . . . . . . . . . . . 61, 744 endomorphism 398, 402, 404, 427, 428, 713, 746
fingerprinting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70, 88, 91 polynomial representation of the ∼ . . . 398, 408
finite iterated ∼ algorithm . . . . . . . see iterated Frobenius
-dimensional vector space . . . . . . . . . . . . . . 710, 714 Fröhlich, Albrecht . . . . . . . . . . . . . . . . . . . 419, 745, 753
duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363, 369 Fuchssteiner, Benno . . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 20
extension of a field . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 Fulton, William . . . . . . . . . . . . . . . . . . . . . . . . . . . 568, 745
field, Fq . . . 2, 18, 20, 55, 73, 75, 76, 88, 229, 266, functional decomposition . . . . . . . . . . . . 576, 580, 581
286, 313, 355, 377–430, 711, 712, 713 fundamental
irreducibility test over a ∼ . . . . . . . . . . . . . . . . . . 407 lemma about gff . . . . . . . . . . . . . . . . . . . 657, 658, 661
root finding over a ∼ . . . . . . . . 377, 392, 418, 428 period . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
prime field, F p . 73, 421, 427, 428, 462, 471, 568 theorem
probability space . . . . . . . . . . . . . 703, 717, 718, 719 of algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372, 711
finitely generated of calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
ideal . . . . . . . . . . . . . . . . . . . . . . . . . . 593, 603, 604, 618 of number theory . . . . . . . . . . . . . . . . . . . . . 377, 518
vector space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 on subresultants . . . . . . . . . . . . . . . . . 327, 329, 332
Fish, Daniel W. . . . . . . . . . . . . . . . . . . . . . . . . . . . 540, 728 Fürer, Martin . . . . . . . . . . . . . . . 222, 244, 245, 247, 745
Fitch, John . . . . . . . . . . . . . . . . . . . . . . 740, 747, 750, 757
Fitchas, Noaï . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619, 744 Galileo Galilei . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
Flaccus, Aules Persius . . . . . . . . . . . . . . . . . . . . 699, 729 Gallagher, Patrick Ximenes . . . . . . . . . . . . . . . 466, 745
778 Index
Kedlaya, Kiran Sridhara . . . . 339, 405, 407, 408, 420, Kraft, Leon Gordon, Jr. . . . . . . . . . . . . . . . . . . . 307, 752
751 Kraïtchik, Maurice Borisovitch . . 376, 540, 567, 727,
Keller, Carsten . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 728, 752
Keller, Wilfrid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Krajíček, Jan . . . . . . . . . . . . . . . . . . . . 697, 736, 739, 752
Keller-Gehrig, Walter . . . . . . . . . . . . . . . . . . . . . 352, 751 Krandick, Werner Johannes . . . . . . . . . . . . . . . . . . . . 6, 7
Kelley, Colin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Kronecker, Leopold . . . . 28, 132, 137, 197, 247, 353,
Kempfert, Horst . . . . . . . . . . . . . . . . . . . . . . 417, 466, 751 465, 725, 742, 752
Kepler, Johannes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622 substitution . . . . . . . . . . . . . . 245, 246, 254, 494, 501
Kerber, Adalbert . . . . . . . . . . . . . . . . . . . . . . . . 7, 698, 736 Krummel, Volker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
kernel of a homomorphism, ker . 105, 349, 383, 401, Kruppa, Alexander . . . . . . . . . . . . . . . . . . . . . . . . 542, 751
704, 706, 709, 714 Krylov, Alekseı̆ Nikolaevich (Krylov Alekse i
Kerschensteiner, Georg . . . . . . . . . . . . . . . . . . . . . . . . . 747 Nikolaeviq) . . . . . . . . . . . . . . . . . . . . . . . 353, 753
key subspace . . . . . . . . . . . . . . . . . . . . . 341, 346, 347, 355
Diffie-Hellman ∼ exchange . . . see Diffie-Hellman Ku, Yu Hsui . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131, 753
in a cryptosystem . 16, 18, 505, 509, 573, 573–582 Küchlin, Wolfgang Wilhelm . . . . . . . . . . 736, 742, 746,
private ∼ . . . . . . . . 17, 504, 509, 575, 576–579, 582 748–751, 760, 761, 765
public ∼ . . . . . . . . 17, 503, 509, 575, 577–579, 582 Kuhnert, Martina Ariane . . . . . . . . . . . . . . . . . . . . . . . 7, 8
tonal ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85, 86 Kühnle, Klaus . . . . . . . . . . . . . . . . . . . . . . . 616, 617, 753
al-Khwārizmı̄, Abū Ja֒far Muh.ammad bin Mūsā Kummer, Ernst Eduard . . . . . . . . . . . . . . . . . . . . . . . . . . 514
ñm Ì '@ úæ
ñÓ áK . YÒm × Q®ªk
( ú× PP@
ñK @) . 68, 88, 90,
. . Kunerle, Jens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Kung, Hsiang Tseng . . . . . . . 286, 353, 354, 738, 753
256, 286, 726, 727, 741, 744, 762
Kipling, Joseph Rudyard . . . . . . . . . . . . . . . . . . 644, 729 Kurowski, Scott . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Kirchhoff, Gustav Robert . . . . . . . . . . . . . . . . . . . . . . . 728 Kvashenko, Kirill Yur’evich (Kvaxenko Kirill
Kirkpatrick, David Galer . . . . . . . . . . . . . . . . . . 353, 751 rьeviq) . . . . . . . . . . . . . . . . . . . . . . . . . . . 641, 735
Kiyek, Karl-Heinz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Klapper, Andrew Manoch . . . . . . . . . . . . . . . . . . . . . . . . . 7 Lafon, Jean-Claude . . . . . . . . . . . . . . . . . . . . . . . 671, 753
Klein, Felix . . . . . . . . . . . . . . . . . . . . . . . 25, 358, 586, 727 Lagally, Klaus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 Lagarias, Jeffrey Clarke . . . . 443, 505–507, 509, 580,
Kleinjung, Thorsten . . . . . . . . . . . . . . . . . . . . . . . 542, 751 744, 753
Klinger, Leslie Stuart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Lagrange (la Grange), Joseph Louis, Comte de . . 90,
knapsack 91, 131, 419, 590, 728, 753
cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . . . . 503, 509 interpolant . . . . . 101, 102, 105, 107, 131, 133, 246,
problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 249, 427
Kneller, Sir Godfrey, Baronet . . . . . . . . . . . . . . . . . . . 725 interpolation . . . . 18, 100, 101, 102, 107, 118, 134,
Knopfmacher, Arnold . . . . . . . . . . . . . . . . . . . . . 419, 752 299, 303, 739
Knopfmacher, John Peter Louis . . . . . . . . . . . 419, 752 multiplier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
Knörrer, Horst . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568, 738 theorem . . . 89, 212, 412, 415, 518, 519, 537, 538,
Knuth, Donald Ervin . . . . 7, 8, 25, 40, 61, 62, 88, 90, 562, 704, 712, 714
247, 286, 308, 332, 417, 505, 531, 567, 571, 669, Lakshman, Yagati Narayana . . . . . 498, 618, 744, 745,
670, 717, 720, 724, 747, 752 751, 753
Koblitz, Neal . . . . . . . . . . . . . . . . . . . 531, 568, 580, 752 Lalande, Joseph-Jérôme Lefrançais de . . . . . . . . . . . 728
von Koch, Niels Fabian Helge . . . . . . . . . . . . . 287, 752 LaMacchia, Brian A. . . . . . . . . . . . . . . . . . . . . . . 353, 753
snowflake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278, 287 λ, Carmichael function . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Koepf, Wolfram . . . . . . . . . . . . . . . . . 670, 671, 697, 752 λ, length of an integer . . . . . . . . . . . . . . . . . . . 30, 53, 142
Kohel, David Russell . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 Lambe, Larry Albert . . . . . . . . . . . . . . . . . . . . . . . . 21, 753
Kolaitis, Phokion-Gerasimos (Κολα´ϊτης, Lambert, Johann Heinrich . . . . . . . . . . . . . . . . . . . 82, 753
Φωκίων-Γεράσιμος) . . . . . . . . . . . . . . . . . . . . . . . 760 Lamé, Gabriel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61, 753
Kollár, János . . . . . . . . . . . . . . . . . . . . . . . . . 618, 735, 752 theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61, 66
Kollberg, Lennart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 Lamport, Leslie B. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Kolmogorov, Andreı̆ Nikolaevich (Kolmogorov Lanczos, Cornelius . . . . . . . . . . . . . . . . . . . . . . . . 353, 754
Andre i Nikolaeviq) . . . . . . . . . . . . . . . . . . 247 algorithm . . . . . . . . . . . . . . . . . . . . . 353, 741, 742, 758
Kondo, Shigero . . . . . . . . . . . . . . . . . . . . . . . . . 82, 90, 767 Landau, Edmund Georg Hermann . . . . 165, 586, 724,
Koornwinder, Tom Hendrik . . . . . . . . . . . . . . . . . . . . . . . 7 748, 752, 754
Körner, Heiko . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 inequality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165, 166
Korselt, Alwin Reinhold . . . . . . . . . . . . . . . . . . 532, 752 Landau, Susan Eva . . . . . . . . . . . . . . . . . . . 576, 581, 752
criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 Landrock, Peter . . . . . . . . . . . . . . . . . . . . . . . . . . . 532, 742
Kotsireas, Ilias Sotirios (Κοτσιρέας, ᾿Ηλίας Landry, Fortuné . . . . . . . . . . . . . . . . . . . . . . . . . . . 542, 754
Σωτηρίου) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Lang, Serge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498, 754
Kovalevskaya, Sof’ya Vasil’evna (Sonya Kowalewski, Lange, Tanja . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421, 754
Kovalevska Sofь Vasilьevna) . . 726 Laplace (la Place), Pierre Simon, Marquis de . . . 294,
Koy, Henrik . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497, 752 432, 724, 725, 727, 728, 754
Kozen, Dexter . . . . . . . . . . . . . 576, 581, 619, 736, 752 expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159, 716
Index 783
Larson, Richard Gustavus . . . . . . . . . . . . . . . . . 532, 735 Levin, Leonid Anatol’evich (Levin Leonid
Las Vegas Anatolьeviq) . . . . . . . . . . . . . . . . . . . . . . 724, 755
algorithm . . . . . . . . . . . 161, 198, 402, 470, 471, 724 Lewin, Daniel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199, 755
Turing machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 lexicographic order . . . 596, 598, 608, 615, 694, 695
lattice . . . . 3, 286, 434, 473, 473–501, 504, 506–508, Leykin, Anton (Le i kin, Anton Gennadi i oviq)
573, 712 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748
dimension of a ∼ . . . . . . . . . . . . . . . . . . . . . . . . 474, 480 Leyland, Paul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
norm of a ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473, 474 Li, Gang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352, 740
Laue, Reinhard . . . . . . . . . . . . . . . . . . . . . . . . . . . 698, 736 Lickteig, Thomas Michael . . . . . . 184, 199, 332, 755
Lauer, Daniel (Daniel Reischert) . . 7, 198, 279, 332, L IDIA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20, 279
466, 754, 761 Lidl, Rudolf . . . . . . . . . . . . . . . . . . . . . . . . . . 421, 711, 755
Laurent, Pierre Alphonse, series . . . . . . . . . 91, 94, 768 Lie, Marius Sophus . . . . . . . . . . . . . . . . . . . . . . . 622, 728
law of quadratic reciprocity . . . . . 372, 529, 537, 586 von Lindemann, Carl Louis Ferdinand . . . . . . . 82, 755
Lawrence, Thomas Edward . . . . . . . . . . . . . . . 140, 726 Lindner, Charles Curt . . . . . . . . . . . . . . . . . . . . . 215, 749
Lazard, Daniel . . . . . . . . . . . . . 619, 640, 744, 754, 758 line at infinity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
-Rioboo-Trager integration . . . 627, 630, 631, 640, linear
758 algebra . . . . 3, 4, 21, 109, 175, 179, 335–356, 373,
lc, leading coefficient . . . . . . . . 32, 38, 597, 708, 709 401, 420, 475, 557, 703, 713, 714, 715
lcm, least common multiple . . . . . . . . . . . . . . . . . . 46, 57 black box ∼ . . . . . . 335, 340, 346, 352, 404, 407
le Carré, John . . . . . . . . . . . . . . . . . . . . . . . . . . . . . see Carré explicit ∼ . . . . . . . . . . . . . . . . . . . . . . . . 335, 352, 407
leading sparse ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
coefficient, lc . . . . . . . . . . . . . . 32, 38, 597, 708, 709 code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209, 215
digit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 40 combination map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
monomial, lm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598 congruential generator . . . . . . . . . . . . . 503, 505, 574
principal submatrix . . . . . . . . . . . . . . . . . . . . . 204, 351 Diophantine equation . . . . . . . . . . . 69, 77, 79, 89, 93
term, lt . . . . . . . . 595, 598, 599, 600, 604, 606–608 equation . . . 1, 3, 66, 129, 175, 197, 340, 346, 685
unit, lu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 feedback shift register . . . . . . . . . . . . . . . . . . 341, 342
leaf of a mobile . . . . . . . . . . . . . . . . . . . . . . 306, 307, 308 map . . . . . . . . . . . . . . . . . . . . . 103, 229, 349, 354, 714
leap day . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
least softly ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
absolute remainder Euclidean Algorithm . . . . . . . 66 subspace . . . . . . . . . . . 209, 210, 280, 714, 715, 768
absolute residue . . . . . . . . . . . . . . . . . . . . . . . . . . 72, 550 system of ∼ equations 1, 120, 131, 136, 183, 214,
common multiple, lcm . . . . . . . . . . . . . . . . . . . . . 46, 57 335–356, 460, 485, 552, 621, 638, 664–666,
Lebesgue (Le Besgue), Victor Amédée . . . . 533, 754 715, 716
Lee, King . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2, 337, 736 sparse ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325, 556
Lee, Lin-Nan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509, 755 linearly
van Leeuwen, Jan . . . . . . . . . . . . . . . 750, 754, 764, 765 convergent Newton iteration . . . . . . . . . . . . . . . . . . 291
Legendre (le Gendre), Adrien Marie . . 198, 372, 418, dependent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714, 717
420, 466, 468, 516, 533, 569, 728, 754, 766 independent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714, 715
symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529, 537, 562 recurrent sequence . . 340, 341, 343–347, 349, 353,
Lehmann, Daniel Jean . . . . . . . . . . . . . . . . . . . . 537, 754 355
primality test . . . . . . . . . . . . . . . . . . . . . . . . . . . 537, 538 van Lint, Jacobus Hendricus . . . . . . . . . . . . . . . 215, 755
Lehmer, Derrick Henry 332, 530, 542, 569, 738, 754 Liouville, Joseph . 472, 623, 640, 728, 729, 755, 764,
Leibniz, Gottfried Wilhelm, Freiherr von . 26, 88, 89, 796
96, 197, 219, 294, 512, 513, 531, 622, 640, 726, L IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
754, 756 Lipson, John David . . . . . . . . . . . . . . . . 6, 247, 306, 755
rule . . . . . . . . . . . . . . . . . . . . . 266, 290, 425, 623, 647 Lipton, Richard Jay . . . . . . . . . . . . . . . . . . . . 88, 198, 742
Leighton, Ralph . . . . . . . . . . . . . . . . . . . . . . . . . . . 727, 728 Lisoněk, Petr . . . . . . . . . . . . . . . . . . . . . . . . . 670, 671, 755
Leiserson, Charles Eric . . . . . . . . . . . . . . . . 41, 368, 741 Little, John Brittain . . . . . . . . . . . . . 614, 617, 618, 741
Lemmermeyer, Franz . . . . . . . . . . . . . . . . . . . . . 724, 754 Liu, Zhuojun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376, 727
length LLL algorithm . . . . . . . . see basis reduction algorithm
of a code . . . . . . . . . . . . . . . . . . . . . . . . . . 209, 210–212 Lloyd, Daniel Boone, Jr. . . . . . . . . . . . . . . . . . . 419, 755
of an integer, λ . . . . . . . . . . . . . . . . . . . . . . . 30, 53, 142 Lloyd, Daniel Bruce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Lenstra, Arjen Klaas . . 279, 465, 474, 475, 497, 506, Lloyd, Stuart Phinney . . . . . . . . . . . . . . . . . . . . . 421, 763
531, 534, 542, 569, 741, 742, 751, 754, 755 lm, leading monomial . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Lenstra, Hendrik Willem, Jr. . . . . 419, 421, 441, 474, ln, natural logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768
475, 497, 506, 531–534, 541, 542, 557, 558, 563, Lobachevskiı̆, Nikolaı̆ Ivanovich (Lobaqevski i
565, 568, 569, 724, 735, 736, 754, 755, 760, 764 Nikola i Ivanoviq) . . . . . . . . . . . . . . . . . . . 374
elliptic curve factoring method . . see elliptic curve Lobo, Austin . . . . . . . . . . 353, 404, 405, 407, 747, 751
Leonard, Douglas Alan . . . . . . . . . . . . . . . . . . . 215, 749 local area network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Levelt, Antonius Henricus Maria (Ton) . 6, 698, 735, Locke, John . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208, 726
742, 755 log, binary logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768
784 Index
Metzner, Torsten . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 prime power ∼ . . . 435, 453, 457, 466, 467, 526,
Meyer, Albert Ronald da Silva . . . . . . . 616–618, 756 528, 529
Meyer auf der Heide, Friedhelm . . . . . . . . . . . . . . . . . 744 gcd . 141, 146, 152, 158, 161, 163, 164, 190, 196,
Meyer Eikenberry, Shawna . . . . . . . . . . . . . . . . 533, 757 198, 202, 313, 681
Meyn, Helmut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6–8 big prime ∼ . 162, 166, 168, 169, 171, 193–196,
Micali, Silvio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 206, 411, 460, 526, 529
Mierendorff, Eva . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 bivariate ∼ . . . . . . . . . . . . . . . . . 141, 162, 168, 203
Mignotte, Maurice . . . . . . . . . . . . . . 146, 198, 421, 757 small primes ∼ . . . 168, 169, 170, 171, 194–196,
bound . . . 141, 164, 166, 167, 171, 184, 194, 196, 203, 206, 460, 526, 528
198, 434, 436, 438, 455, 470, 488, 490, 492 inversion 69, 73, 76, 77, 111, 115, 124, 138, 163,
Mihăilescu, Preda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 263, 265, 268
Mikeladze, Sh. E. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 multiplication . . 73, 243, 262, 283, 460, 461, 536
millenium bug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 module . . . . . . . . . . . . . . . . . . . . . . . . . 342, 349, 354, 500
Miller, Gary Lee . . . . . . 532, 533, 535, 736, 755, 757 cyclic ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349, 350
Miller, Raymond Edward . . . . . . . . . . . . . . . . . 744, 751 Z-∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349, 473
Miller, Victor Saul . . . . . . . . . . . . . . . . . . . . . . . . 580, 757 Moenck, Robert Thomas . . . 247, 286, 306, 332, 421,
minimal 671, 673, 737, 757
distance of a code . . . . . . . . . . . . 210, 211–213, 215 de Moivre, Abraham . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Euclidean function . . . . . . . . . . . . . . . . . . . . . . . . 62, 63 Möller, Hans Michael . . . . . . . . . . . . . . . . 199, 618, 757
Gröbner basis . . . . . . . . . . . . . . . . . . . . . 611, 620, 621 monic
polynomial Euclidean Algorithm . 57, 62, 184, 186, 187, 192,
196, 197, 199, 630, 631
of a matrix . . . . . . . . . . . . 343, 346, 355, 404, 716
polynomial . . . . . . . 32, 35, 40, 56, 59, 60, 708, 710
of a sequence 343, 344–351, 354–356, 404, 407
Monien, Burkhard . . . . . . . . . . . . . . . . . . . . . . . . 744, 756
of an algebraic element . . . . 152, 175, 203, 210,
Monier, Louis Marcel Gino . . . . . . . . . . 532, 533, 757
211, 343, 354, 415–417, 663, 710, 711
monomial . . 591, 596, 597, 601, 602, 606, 611, 620,
Minkowski, Hermann . . . . . . . . . . . 473, 496, 586, 757
709
Mishra, Bhubaneswar (Bud) . . . . . . . . . . . . . . . 619, 745
ideal . . . . . . . . . . . . . . . . . . . . . . . . . . 601, 602, 603, 620
Mitchell, Joan Laverne . . . . . . . . . . . . . . . . . . . . 368, 760
leading ∼ , lm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Mittag-Leffler, Gustav Magnus (Gösta) . . . . . . . . . . 726 order 595, 596, 597–599, 603–605, 610, 620, 621
mixed-radix representation . . . . . . . . . . . . . . . . 132, 134 Montaigne, Michel Eysquem, Seigneur de . 699, 729
mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306, 307 Monte Carlo
stochastic ∼ . . . . . . . . . . . . . . . . . . . . . . . . 306, 307, 308 algorithm . . . . . . . . . . . . . . . . . . . . . 161, 198, 428, 724
Möbius, August Ferdinand Turing machine
function, µ . . . . . . . . . . . . . . . . . . . . . . . . 410, 429, 508 one-sided ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
inversion . . . . . . . . . . . . . . . . . . . . . . . . . . 410, 413, 429 two-sided ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
mod, congruent modulo . . . . . . . . . . . . . . . . . . . . . 69, 706 Montgomery, Peter Lawrence . . . 280, 287, 288, 308,
mod, residue class . . . . . . . . . . . . . . . . . 71, 72, 398, 706 353, 542, 569, 741, 751, 757, 758
modular Moore, Eliakim Hastings . . . . . . . . . . . . . . . . . . . . 88, 758
algorithm . . 3, 19, 97, 97–139, 152, 161, 183, 192, Mora, Ferdinando Teo 618, 619, 739, 744, 746, 747,
339, 408, 433, 444, 505, 517, 523, 525, 526 757
big prime ∼ . . 97, 100, 152, 161, 289, 444, 460, Morain, François . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
527 Moreno-Socías, Guillermo . . . . . . . . . . . . . . . . . . . . . . . . 8
prime power ∼ 97, 99, 100, 198, 271, 433, 460, Morenz, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
470, 528, 536 De Morgan, Augustus . . . . . 44, 68, 96, 622, 726, 729
small primes ∼ 97, 98–100, 112, 137, 247, 310, Morgenstern, Jacques . . . . . . . . . . . . . . . . . . . . . 619, 744
444, 460, 467, 470, 471, 528, 536 Moritz, Robert Edouard . . . . . . . . . . . . . . . . . . . 729, 758
arithmetic . . . . . . . . . 69, 70, 71, 132, 282, 289, 709 Morrison, Michael Allan . . . . . . . . 541, 542, 568, 758
composition . . . 338, 339, 354, 356, 407, 408, 427 Moses, Joel . . . . . . . . . . . . . . . . . . . . . . . 20, 198, 466, 758
fast ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . 338, 339, 405 Motwani, Rajeev . . . . . . . . . . . . . . . . . . . . . . . 88, 198, 758
determinant . . . . . . . . . . . . . . . . . . 109, 113, 132, 525 Moura, Arnaldo Vieira . . . . . . . . . . . . . . . . . . . . . . . . . . 759
big prime ∼ . . . . . . . . . . . 110, 113, 168, 460, 526 Mourrain, Bernard . . . . . . . . . . . . . . . . . . . . . . . . 698, 743
small primes ∼ . . . 112, 113, 136, 168, 189, 460, µ, Möbius function . . . . . . . . . . . . . . . . . . 410, 429, 508
526, 528, 536, 537 Mulders, Thom . . . . . . . . . . . . . . . . . 199, 501, 640, 758
EEA Mullen, Gary Lee . . . . . . . . . . . . . . . . . . . . 745, 758, 766
big prime ∼ . . . . . . . . . . . . . . . . 189, 190, 195, 206 Müller, Daniel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
bivariate ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Müller, Dirk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
small primes ∼ . . . 188, 189, 190, 195, 332, 460, Müller, Eva-Maria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
526, 528, 537 Müller, Olaf . . . . . . . . . . . . . . . . . . . . . . . . . 6–8, 461, 737
exponentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Mullin, Ronald Cleveland . . . . . . . . . . . . . . . . . . . 88, 758
factorization . . . . . . . . . . . . . . . . . . 436, 453, 458, 489 multidegree of a polynomial, mdeg . . . . . . . . 597, 598
big prime ∼ . 433, 435, 436, 467, 526, 528, 529 multifactor Hensel lifting . . . . . . . . . . . . . . . . . . . . . . . 450
786 Index
multiple polynomial quadratic sieve . . . . . . . . . . . . . 567 iteration 3, 90, 100, 101, 218, 219, 221, 259, 268,
multiplication 257–292, 295–310, 444, 448, 450, 451, 581,
by scalars . . . . . . . . . . . . . . . 346, 348, 351, 713, 714 623
Cantor ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . 281, 282, 287 linearly convergent ∼ . . . . . . . . . . . . . . . . . . . . . . . 291
FFT ∼ . . . . . . . . . . . . . . . . see Fast Fourier Transform multivariate ∼ . . . . . . . . . . . . . . . . . . . . . . . . 449, 450
matrix ∼ . . . . . . . . 43, 335, 337–339, 411, 715, 720 numerical ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . 262, 271
exponent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 p-adic ∼ . . . . . . . . . . . . . . . 268, 271, 272, 290, 292
modular ∼ . . . . . . 73, 243, 262, 283, 460, 461, 536 Nguyen, Phong Quang . . . . . . . . . . . . . . . 509, 580, 758
of integers . 37, 227, 243, 247, 283, 284, 335, 337, Nicely, Thomas Ray . . . . . . . . . . . . . . . . . . . . . . . . 83, 758
460 Niederreiter, Harald Günther . . . . 407, 420, 421, 428,
fast ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221–254 509, 711, 745, 747, 755, 758, 759
of polynomials . . . 35, 36, 39, 221–254, 280–282, Niesi, Gianfranco . . . . . . . . . . . . . . . . . . . . . . . . . 619, 747
284, 285, 319, 323, 335, 460 Nilsson, Bengt Ola Peter . . . . . . . . . . . . . . . . . . . . . . . . . . 8
classical ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Nöcker, Michael . . . . . . . 6, 7, 88, 461, 580, 737, 746
fast ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221–254 Noether, Amalie Emmy . . . . . . . . . . . . . . 586, 604, 750
Schönhage and Strassen ∼ . . . . . . . . see Schönhage Noetherian ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
time, M . . . . . . . . . . . . . 244, 245, 247, 254, 257, 381 non-Archimedean valuation . . . . . . . . . . . . . . . . . . . . . 274
multiplicative group . . . . 93, 105, 133, 211, 212, 250, non-Euclidean geometry . . . . . . . . . . . . . . . 25, 373, 374
280, 384, 535, 578, 580, 703, 704, 713 nonresidue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
multiplicity . 200, 389–392, 394, 419, 440, 460, 470, nonscalar model of computation . . . . . . . . . . . 286, 324
552, 560, 630, 656, 692, 711 nonsingular
multipoint evaluation . . . . . . . . . . . . . . . . . see evaluation curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559, 568, 571
multiprecision integer . . . . 29, 30–32, 34, 37, 41, 82, matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . see matrix
283, 286 norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419, 473, 707, 717
multivariate . . . . . . . . . . . . . . . . . . . . . . . see also bivariate Euclidean ∼ , || · ||2 . . . 12, 157, 164, 473, 474, 480,
division with remainder . . 595, 598, 599, 600, 604, 487, 497, 717, 768
605 max-∼ , || · ||∞ . . . . . . . . . . . . . . . . see maximum norm
factorization . . . . . . . . . . . . . . . . . . . . . . . 493, 497, 501 of a lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473, 474
gcd . . . . . . . . . . . . . . . . . 190, 198, 202, 466, 496, 501 one-∼ , || · ||1 . . . . . . . . . . . . . . . . . . . . . . . 165, 717, 768
Newton iteration . . . . . . . . . . . . . . . . . . . . . . . . 449, 450 q-∼ , || · ||q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716, 717
polynomial . 3, 4, 21, 60, 101, 191, 198, 199, 254, normal
378, 493, 586, 591–621, 709, 768 basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76, 580
quotient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 degree sequence . . . . . . . . . . . . . see degree sequence
remainder . . . . . . . . . . . . . . . 599, 600, 601, 608, 610 field extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
M U M ATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 form . . . . . . . . . 56, 57, 59, 60, 63, 64, 150, 191, 200
Mumford, David Bryant . . . . . . . . . . . . . . . . . . . . . . . . . 618 Hermite ∼ . . . . . . . . . . . . . . . . . . . . 89, 352, 498, 499
Munro, James Ian . . . . . . . . . . . . . . . . . . . . . . . . . 306, 737 matrix ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
M U PAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 20 Smith ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
musical normalized . . . . . . . . . . . . . . . . 57, 59, 63, 147, 148, 149
interval . . . . . . . . . . . . . . . . . . . . . . . 84, 85, 86, 88, 507 polynomial . . . . . 57, 144, 150, 151, 152, 163, 167
scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 69, 84 Novalis (Friedrich Leopold Freiherr von Hardenberg)
theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84, 85 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68, 726, 729, 734
Musil, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256, 727 Novocin, Andrew . . . . . . . . . . . . . . . . . . . . . . . . . 497, 748
Musser, David Rea . . . . . . . . . . . . . . . . . . . 465, 751, 758 NP . . . 215, 474, 496, 503, 504, 509, 576, 579, 616,
Myerson, Gerald . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 722, 723
co-∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722, 723
N, set of nonnegative integers . . . . . . . . . . . . . . . . . . . 768 N TL . . . . . . . . . 3, 8, 20, 193–196, 279, 283, 284–286,
NAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 461–466, 497
Najafi, Seyed Hesameddin . . . . . . . . . . . . . . . . . . . . . . . . 7 Nullstellensatz
Najfeld, Igor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698, 748 Hilbert ∼ . . . . . . 586, 595, 617, 618, 621, 736, 761
Napoléon I. Bonaparte . . . . . . . . . . . . 10, 502, 725, 728 proof system . . . . . . . . . . . . . . . . . . . . . . 679, 697, 698
Nash, Stephen Gregory . . . . . . . . . . . . . . . . . . . . . . . . . . 741 number
Näslund, Mats . . . . . . . . . . . . . . . . . . . . . . . 580, 748, 758 field
Newton, Humphrey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 algebraic ∼ . . . . . . . . . . . . . . . . . 279, 378, 473, 533
Newton, Sir Isaac . . . 0, 3, 24, 28, 61, 197, 203, 218, sieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541, 542, 569
219, 256, 286, 290, 358, 372, 374, 512, 622, 641, theory . . . . . . . . . . . . . . . . . . . . . . . . 529, 530, 533, 724
725–727, 745, 758 analytic ∼ . . . . . . . . . . . . . 508, 523, 532, 533, 652
expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 computational ∼ . . . . . . . . . . . . 3, 4, 517–571, 586
formula . . . . . . . . . . . . . . . . . . . . . . . . . . . 267, 290, 291 fundamental theorem of ∼ . . . . . . . . . . . . 377, 518
interpolation . . . . . . . . . . . . . . . . . . 103, 134, 135, 671 numerical
inversion . . . . . . 259, 261, 262, 268–270, 275, 282, analysis . . . . . . 1, 32, 118, 119, 121, 132, 259, 621
286–289 Newton iteration . . . . . . . . . . . . . . . . . . . . . . . . 262, 271
Index 787
part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625, 642 Riemann, Georg Friedrich Bernhard . . 373, 533, 761
root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456, 466 Hypothesis . . . . . . . . . . . . . . 508, 533, 748, 749, 757
Razborov, Aleksandr Aleksandrovich (Razborov Extended ∼ , (ERH) . . . . see Extended Riemann
Aleksandr Aleksandroviq) . . . 697, 739, zeta function, ζ . 62, 221, 508, 533, 652, 684, 756,
761 759
reachability problem . . . . . . . . . . . . . . . . . 680, 681, 697 right ideal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
Recio Muñiz, Tomás Jesús . . . . . . . . . . . . . . 6, 619, 749 rigid conformation of cyclohexane . . 12, 15, 16, 698
Recorde, Robert . . . . . . . 44, 502, 726, 728, 729, 796 ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32, 705, 711
rectangular matrix multiplication . . . . . . . . . . . . . . . . 353 characteristic of a ∼ . 394, 395, 397, 415, 460, 558,
recurrence . . . . . . . . . . 1, 349, 353, 354, 653, 669, 684 561, 581, 623, 626, 630, 658, 665, 710, 712
recursion order . . . . . . . . . . . . . 343, 344, 345, 354, 355 commutative ∼ . . . . . . . . . . . 705, 706, 709, 711, 713
recursively enumerable . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 factorial ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
R EDUCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 homomorphism . . . . . 104, 107, 133, 295, 302, 705,
reduced 706, 709
basis 286, 478, 479, 480, 482, 488, 491, 497, 498, canonical ∼ . . . . . . . . . . . . . 72, 104, 110, 706, 709
504, 506, 508 invariant ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 isomorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
Gröbner basis . . . . . . . . . . . . . . . . . see Gröbner basis Noetherian ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
polynomial remainder sequence . . . . . . . . . . . . . . 199 of algebraic integers . . . . . . . . . . . . . . . . . . . . 707, 708
reducible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 of constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
refutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678, 679 of polynomials . . . . . . . . . . . . . . . . . . . . . . . 2, 708, 768
Reichel, Horst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756 operation . . . . . . . . . . . . . . . . see arithmetic operation
Reid, Constance . . . . . . . . . . . . . . . . . . . . . . . . . . 587, 761 Rink, Friedrich Theodor . . . . . . . . . . . . . . . . . . . . . . . . . 727
Reif, John Henry . . . . . . . . . . . . . . . . . . . . . . . . . . 619, 736 Rioboo, Renaud . . . . . . . 627, 630, 631, 640, 754, 758
Reischert, Daniel . . . . . . . . . . . . . . . . . . . . . . . . . see Lauer Risch, Robert Henry . . . . . . . . . . . . . . . . . 640, 641, 761
Reisig, Wolfgang . . . . . . . . . . . . . . . . . . . . . . . . . 697, 761 differential equation . . . . . . . . . . 641, 738, 742, 750
Reitwiesner, George Walter . . . . . . . . . . . . . . . . . 82, 761 rising factorial . . . . . . . . . . . . . . . . . . 647, 670, 673, 768
remainder, rem 38, 40, 41, 46, 47, 261, 323, 600, 707 Ritscher, Stephan . . . . . . . . . . . . . . . . . . . . . . . . . 617, 756
division with ∼ . . . . . . 2, 26, 37, 38, 39, 41, 45, 51, Ritt, Joseph Fels . . . . . . . . . . . . . . . . 619, 640, 745, 762
59–62, 100, 131, 257, 261, 262, 282, 283, 314, Rivest, Ronald Linn 16, 41, 368, 509, 576, 740, 741,
407, 445 762
in the Euclidean Algorithm 48, 52, 57, 58, 59, 61, Robbiano, Lorenzo . . . . . . . . . . . . . . 617, 619, 742, 747
197, 199, 313, 324, 331, 630, 631 robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591, 592
multivariate ∼ . . . . . . . . . . . . 599, 600, 601, 608, 610 kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615, 698
Remmers, Harry . . . . . . . . . . . . . . . . . . . . . . . . . . 419, 755 Rodger, Christopher Andrew . . . . . . . . . . . . . . 215, 749
Renegar, James . . . . . . . . . . . . . . . . . . . . . . . . . . . 619, 761 Rogers, Leonard James, -Ramanujan identity . . . 671,
repeated squaring . . 17, 75, 76, 77, 88, 93, 264, 291, 685, 743, 759
381, 385, 389, 392, 403, 405, 407, 424, 519, 521, Rolletschek, Heinrich Franz . . . . . . . . . . . . . . . 132, 751
537 The Rolling Stones . . . . . . . . . . . . . . . . . . . . . . . . 516, 728
representative Roman, Steven . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669, 762
canonical ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 Rónyai, Lajos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421, 762
system of ∼ s . . . . . . . . . . . . . . . . . . . . . . . . 72, 706, 709 root
symmetric ∼ . . . . . . . . . . . . . . . . . . . . . . 72, 110, 436 finding . . 132, 219, 257, 273, 286, 392, 456, 457,
repunit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530, 534, 569 460, 466, 525, 526
Research Institute for Symbolic Computation (RISC) over finite fields . . . . . . . . . . . . 377, 392, 418, 428
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 integral ∼ . . . . . . . . . . . . . . . . . . . . . 392, 393, 635, 641
residue of an integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271, 460
class, mod . . . . . . . . . . . . . . . . . . . . . . . 71, 72, 398, 706 of unity . . . . 19, 227, 221–254, 262, 373, 384, 412
class ring . . 71, 72, 75, 92, 93, 163, 262, 326, 327, primitive ∼ . . 211, 209–215, 227, 221–254, 296,
398, 706, 768 333, 340, 352, 362, 412, 412–417, 536
resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678 rational ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456, 466
resultant, res . 15, 155, 157, 141–207, 327, 331–333, Rosen, Frederic . . . . . . . . . . . . . . . . . . . . . . . . . . . 726, 762
434, 435, 453, 615, 619, 628, 630, 635, 641, 643, Rosenkranz, Karl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
662, 663, 694 Rosser, John Barkley . . . . . . . 527, 532, 536, 750, 762
reversal, rev . . . . . . . . . . . 203, 258, 262, 287, 343, 424 Rota, Gian-Carlo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Reynaud, Antoine André Louis . . . . . . . . . . . . . . 61, 761 Rothstein, Michael . . . . . . . . . . . . . . . . . . . 640, 641, 762
Rhind Papyrus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 and Trager integration . . . . . . . . . . . . . . . . . . 627, 640
Richardson, Daniel . . . . . . . . . . . . . . . . . . . . . . . . 640, 761 rounding error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Richmond, Lawrence Bruce . . . . . . . . . . 419, 421, 759 routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 198
te Riele, Herman(us) Johannes Joseph . . . . . 508, 533, Rowland, John Hawley . . . . . . . . . . . . . . . . . . . . 199, 762
542, 751, 756, 759 Roy, Marie-Françoise . 184, 199, 332, 619, 749, 755
Index 791
Strehl, Volker . . . . . . . . . . . . . . 6, 7, 670, 671, 755, 760 Taniyama, Yutaka, -Weil conjecture . . . . . . . . . . . . . 514
string matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Tannery, Paul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729, 744
strong Tarry, Gaston . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531, 765
liar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523, 532 Tarski, Alfred (Tajtelbaum) . . . . . . . . . . 619, 748, 765
pseudoprimality test . . . . . 520, 521, 523, 532, 536 taxi-cab number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
witness . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523, 532, 534 Taylor, Brook . . . . . . . . . . . . . . . . . . . . . . . . 286, 746, 765
Sturm, Jacques Charles François . . 94, 332, 748, 764 coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 752, 765 expansion 100, 114, 121, 113–131, 259, 264–278,
theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 198 286, 289, 290, 292, 353, 623, 671
Sturmfels, Bernd . . . . . . . . . . . . . . . . . . . . . . . . . . 697, 743 generalized ∼ . . . . . . . . . . . . . . . . . . . . . . . . 264, 289
subdeterminant . . . . . . . . . . . . . . . . . . . . . . 688, 689, 694 polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
subfield . . . . . . . . . . . . . . . . . . . . . . 94, 641, 710, 711, 712 series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
subgroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373, 704, 768 Taylor, Richard . . . . . . . . . . . . . . . . . . . . . . . . . . . 514, 765
submodule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 Teichmüller, Oswald . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
subproduct tree . . . . . . . . . . . . . . . . . 296, 297, 298, 302 telescoping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
subresultant . . . . . 3, 33, 45, 141, 143, 152, 164, 181, Tenenbaum, Gérald . . . . . . . . . . . . . . . . . . . . . . . 536, 765
178–207, 313, 327–332, 616, 630, 681 te Riele, Herman(us) Johannes Joseph . . . . . see Riele
fundamental theorem on ∼ s . . . . . . . 327, 329, 332 term
polynomial remainder sequence . . . . . . . . . . . . . . 199 ratio . . . . . . . . . . . 659, 660, 663, 664, 667, 674, 683
subring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641, 706 rewriting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591, 618
subset sum Thatcher, James Winthrop . . . . . . . . . . . . . . . . . 744, 751
cryptosystem . . . . . . . . . see knapsack cryptosystem Theaitetus (Θεαίτητος) . . . . . . . . . . . . . . . . . . . . . . . . . . 24
problem . . . . . . . . . . . . . . . . . . . . . . 503, 504, 509, 576 Theiwes, David . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
subspace theorem in a proof system . . . . . . . . . . . . . . . . . . . . . . . 677
Krylov ∼ . . . . . . . . . . . . . . . . . . . . . 341, 346, 347, 355 Theoretical Computer Science . . . . . . . . . . . . . . . . . . . 21
linear ∼ . . . . . . . . . . . . . 209, 210, 280, 714, 715, 768 theory of a proof system . . . . . . . . . . . . . . . . . . . . . . . . 677
substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623 Thijsse, Gérard Philip Antoine . . . . . . . . . . . . . . . . . . 727
Sudan, Madhu . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215, 735 Thomé, Emmanuel . . . . . . . . . . . . . . . . . . . . . . . . 542, 751
summation . . . . . . . . . . . . . . . . . . . . 3, 101, 645–675, 681 three primes FFT . . . . . . 243, 246, 247, 283, 284, 286
hypergeometric ∼ 3, 641, 660, 665, 658–669, 671, 3-adic FFT . . . . . . . . . . . . . . . . . . . . . . 242, 247, 252, 253
674, 683, 685 Thue, Axel . . . . . . . . . . . . . . . . . . . . . . 132, 750, 765, 767
indefinite ∼ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646, 683 Tijdeman, Robert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760
of polynomials . . . . . . . . . . . . . 3, 645, 649, 650, 658 van Tilborg, Henricus Carolus Adrianus (Henk) 215,
Sun, Xiaoguang . . . . . . . . . . . . . . . . . . . . . . . . . . . 131, 753 737
Sun-Tsŭ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Timofeev, Andrey . . . . . . . . . . . . . . . . . . . . . . . . . 542, 751
supercomputer . . . . . . . . . . . . . . . . . . . . . . . 1, 18, 83, 575 Tiwari, Prasoon . . . . . . . . . . . . . . . . . . . . . . . . . . . 498, 737
superincreasing sequence . . . . . . . . . . . . . . . . . . . . . . . 504 Toeplitz, Otto, matrix . . . . . . 202, 332, 335, 353, 738
superlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 tonal key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85, 86
surjective . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704, 713, 714 Toom, Andrei Leonovich (Toom Andre i
Svoboda, Antonín . . . . . . . . . . . . . . . . . . . . . . . . . 132, 764 Leonoviq) . . . . . . . . . . . . . . . . . . . . . . . . . . 247, 765
Swan, Richard Gordon . . . . . . . . . . . . . . . 207, 332, 764 total
Swift, Jonathan . . . . . . . . . . . . . . . . . . . . . . . . . . . 702, 729 degree . . . . 157, 172, 176, 493, 597, 616, 689, 709
Swinnerton-Dyer, Sir Henry Peter Francis . . . . . . . 465 order . . . . . . . . . . . . . . . . . . . . 595, 596, 602, 603, 620
polynomial . . . . . . . . . 434, 441, 442, 443, 465, 467 Trabb Pardo, Luis Isidoro . . . . . . . . . . . . . . . . . 567, 752
Sylvester, James Joseph 96, 197, 199, 294, 334, 726, trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382, 419
727, 736, 755, 765 traditional
matrix, Syl . . . . 155, 158, 159, 181, 197, 199, 201, Euclidean Algorithm . . 47, 51, 54, 57, 79, 94, 95,
204, 205, 335, 340, 435, 470 99, 144, 184, 185, 187, 197, 199, 329
symbolic-numeric computation . . . . . . . . . . . . . . . . . . . 41 Extended Euclidean Algorithm (EEA) . 48, 49, 51,
symmetric 52, 54, 57, 59, 60, 64, 65, 80, 94, 111, 125,
cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . 16, 575, 578 184, 186, 189, 205, 313, 317, 325, 710
group . . . . . . . . . . . . . . . . . . . . . . . . . 136, 442, 465, 705 Trager, Barry Marshall . . . . . 466, 496, 498, 627, 630,
system of representatives . . . . . . . . . . . . . . . 72, 706, 709 631, 640, 751, 758, 765
symmetric ∼ . . . . . . . . . . . . . . . . . . . . . . . . . 72, 110, 436 transcendental . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 90, 710
Szabó, Nicholas Sigismund . . . . . . . . . . . . . . . 132, 765 transmission
channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 209
T, transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
tableau . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678 rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Takahashi, Daisuke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 transposition principle . . . . . . . . . . . . . . . . . . . . 340, 353
Tamura, Yoshiaki . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 trapdoor function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Tanaka, Richard Isamu . . . . . . . . . . . . . . . . . . . . 132, 765 Traub, Joseph Frederick . . . . 197, 199, 332, 738, 761
tangent function . . . . . . . . . . . . . . . . . . . . . . . . . . . 123, 124 Traverso, Carlo . . . . . . . . . . . . . . . . . 619, 734, 747, 765
794 Index