← LibraryBerlekamp's Factorization AlgorithmEngineering · MathematicsLesson 196/385← PrevNext →
ArticlePublished 7 Aug 20263 min readBy Kevin Jogin

Engineering  /  Mathematics  — Finite Fields

Berlekamp's Factorization Algorithm

Berlekamp's algorithm: the Berlekamp subalgebra, the kernel computation, and splitting by gcds.

Page KV-MATH-0468Reading time 4 minReviewed 2026-08-07Author Kevin Jogin

Executive summary

Berlekamp's algorithm factors a squarefree polynomial by computing the kernel of a linear map. The kernel dimension equals the number of irreducible factors, so the count is known before any factor is found.

Splitting then uses the kernel elements, taking gcds against constant shifts.

Learning objectives

  1. Define the Berlekamp subalgebra and its dimension.
  2. State the algorithm and its cost.
  3. Explain when it is preferred over Cantor-Zassenhaus.

01The Berlekamp subalgebra

Definition

Berlekamp subalgebra

For squarefree f over F_q, the set

B = {v ∈ F_q[X]/(f) : v^q = v}.

These are the elements fixed by the Frobenius map on the quotient algebra.

Theorem

Dimension equals the factor count

If f has r distinct irreducible factors, then B is an F_q-vector space of dimension r.

The reason is the product decomposition. Since f is squarefree, the quotient algebra is a product of r fields, and an element is fixed by Frobenius exactly when each component lies in F_q. Choosing one base field element per component gives q^r such elements, a space of dimension r.

02The algorithm

Algorithm

Berlekamp factorisation

Inputsquarefree monic f of degree n over F_q
Outputthe complete factorisation of f
  1. Verify f is squarefree; if not, run squarefree decomposition first.
  2. Build the matrix Q whose columns are the coordinates of X^{iq} mod f, for i = 0, ..., n−1.
  3. Compute the kernel of Q − I; its dimension is r, the number of factors.
  4. If r = 1, f is irreducible — return it.
  5. For each non-constant basis element v of the kernel:
  6.   For each c in F_q, compute gcd(f, v − c).
  7.   Collect the non-trivial gcds as factors.
  8. Recurse on any factor that is still reducible.
Cost  O(n³ + qrn²) field operations
Theorem

Complete splitting

For a non-constant v ∈ B, f = ∏_{c ∈ F_q} gcd(f, v − c), and the factors are separated according to the value v takes in each component.

03Cost and applicability

Choosing between the algorithms
Field sizeBerlekampCantor-Zassenhaus
q = 2Excellent — bit operationsCompetitive
Small qGoodGood
Large qPoor — the q factor dominatesPreferred, only log q
Large nPoor — cubic eliminationPreferred, quadratic

Over F₂ Berlekamp is particularly attractive: the linear algebra is over the two-element field, so elimination is word-parallel bit operations, and the splitting loop has only two constants to try.

The deeper value of the algorithm is conceptual. It shows that polynomial factorisation, apparently a question about polynomials, is a rank computation — and the reformulation is what makes the factor count available in advance.

04Frequently asked questions

Why is the kernel dimension the factor count?

Because the quotient algebra is a product of r fields when f is squarefree, and the Frobenius-fixed elements are those with each component in the base field. That gives one free coordinate per component, hence dimension r.

How is the matrix Q constructed?

By computing X^{iq} mod f for each i, which is a sequence of modular exponentiations or repeated Frobenius applications. Building it dominates the cost for large degree.

What if q is too large for the splitting loop?

Sample random constants rather than enumerating, or switch to Cantor-Zassenhaus entirely. Most implementations choose the algorithm based on q and n rather than committing to one.

Sources and method

Structural reference: Victor Shoup, A Computational Introduction to Number Theory and Algebra, Version 1, Cambridge University Press, 2005 — book pages 477-482.

This page carries the durable method layer only: definitions, constructions, algorithms, complexity results and selection criteria, authored originally for KEVOS. No text is transcribed or paraphrased from the source, and no numeric tables or benchmark data are reproduced — these are routed to live authoritative sources instead.

Author: Kevin Jogin. Last reviewed 2026-08-07.

Continue learning

Square-Free Decomposition of PolynomialsArticle · MathematicsNEXT LESSON →Analysis of Berlekamp's AlgorithmArticle · MathematicsAnalysis of the Cantor-Zassenhaus AlgorithmArticle · MathematicsDeterministic Polynomial Factorization AlgorithmsArticle · Mathematics