# TAOCP 3.3.4 The Spectral Test

> Study guide to TAOCP 3.3.4 The Spectral Test. The most important test for LCGs: in t dimensions, successive tuples from an LCG lie on a set of parallel…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 3.3.4 The Spectral Test: The most important test for LCGs: in t dimensions, successive tuples from an LCG lie on a set of parallel hyperplanes, and the spectral test measures how far apart those planes are. Budget about 9 hours; do exercises 1, 8 and 4.

Knuth gives an algorithm to compute it and tables of good and bad multipliers.

## Key facts {#key-facts}

- Week 70 of 145 on the cracked.guide path, in [TAOCP Vol 2: Seminumerical Algorithms](https://cracked.guide/taocp/volume-2).
- Time budget: about 9 hours.
- 32 exercises in the section, rated M10 to HM47; the guide picks 8.
- Picked exercises with Knuth's triangle for recommended: 4, 15, 32 and 24.
- Before you start: 3.2.1 The Linear Congruential Method and basic linear algebra (vectors, dot products).

## Week 70 goals {#objectives}

By the end of week 70 you can:

- Explain why t-tuples from an LCG lie on parallel hyperplanes.
- Recognize that wider spacing between hyperplanes means a worse multiplier.
- Use a scatter plot of successive pairs to spot lattice structure.

## This week's steps {#steps}

- Read §3.3.4 The Spectral Test: Before reading, plot (X_n, X_{n+1}) for a small LCG and see the lines.
- Work the exercises (8 picked): Start with Ex 1, Ex 8, Ex 4; log what you solve below.
- Write down one thing you'd explain to someone: A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

## Exercises {#exercises}

This section has 32 exercises, rated M10 to HM47, and Knuth marks 7 of them with the triangle for recommended. Implementing Algorithm S and running it on a few famous multipliers is the best use of this week; exercise 14 is the warm-up for that.

Worth your time:

- 1 (rated M10): What the spectral test means in one dimension. Checks the definition.
- 8 (rated M16): How bad two-dimensional accuracy can be while three-dimensional accuracy stays fine.
- 4 (rated M23, recommended): The two-dimensional lattice basis behind the test. The geometry in miniature.
- 14 (rated 24): Run Algorithm S by hand on a tiny generator. Do this before coding it.
- 15 (rated M20, recommended): Count how many parallel hyperplanes cut the unit cube. Connects the abstract number to the picture.
- 21 (rated M20): Analyze the lattice when an application throws away some outputs.
- 32 (rated M21, recommended): Show that a well-known combined generator is close to one big linear congruential generator, so the spectral test applies to it.
- 24 (rated M28, recommended): Extend the spectral test to second-order recurrences. The stretch.

## Why it matters {#why}

This explains disasters like IBM's RANDU, whose triples fall on just 15 planes. It is the reason you should not trust a generator just because its 1D histogram looks flat.

## Before you start {#before}

- 3.2.1 The Linear Congruential Method
- Basic linear algebra (vectors, dot products)

## How to approach it {#approach}

Before reading, plot (X_n, X_{n+1}) for a small LCG and see the lines. Plot RANDU triples in 3D. Then read the spectral test algorithm for the ideas. Following every step of the algorithm is optional.

## Common traps {#traps}

- Getting lost in lattice-reduction details. The picture is what matters.

## Links {#links}

- [Knuth's TAOCP page (editions, errata, MIX/MMIX)](https://www-cs-faculty.stanford.edu/~knuth/taocp.html)
- [Vol 2 errata (plain text, from Knuth)](https://www-cs-faculty.stanford.edu/~knuth/err2.textxt)
- [Wikipedia: Spectral test](https://en.wikipedia.org/wiki/Spectral_test)
- [Wikipedia: RANDU](https://en.wikipedia.org/wiki/RANDU)

---

Source: https://cracked.guide/guide/knuth-w053-0
cracked.guide: A free, dated 145-week path to getting genuinely cracked at programming.
