Prime Numbers
Prime Numbers Prime Numbers
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
- Page 402 and 403: 8.1 Cryptography 393 just to genera
- Page 404 and 405: 8.1 Cryptography 395 where in the l
- Page 406 and 407: 8.2 Random-number generation 397 ar
- Page 408 and 409: 8.2 Random-number generation 399 Al
- Page 410 and 411: 8.2 Random-number generation 401 }
- Page 412 and 413: 8.2 Random-number generation 403 is
- Page 414 and 415: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 416 and 417: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 418 and 419: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 420 and 421: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 422 and 423: 8.3 Quasi-Monte Carlo (qMC) methods
- Page 424 and 425: 8.4 Diophantine analysis 415 [Tezuk
- Page 426 and 427: 8.4 Diophantine analysis 417 9262 3
- Page 428 and 429: 8.5 Quantum computation 419 We spea
- Page 430 and 431: 8.5 Quantum computation 421 three H
- Page 432 and 433: 8.5 Quantum computation 423 for a n
- Page 434 and 435: 8.6 Curious, anecdotal, and interdi
- Page 436 and 437: 8.6 Curious, anecdotal, and interdi
- Page 438 and 439: 8.6 Curious, anecdotal, and interdi
- Page 440 and 441: 8.7 Exercises 431 universal Golden
- Page 442 and 443: 8.7 Exercises 433 standards insist
- Page 444 and 445: 8.7 Exercises 435 of positive compo
- Page 446 and 447: 8.8 Research problems 437 element o
- Page 448 and 449: 8.8 Research problems 439 the Leveq
- Page 450 and 451: 8.8 Research problems 441 for every
- Page 454 and 455: 9.1 Tour of “grammar-school” me
- Page 456 and 457: 9.2 Enhancements to modular arithme
- Page 458 and 459: 9.2 Enhancements to modular arithme
- Page 460 and 461: 9.2 Enhancements to modular arithme
- Page 462 and 463: 9.2 Enhancements to modular arithme
- Page 464 and 465: 9.2 Enhancements to modular arithme
- Page 466 and 467: 9.3 Exponentiation 457 Algorithm 9.
- Page 468 and 469: 9.3 Exponentiation 459 But there is
- Page 470 and 471: 9.3 Exponentiation 461 the benefit
- Page 472 and 473: 9.4 Enhancements for gcd and invers
- Page 474 and 475: 9.4 Enhancements for gcd and invers
- Page 476 and 477: 9.4 Enhancements for gcd and invers
- Page 478 and 479: 9.4 Enhancements for gcd and invers
- Page 480 and 481: 9.4 Enhancements for gcd and invers
- Page 482 and 483: 9.5 Large-integer multiplication 47
- Page 484 and 485: 9.5 Large-integer multiplication 47
- Page 486 and 487: 9.5 Large-integer multiplication 47
- Page 488 and 489: 9.5 Large-integer multiplication 47
- Page 490 and 491: 9.5 Large-integer multiplication 48
- Page 492 and 493: 9.5 Large-integer multiplication 48
- Page 494 and 495: 9.5 Large-integer multiplication 48
- Page 496 and 497: 9.5 Large-integer multiplication 48
- Page 498 and 499: 9.5 Large-integer multiplication 48
- Page 500 and 501: 9.5 Large-integer multiplication 49
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