Algorithm Search⌘K

Proofs: Rader's algorithm

These are the human proofs of Rader's algorithm, at full length.

RADER-FFT computes a DFT of prime length n with (3/2) L lg L + 2L multiplications and 3 L lg L + 3n − 4 additions full

This proof shows: correctness, complexity.

Statement. Let nn be a prime, N=n−1N = n - 1, LL the least power of two with L≥2N−1L \ge 2N - 1, and RR a commutative ring containing an element ω\omega with ωn=1\omega^n = 1, and an element ρ\rho with ρL=1\rho^{L} = 1 and ρL/2=−1\rho^{L/2} = -1 (when L≥2L \ge 2), in which LL is a unit. (Over C\mathbb{C}, ω=e−2πi/n\omega = e^{-2\pi i/n} and ρ=e−2πi/L\rho = e^{-2\pi i/L}; modulo a prime PP, this needs n∣P−1n \mid P - 1 and L∣P−1L \mid P - 1.) For every x∈Rnx \in R^n, RADER-FFT returns XX with Xk=∑jxjωjkX_k = \sum_{j} x_j \omega^{jk}, using 32Llg⁡L+2L\frac32 L \lg L + 2L multiplications and 3Llg⁡L+3n−43 L \lg L + 3n - 4 additions and subtractions in RR.

Lemma 1 (the reindexing). Let gg be a primitive root modulo nn. The maps q↦gq mod nq \mapsto g^q \bmod n and p↦g−p mod np \mapsto g^{-p} \bmod n are bijections from [0,N)[0, N) onto {1,…,n−1}\{1, \ldots, n - 1\}, and gqg−p≡g(q−p) mod N(modn)g^{q} g^{-p} \equiv g^{(q - p) \bmod N} \pmod n. Proof. The multiplicative group modulo the prime nn has order NN and is generated by gg, so g0,…,gN−1g^0, \ldots, g^{N-1} are distinct and exhaust it; the same holds for their inverses g−pg^{-p}. Since gN≡1g^N \equiv 1 (Fermat's little theorem), exponents may be reduced modulo NN. □\square

Lemma 2 (the convolution). With aq=xgqa_q = x_{g^q} and bm=ωg−mb_m = \omega^{g^{-m}} (exponents of gg reduced modulo nn), for each p∈[0,N)p \in [0, N),

Xg−p=x0+∑q=0N−1aq b(p−q) mod N.X_{g^{-p}} = x_0 + \sum_{q=0}^{N-1} a_q\, b_{(p - q) \bmod N}.

Proof. Let k=g−p mod nk = g^{-p} \bmod n, which is nonzero. Split Xk=x0ω0+∑j=1n−1xjωjkX_k = x_0 \omega^0 + \sum_{j=1}^{n-1} x_j \omega^{jk} and substitute j=gqj = g^q by Lemma 1. Since ωn=1\omega^n = 1, ωjk\omega^{jk} depends only on jk mod njk \bmod n, and jk≡gqg−p≡g−((p−q) mod N)(modn)jk \equiv g^q g^{-p} \equiv g^{-((p - q) \bmod N)} \pmod n by Lemma 1, so ωjk=b(p−q) mod N\omega^{jk} = b_{(p - q) \bmod N}. □\square

Lemma 3 (cyclic convolution by padding). Let ℓ\ell be the linear convolution of aa and bb, ℓr=∑q+m=raqbm\ell_r = \sum_{q + m = r} a_q b_m for 0≤r≤2N−20 \le r \le 2N - 2. Then (a∗b)p=ℓp+ℓp+N(a * b)_p = \ell_p + \ell_{p + N} for 0≤p<N0 \le p < N, with ℓ2N−1=0\ell_{2N - 1} = 0. Proof. The pairs (q,m)∈[0,N)2(q, m) \in [0, N)^2 with (q+m) mod N=p(q + m) \bmod N = p are those with q+m=pq + m = p or q+m=p+Nq + m = p + N, since 0≤q+m≤2N−20 \le q + m \le 2N - 2. □\square

Line L4. Let α,β∈RL\alpha, \beta \in R^L be aa and bb padded with zeros. The radix-2 FFT of length LL with root ρ\rho computes α^k=∑jαjρjk\hat\alpha_k = \sum_j \alpha_j \rho^{jk}, because ρL/2=−1\rho^{L/2} = -1 (the proof is on the page of the iterative FFT). Then α^kβ^k=∑rγrρrk\hat\alpha_k \hat\beta_k = \sum_{r} \gamma_r \rho^{rk}, where γr=∑(q+m) mod L=rαqβm\gamma_r = \sum_{(q + m) \bmod L = r} \alpha_q \beta_m is the cyclic convolution of length LL, by expanding the product and using ρL=1\rho^L = 1. Since αqβm≠0\alpha_q \beta_m \ne 0 only if q,m<Nq, m < N, and then q+m≤2N−2<Lq + m \le 2N - 2 < L, no index wraps around and γr=ℓr\gamma_r = \ell_r for r≤2N−2r \le 2N - 2, γr=0\gamma_r = 0 otherwise. The inverse FFT, run with ρ−1\rho^{-1} (which also satisfies (ρ−1)L/2=−1(\rho^{-1})^{L/2} = -1) and multiplied by L−1L^{-1}, returns γ\gamma: indeed ∑kγ^kρ−kr=∑sγs∑kρk(s−r)=Lγr\sum_k \hat\gamma_k \rho^{-kr} = \sum_s \gamma_s \sum_k \rho^{k(s - r)} = L \gamma_r, because for s≠rs \ne r in [0,L)[0, L) the inner sum S=∑k<LρktS = \sum_{k<L} \rho^{kt}, t=(s−r) mod L∈(0,L)t = (s - r) \bmod L \in (0, L), vanishes. To see this, write t=2edt = 2^e d with dd odd, so 2e+1≤L2^{e+1} \le L, and let K=L/2e+1K = L / 2^{e+1}. Then ρKt=(ρL/2)d=−1\rho^{Kt} = (\rho^{L/2})^d = -1. Since ρL=1\rho^L = 1, the term ρkt\rho^{kt} depends only on k mod Lk \bmod L, and k↦k+Kk \mapsto k + K permutes the residues modulo LL, so S=ρKtS=−SS = \rho^{Kt} S = -S. Thus 2S=02S = 0, and S=0S = 0 because 22 divides the unit LL and is therefore a unit. Folding by Lemma 3 gives c=a∗bc = a * b.

Correctness. Line L5 sets X0=∑jxjω0X_0 = \sum_j x_j \omega^0. By Lemma 1, the loop at lines L6 and L7 writes each nonzero index k=g−pk = g^{-p} exactly once, with the value x0+cpx_0 + c_p, which is XkX_k by Lemma 2 and line L4. So the returned vector is XX.

Inverse. With ω−1\omega^{-1}, which also has (ω−1)n=1(\omega^{-1})^n = 1, the same program computes ∑kXkω−jk\sum_k X_k \omega^{-jk}; if ω\omega is a principal nn-th root of unity and nn is a unit, this is nxjn x_j, and the final division returns xx.

Operation count. The three FFTs of length LL (of α\alpha, of β\beta, and the inverse) each consist of lg⁡L\lg L stages of L/2L/2 butterflies, one multiplication and two additions each: L2lg⁡L\frac{L}{2} \lg L multiplications and Llg⁡LL \lg L additions per FFT. The pointwise product is LL multiplications, and the scaling by L−1L^{-1} is LL more. The folding adds ℓp+N\ell_{p+N} for 0≤p≤N−20 \le p \le N - 2: N−1N - 1 additions. Line L5 is n−1n - 1 additions and line L7 is NN additions. The totals are 32Llg⁡L+2L\frac32 L \lg L + 2L multiplications and 3Llg⁡L+(N−1)+(n−1)+N=3Llg⁡L+3n−43 L \lg L + (N - 1) + (n - 1) + N = 3 L \lg L + 3n - 4 additions. Since 2n−3≤L<2(2n−3)2n - 3 \le L < 2(2n - 3), both are Θ(nlog⁡n)\Theta(n \log n) for n≥3n \ge 3. The arrays have length LL, so the extra space is Θ(n)\Theta(n). ■\blacksquare

Back to Rader's algorithm