# TAOCP Volume 2: Seminumerical Algorithms

> Knuth's The Art of Computer Programming, Volume 2 (third edition, 1997, ISBN 0-201-89684-2), as studied on the cracked.guide path in weeks 64 to 89: 30 reading guides, 918 exercises, about 198 hours.

Volume 2 is about numbers as computers see them. Chapter 3 is random numbers: how to generate them, how to test them, and how to turn them into shuffles and samples. Chapter 4 is arithmetic: floating point, bignums, fast multiplication, gcd, factoring and polynomials. Some sections are deep number theory; the guides tell you where to dig in and where to skim.

## Every section, week by week

| Section | Week | Exercises | Picked | Hours |
| --- | --- | --- | --- | --- |
| [3.1 Introduction](https://cracked.guide/guide/knuth-w048-0) | 64 | 23 (10 to M48) | 8 | 3 |
| [3.2.1 The Linear Congruential Method](https://cracked.guide/guide/knuth-w048-1) | 65 | 49 (10 to 40) | 8 | 8 |
| [3.2.2 Other Methods](https://cracked.guide/guide/knuth-w049-0) | 66 | 37 (00 to M40) | 8 | 7 |
| [3.3.1 General Test Procedures](https://cracked.guide/guide/knuth-w050-0) | 67 | 25 (00 to HM48) | 8 | 7 |
| [3.3.2 Empirical Tests](https://cracked.guide/guide/knuth-w051-0) | 68 | 35 (00 to M46) | 8 | 8 |
| [3.3.3 Theoretical Tests](https://cracked.guide/guide/knuth-w052-0) | 69 | 28 (M10 to M40) | 8 | 5 |
| [3.3.4 The Spectral Test](https://cracked.guide/guide/knuth-w053-0) | 70 | 32 (M10 to HM47) | 8 | 9 |
| [3.4.1 Numerical Distributions](https://cracked.guide/guide/knuth-w054-0) | 71 | 33 (10 to HM40) | 8 | 9 |
| [3.4.2 Random Sampling and Shuffling](https://cracked.guide/guide/knuth-w055-0) | 72 | 17 (M12 to M39) | 8 | 6 |
| [3.5 What Is a Random Sequence?](https://cracked.guide/guide/knuth-w056-0) | 73 | 44 (10 to HM50) | 8 | 6 |
| [3.6 Summary](https://cracked.guide/guide/knuth-w056-1) | 73 | 15 (15 to 46) | 7 | 2 |
| [4.1 Positional Number Systems](https://cracked.guide/guide/knuth-w057-0) | 74 | 34 (00 to M40) | 8 | 5 |
| [4.2.1 Single-Precision Calculations](https://cracked.guide/guide/knuth-w058-0) | 75 | 19 (10 to 40) | 8 | 8 |
| [4.2.2 Accuracy of Floating Point Arithmetic](https://cracked.guide/guide/knuth-w059-0) | 76 | 31 (10 to M40) | 8 | 8 |
| [4.2.3 Double-Precision Calculations](https://cracked.guide/guide/knuth-w060-0) | 77 | 9 (16 to M42) | 5 | 4 |
| [4.2.4 Distribution of Floating Point Numbers](https://cracked.guide/guide/knuth-w060-1) | 77 | 20 (13 to 42) | 7 | 4 |
| [4.3.1 The Classical Algorithms](https://cracked.guide/guide/knuth-w061-0) | 78 | 43 (10 to 42) | 8 | 10 |
| [4.3.2 Modular Arithmetic](https://cracked.guide/guide/knuth-w062-0) | 79 | 14 (M10 to M30) | 8 | 6 |
| [4.3.3 How Fast Can We Multiply?](https://cracked.guide/guide/knuth-w063-0) | 80 | 19 (M15 to M49) | 8 | 9 |
| [4.4 Radix Conversion](https://cracked.guide/guide/knuth-w064-0) | 81 | 19 (16 to M47) | 8 | 6 |
| [4.5.1 Fractions](https://cracked.guide/guide/knuth-w065-0) | 82 | 16 (10 to 42) | 6 | 3 |
| [4.5.2 The Greatest Common Divisor](https://cracked.guide/guide/knuth-w065-1) | 82 | 42 (18 to HM49) | 8 | 7 |
| [4.5.3 Analysis of Euclid's Algorithm](https://cracked.guide/guide/knuth-w066-0) | 83 | 51 (20 to HM46) | 8 | 8 |
| [4.5.4 Factoring into Primes](https://cracked.guide/guide/knuth-w067-0) | 84 | 47 (10 to M50) | 8 | 10 |
| [4.6.1 Division of Polynomials](https://cracked.guide/guide/knuth-w068-0) | 85 | 31 (10 to M40) | 8 | 7 |
| [4.6.2 Factorization of Polynomials](https://cracked.guide/guide/knuth-w069-0) | 86 | 41 (20 to M47) | 8 | 7 |
| [4.6.3 Evaluation of Powers](https://cracked.guide/guide/knuth-w070-0) | 87 | 42 (10 to M50) | 8 | 7 |
| [4.6.4 Evaluation of Polynomials](https://cracked.guide/guide/knuth-w071-0) | 88 | 74 (15 to M50) | 8 | 9 |
| [4.7 Manipulation of Power Series](https://cracked.guide/guide/knuth-w072-0) | 89 | 28 (M00 to HM35) | 8 | 5 |
| [Vol 2 review](https://cracked.guide/guide/knuth-w072-1) | 89 | 918 (00 to HM50) | 8 | 5 |

## What you will be able to do

- Pick, use and test a random number generator, and avoid the classic biased-shuffle and modulo-bias bugs.
- Explain floating-point error and write numerically careful code.
- Implement arbitrary-precision arithmetic, including long division and a faster-than-schoolbook multiply.
- Implement gcd, modular inverses, primality testing and Pollard rho factoring.

## Before you start

- Vol 1 math, especially 1.2.4 (number theory) and 1.2.9 (generating functions).
- Basic probability and statistics: mean, variance, distributions.
- C or another language with 64-bit integers for the bignum work.

## Getting the book

Vol 2, 3rd edition is about $64 new from InformIT, less used. Borrow before you buy: many public and university libraries give you free access to O'Reilly Learning, which carries TAOCP; Libby/OverDrive and interlibrary loan (search WorldCat) work too. Older used editions are fine for Vols 1 to 3; section numbers barely changed. If you buy the eBook, get the PDF from InformIT. Knuth himself warns that the Kindle and ePUB versions mangle the math.


## Questions

### How long does TAOCP Volume 2 take?

On the cracked.guide path it takes 26 weeks (weeks 64 to 89), about 6 months, and the reading guides budget about 198 hours in all.

### How many exercises are in TAOCP Volume 2?

918 in the sections the path covers, rated 00 to HM50, and about 240 of them carry Knuth's triangle for recommended. Each reading guide picks the ones worth your time.

### Which edition of Volume 2 do I need?

The current one is the third edition (1997). Older used editions work for most of it; section numbers barely changed. Buy the PDF, not Kindle, if you want an eBook.

---

Source: https://cracked.guide/taocp/volume-2
cracked.guide: A free, dated 145-week path to getting genuinely cracked at programming.
