Purpose: Compute a DFT of prime length in by re-indexing with a primitive root, turning the transform into a cyclic convolution of length .

The Idea

The multiplicative group is cyclic of order . Let be a primitive root. Then every nonzero index can be written as , and the map is a bijection .

Re-index the DFT (for ) by , :

The exponent depends only on , so the right-hand side is a cyclic convolution of length between the sequences and .

Since is composite (for ), that convolution can be computed with a standard FFT β€” or, if is awkward, by zero-padding to a power of two with Bluestein-style handling.

Algorithm

  1. Find a primitive root modulo .
  2. Set separately.
  3. Permute the input by .
  4. Cyclically convolve with the precomputed sequence .
  5. Add to every output and un-permute.

Complexity

  • Time:
  • Space:
  • Precomputation: one primitive root (fast, needs the factorisation of ) plus the twiddle sequence

Rader vs Bluestein for prime lengths

RaderBluestein
Requiresa primitive root mod nothing
Convolution length (exact, cyclic) (padded, linear)
Numerical accuracybetterchirp factors grow, slightly worse
Generalityprime lengths onlyany length
Used byFFTW for small primesFFTW for large/awkward primes

Both appear in production FFT libraries: FFTW picks Rader for moderate primes and Bluestein when factors badly.

Where this matters in competitive programming

Rarely, directly. But the underlying move β€” re-indexing a sum by a primitive root to turn multiplication into addition β€” is a genuinely reusable idea:

  • it is how discrete logarithms convert multiplicative problems into additive ones;
  • it is the basis of Pohlig-Hellman;
  • it turns β€œconvolution over under multiplication” into ordinary cyclic convolution, which is occasionally exactly what a counting problem needs.

Variants / Use Cases