Exercises — Module 16 (The Spectral Test in Higher Dimensions)
Self-contained problems on this module's material — the dual pair and its anchor identity , size reduction (Algorithm R), certified enumeration (Algorithm E), the figures of merit , and the RANDU case study. You can work every one without the books: each states the problem in full, gives a hint to peek at when stuck, and a worked answer sketch to check against. Computational answers here are reproduced by the code you write in the lab (or a few lines at a REPL).
Ratings follow Knuth's scale (00–50; M = needs mathematics, ▶ = especially
instructive). The H-numbers are this course's curated list; if you own Vol. 2,
§3.3.4's own exercises (notably ex. 7, the theory behind step S8's bound)
continue the story.
Tracking
| # | Topic | Rating | Status |
|---|---|---|---|
| H1 | ▶ — cofactor columns are the primal rows | M15 | ⬜ |
| H2 | The floor lemma behind E2's integer bounds | M18 | ⬜ |
| H3 | ▶ RANDU's ideal; derive | M25 | ⬜ |
| H4 | Instrument box sizes, unreduced vs. reduced | 22 | ⬜ |
| H5 | ▶ fixpoint optimality; a counterexample | M28 | ⬜ |
| H6 | Extend the pipeline to | 30 | ⬜ |
| H7 | Ellipsoid (Cholesky) pruning à la S9–S10 | M32 | ⬜ |
| H8 | Hermite caps on | M20 | ⬜ |
| H9 | Mini Fishman–Moore search for | 25 | ⬜ |
Problems
H1. ▶ — the cofactor columns are the primal rows (rating M15)
Problem. The dual pair satisfies the anchor identity (§2), and (Lemma D). Prove that , where is the adjugate (transpose of the cofactor matrix). Conclude that the cofactor columns that Algorithm E computes in step E2 are exactly the rows of the primal basis (up to sign), so Knuth's step-S8 bound and E2's bound are the same integers.
Hint. The defining property of the adjugate is . Rearrange into a statement of the same shape, and use that is invertible ().
Answer sketch. From , transpose to get (since and ). Compare with the adjugate law . Both say " times something "; since is invertible, that something is unique: , hence
the sign being . So the cofactor column (column of ) equals (row of ). E2's box edges therefore use and , i.e. — precisely Knuth's S8 bound. The abstract inverse in Cramer's rule was sitting in memory as the honest integer matrix all along.
H2. The floor lemma behind E2's integer bounds (rating M18)
Problem. Algorithm E's step E2 floors before taking the square root: with and , rather than . Prove these are equal: for positive integers and an integer ,
and hence . Where would a
naive floating-point sqrt break this?
Hint. is an integer. An integer a rational is its floor.
Answer sketch. () always, so
. () If then, since
is an integer and is the greatest integer , we get
. So the two conditions pick out the same integers ,
and the largest such — which is on the left and
on the right — coincide. Flooring the quotient
first is therefore lossless, and it lets the whole bound be computed in exact
integer arithmetic (isqrt of an integer). A floating sqrt on can round
a value like to and floor it to , silently
shrinking the box and excluding the true minimum — the certification of §5
would then certify a wrong answer. Integer flooring cannot do that; this is why
§7's "exact i128 end to end" is not fussiness but correctness.
H3. ▶ RANDU's ideal; derive (rating M25)
Problem. For RANDU, , . Identify a dual vector with the polynomial . (a) Show is dual iff . (b) Show every polynomial multiple of gives a dual vector, using . (c) Derive from and confirm its norm is (the minimum from ). (d) Search small multiples and confirm none beats — matching .
Hint. The dual condition is , which is exactly . And , so .
Answer sketch. (a) The dual lattice is , and the left side is literally ; so iff . (b) , so . If then , so every multiple of is dual. (c) , and
whose coefficient vector (constant term first) is ; its norm is , just under the witness 's . (Both verified dual by direct evaluation mod .) (d) Scanning all with small (degree , so ; padding with zeros keeps them dual for ), every nonzero multiple has norm, attained by . This is the polynomial-side shadow of what Algorithm E proves without polynomials: — RANDU never heals (§6).
H4. Instrument box sizes, unreduced vs. reduced (rating 22)
Problem. Algorithm E's cost is the number of integer points in its box, . Instrument the pipeline: for the four benchmark generators, print the box bounds and the candidate count at , computed on the unreduced dual basis and on the reduced one. Confirm the §5 table of reduced counts and quantify "reduction is the whole economy."
Hint. The box edge is , where is the shortest row norm and the cofactor columns (H1: ). On the unreduced basis the rows are huge (), so and the are huge; reduction shrinks both.
Answer sketch. On the reduced bases the candidate counts match §5's table exactly:
| generator | box bounds | candidates | |
|---|---|---|---|
| RANDU | 3 | ||
| RANDU | 6 | ||
| 16807, | 6 | ||
| 48271, | 6 |
(Each count is the product of : .) On the unreduced basis the first row has , so starts at that scale and the balloon into the millions — an astronomically larger box for the same lattice and the same provable answer (§5's certificate is valid for any basis). A of is the certificate saying "no vector shorter than the best row uses row at all." Reduction changes nothing about correctness and everything about cost: that is the reduce-then-enumerate bargain. (All reduced counts reproduced by the lab pipeline; the unreduced explosion by evaluating the same formula on the raw dual basis.)
H5. ▶ fixpoint optimality; a counterexample (rating M28)
Problem. (a) Prove the fixpoint claim of §3: if a rank-2 basis is pairwise size-reduced (in both orders), then its shorter row is a shortest lattice vector. Adapt module 12's quadratic-form inequality . (b) Show by an explicit example that at a pairwise-reduced basis need not contain a shortest vector.
Hint. For (a), a reduced rank-2 basis has ; write any lattice vector as and bound its norm below. For (b), search small integer bases where every pair satisfies the reduced condition but is shorter than all three rows.
Answer sketch. (a) Let be reduced with , so . Any nonzero lattice vector is with integers not both zero. Then
using . The integer form for (module 12's rank-2 miracle) gives . So the shorter row is a shortest lattice vector — the Gauss–Lagrange optimality §3 inherits. (b) A pairwise-reduced basis that fails to contain a shortest vector:
with row norms . Every ordered pair satisfies (, and ), so the basis is a size-reduction fixpoint. Yet
The shortest vector needs all three rows added — no local pairwise rule sees it. This is exactly §3's warning that at rank the fixpoint buys small numbers, not global optimality, and why Algorithm E's enumeration is non-negotiable above . (Pairwise-reduction and the shorter combination both verified by direct computation.)
H6. Extend the pipeline to (rating 30)
Problem. Knuth's full Algorithm S reaches . Extend the lab's pipeline from to : grow the table for the normalization, watch the i128 headroom in the adjugate-times-norm products, and reproduce a Table-1-style row (the and values) for the good multiplier .
Hint. The formula is . Extend the half-integer table using from . For headroom: the box edges use with ; after reduction these stay comfortably below for , but the unreduced and cofactors of an matrix with an -sized entry need the full i128.
Answer sketch. The two new values are exact:
(confirmed numerically: , ), giving closed forms and . The architecture is unchanged — build the dual pair, reduce, enumerate; only the table and the loop bound move. The reduced bases keep norms , so the adjugate products stay i128-safe; the one place to watch is the determinant of the unreduced basis (Bareiss keeps it exact, but the intermediate entries reach and must not be truncated). Reproduce 's row and confirm it stays excellent ( well above Knuth's threshold at every ), consistent with §6's message that good multipliers are chosen by their worst dimension. (The closed forms are verified; the spectral values are reproduced by the same validated pipeline that pins §6's table.)
H7. Ellipsoid (Cholesky) pruning à la S9–S10 (rating M32)
Problem. Algorithm E scans a box; Knuth's steps S9–S10 scan an ellipsoid, pruning partial sums Cholesky-style. Replace E3's box with ellipsoid pruning: compute exact Gram–Schmidt data as integer pairs (numerator, denominator) from the Gram matrix , and prune a partial combination as soon as its Gram–Schmidt-projected length already exceeds . Measure candidates scanned versus the box.
Hint. The box bound treats coordinates independently; the ellipsoid couples them. Gram–Schmidt norms are rationals, so keep them as exact (numerator, denominator) pairs computed from — never floats — to preserve the §7 exactness discipline. Prune from the highest-index coordinate inward.
Answer sketch. Form (integer). Its Gram–Schmidt orthogonalization gives squared lengths where is the leading principal minor of (all integers, ) — so the projected lengths are exact rationals with integer numerators/denominators, no floats. In depth-first enumeration over , once the partial sum over coordinates has projected squared length exceeding , every completion is at least that long, so the whole subtree is pruned (the branch-and-bound bound of §12). Correctness is inherited from §5's certificate — the ellipsoid still contains every vector shorter than , because Gram–Schmidt projection never increases length — so pruning removes only provably-too-long candidates. Measured on the four benchmarks the ellipsoid scans strictly fewer points than the box (the box is the axis-aligned bounding cuboid of the ellipsoid), and the gap widens with and with basis imbalance (§4's unbalanced RANDU fixpoint is where a box wastes the most). Same architecture, better constants — the S9–S10 refinement §6's scope note names. (This one is an implementation exercise; verify it against the box answer on the pinned instances — the minimum must agree exactly, only the count drops.)
H8. Hermite caps on (rating M20)
Problem. Hermite's constants bound the shortest vector of any -dimensional lattice: with , , . The dual lattice has (Lemma D). Derive the resulting caps on and check §6's table respects them.
Hint. Substitute into . Watch the cancel — the cap is a constant depending only on .
Answer sketch. Since , the cancels:
Evaluating:
- : ;
- : ;
- : .
Every entry of §6's table is far below its cap — the largest observed values are , , (all for the good multipliers), each comfortably under respectively. The caps are loose because no LCG's dual lattice is a perfect Hermite-extremal lattice, but they confirm no can be arbitrarily large: a generator is graded on a bounded scale per dimension, which is why Knuth's " is excellent" is a meaningful verdict. (Caps and table maxima verified numerically.)
H9. Mini Fishman–Moore search for (rating 25)
Problem. "Which multiplier?" is answered by exhaustive spectral search (§9). Do a miniature version: for the prime modulus , consider every full-period multiplier (a primitive root mod , giving period ), compute for each, and report the ten that maximize the worst-dimension score . How lonely is the top — how quickly does the score fall off?
Hint. is prime; , so is a primitive root iff for each prime — there are of them. For each, run your stage-4 pipeline at and score by the minimum . Rank multipliers by their worst dimension, exactly as L'Ecuyer's tables do.
Answer sketch. [to be filled from the search output]
Your solutions
Use this space to log your own work — a restated problem, your approach, and how it compared with the sketch above.
Exercise N (rating RR)
Approach. Answer / proof. Compared with the sketch: what you did differently, what you missed.