← LibraryFaster Square-Free DecompositionEngineering · MathematicsLesson 199/385← PrevNext →
ArticlePublished 7 Aug 20263 min readBy Kevin Jogin

Engineering  /  Mathematics  — Finite Fields

Faster Square-Free Decomposition

Yun's algorithm and other improvements to squarefree decomposition, and their cost advantages.

Page KV-MATH-0471Reading time 3 minReviewed 2026-08-07Author Kevin Jogin

Executive summary

The naive squarefree decomposition performs a gcd per multiplicity level. Yun's algorithm restructures the computation so the total work is proportional to a single gcd rather than to the number of levels.

The characteristic p case still requires special handling for vanishing derivatives.

Learning objectives

  1. State Yun's algorithm and its cost advantage.
  2. Compare with the naive method.
  3. Handle the characteristic p branch.

01The naive cost

The straightforward method computes a gcd at each multiplicity level, so a polynomial with factors of high multiplicity requires many gcds even though most of the work is repeated.

Yun's algorithm restructures the recursion so that the polynomials shrink quickly, making the total cost comparable to a single gcd computation on the original.

02Yun's algorithm

Algorithm

Yun's squarefree decomposition

Inputmonic f over a field of characteristic 0 or not dividing the multiplicities
Outputsquarefree parts indexed by multiplicity
  1. Compute u = gcd(f, f').
  2. Set v = f/u and w = f'/u.
  3. For i = 1, 2, ...:
  4.   Compute h = w − v'.
  5.   Compute g = gcd(v, h); this is the product of factors of multiplicity exactly i.
  6.   Set v = v/g and w = h/g.
  7. Until v is constant.
Cost  O(n²), with the total gcd work comparable to one gcd on f

The improvement comes from maintaining the derivative information incrementally in w rather than recomputing gcds against the original polynomial at each level. The degrees fall quickly, so later iterations are cheap.

  1. Naive methodOne gcd per levelRepeated work on large polynomials
  2. Yun's algorithmTotal comparable to one gcdIncremental derivative tracking
  3. With fast arithmeticO(n log² n)Using fast gcd

03Characteristic p

  1. Run Yun's algorithm

    Handles all multiplicities not divisible by p.

  2. Detect a vanishing derivative

    If f' = 0, then f = g(X^p) for some g.

  3. Extract the p-th root

    Take p-th roots of coefficients — possible since Frobenius is surjective on a finite field — and divide exponents by p.

  4. Recurse and adjust

    Decompose the root and multiply every multiplicity by p.

  5. Combine

    Merge the two sets of results.

The branch is unavoidable and is a recurring feature of finite field algorithms: the characteristic interacts with exponents in ways that have no analogue in characteristic zero, and every algorithm relying on derivatives needs the extra case.

04Frequently asked questions

How much faster is Yun's algorithm in practice?

Substantially for polynomials with high multiplicities, and comparable for squarefree inputs where both terminate after one step. The worst case is where it matters most.

Does it work over the integers?

Yes, in characteristic zero it applies without the special branch. Coefficient growth remains a concern and the modular method is used as elsewhere.

Why is squarefree decomposition worth optimising?

Because it runs before every factorisation and on every input. Even a modest constant-factor improvement applies universally, and for high-multiplicity inputs the asymptotic gain is real.

Sources and method

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

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

Deterministic Polynomial Factorization AlgorithmsArticle · MathematicsNEXT LESSON →Computational Number Theory: Tools and LibrariesArticle · MathematicsAnalysis of Berlekamp's AlgorithmArticle · MathematicsArbitrary Precision Arithmetic in PracticeArticle · Mathematics