Prime Numbers

Prime Numbers Prime Numbers

thales.doa.fmph.uniba.sk
from thales.doa.fmph.uniba.sk More from this publisher
10.12.2012 Views

Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC In this chapter we explore the galaxy of “fast” algorithms that admit of applications in prime number and factorization computations. In modern times, it is of paramount importance to be able to manipulate multipleprecision integers, meaning integers that in practice, on prevailing machinery, have to be broken up into pieces, with machine operations to involve those pieces, with a view to eventual reassembly of desired results. Although multiple-precision addition and subtraction of integers is quite common in numerical studies, we assume that notions of these very simple fundamental operations are understood, and start with multiplication, which is perhaps the simplest arithmetic algorithm whose classical form admits of genuine enhancements. 9.1 Tour of “grammar-school” methods 9.1.1 Multiplication One of the most common technical aspects of our culture is the classical, or shall we say “grammar-school,” method of long multiplication. Though we shall eventually concentrate on fast, modern methods of remarkable efficiency, the grammar-school multiply remains important, especially when the relevant integers are not too large, and itself allows some speed enhancements. In the typical manifestation of the algorithm, one simply writes out, one below the other, the two integers to be multiplied, then constructs a parallelogram of digitwise products. Actually, the parallelogram is a rhombus, and to complete the multiply we need only add up the columns of the rhombus, with carry. If each of x, y to be multiplied has D digits in some given base B (also called the “radix”), then the total number of operations required to calculate xy is O(D 2 ), because that is how many entries appear in the rhombus. Here, an “operation” is either a multiply or an add of two numbers each of size B. We shall refer to such a fundamental, digitwise, multiply as a “size-B multiply.” A formal exposition of grammar-school multiply is simple but illuminating, especially in view of later enhancements. We start with two definitions: Definition 9.1.1. The base-B representation of a nonnegative integer x is the shortest sequence of integer digits (xi) such that each digit satisfies

444 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC 0 ≤ xi

Chapter 9<br />

FAST ALGORITHMS FOR LARGE-INTEGER<br />

ARITHMETIC<br />

In this chapter we explore the galaxy of “fast” algorithms that admit of<br />

applications in prime number and factorization computations. In modern<br />

times, it is of paramount importance to be able to manipulate multipleprecision<br />

integers, meaning integers that in practice, on prevailing machinery,<br />

have to be broken up into pieces, with machine operations to involve those<br />

pieces, with a view to eventual reassembly of desired results. Although<br />

multiple-precision addition and subtraction of integers is quite common in<br />

numerical studies, we assume that notions of these very simple fundamental<br />

operations are understood, and start with multiplication, which is perhaps<br />

the simplest arithmetic algorithm whose classical form admits of genuine<br />

enhancements.<br />

9.1 Tour of “grammar-school” methods<br />

9.1.1 Multiplication<br />

One of the most common technical aspects of our culture is the classical,<br />

or shall we say “grammar-school,” method of long multiplication. Though we<br />

shall eventually concentrate on fast, modern methods of remarkable efficiency,<br />

the grammar-school multiply remains important, especially when the relevant<br />

integers are not too large, and itself allows some speed enhancements. In the<br />

typical manifestation of the algorithm, one simply writes out, one below the<br />

other, the two integers to be multiplied, then constructs a parallelogram of<br />

digitwise products. Actually, the parallelogram is a rhombus, and to complete<br />

the multiply we need only add up the columns of the rhombus, with carry. If<br />

each of x, y to be multiplied has D digits in some given base B (also called<br />

the “radix”), then the total number of operations required to calculate xy is<br />

O(D 2 ), because that is how many entries appear in the rhombus. Here, an<br />

“operation” is either a multiply or an add of two numbers each of size B. We<br />

shall refer to such a fundamental, digitwise, multiply as a “size-B multiply.”<br />

A formal exposition of grammar-school multiply is simple but illuminating,<br />

especially in view of later enhancements. We start with two definitions:<br />

Definition 9.1.1. The base-B representation of a nonnegative integer x<br />

is the shortest sequence of integer digits (xi) such that each digit satisfies

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!