# TAOCP 4.6.2 Factorization of Polynomials

> Study guide to TAOCP 4.6.2 Factorization of Polynomials. Factoring polynomials modulo a prime (Berlekamp's algorithm and distinct-degree factorization) and…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 4.6.2 Factorization of Polynomials: Factoring polynomials modulo a prime (Berlekamp's algorithm and distinct-degree factorization) and then lifting to factor polynomials over the integers. Budget about 7 hours; do exercises 9, 10 and 11.

## Key facts {#key-facts}

- Week 86 of 145 on the cracked.guide path, in [TAOCP Vol 2: Seminumerical Algorithms](https://cracked.guide/taocp/volume-2).
- Time budget: about 7 hours.
- 41 exercises in the section, rated 20 to M47; the guide picks 8.
- Picked exercises with Knuth's triangle for recommended: 10, 12, 15, 34 and 22.
- Before you start: 4.6.1 Division of Polynomials and basic linear algebra mod p.

## Week 86 goals {#objectives}

By the end of week 86 you can:

- Explain how Berlekamp's algorithm factors a squarefree polynomial modulo a prime.
- Recognize irreducible quadratics and cubics modulo 2 by checking for roots.
- Use gcd(u, u′) to detect repeated factors before factoring.

## This week's steps {#steps}

- Read §4.6.2 Factorization of Polynomials: Read the overview and follow one small worked example of Berlekamp's algorithm.
- Work the exercises (8 picked): Start with Ex 9, Ex 10, Ex 11; 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 41 exercises, rated 20 to M47, and Knuth marks 10 of them with the triangle for recommended. Work Berlekamp's algorithm on the text's example by hand or with a small program before the theory exercises.

Worth your time:

- 9 (rated 20): Build a table of inverses mod 101 from a primitive root.
- 10 (rated 21, recommended): Factor the text's example mod 2 with Berlekamp.
- 11 (rated 22): Same polynomial mod 5.
- 12 (rated M22, recommended): How x^4 + 1 factors modulo every prime.
- 19 (rated M20): Eisenstein's irreducibility criterion.
- 15 (rated M27, recommended): Square roots modulo a prime. Needed all over number theory and crypto.
- 34 (rated M25, recommended): Squarefree factorization using derivatives and gcds.
- 22 (rated M24, recommended): Hensel lifting of a factorization mod p to mod p^e. The stretch.

## Why it matters {#why}

One of the more specialized sections. It matters for computer algebra and coding theory; for most programmers the takeaway is that factoring polynomials is surprisingly tractable while factoring integers is not.

## Before you start {#before}

- 4.6.1 Division of Polynomials
- Basic linear algebra mod p

## How to approach it {#approach}

Read the overview and follow one small worked example of Berlekamp's algorithm. Skim the rest. Spend extra time catching up if you are behind.

## Common traps {#traps}

- Feeling you must master this. It is fine to come back later.

## 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: Berlekamp's algorithm](https://en.wikipedia.org/wiki/Berlekamp%27s_algorithm)
- [Wikipedia: Factorization of polynomials over finite fields](https://en.wikipedia.org/wiki/Factorization_of_polynomials_over_finite_fields)

---

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