Algorithm Search⌘K

Proofs: Iterative FFT

These are the human proofs of Iterative FFT, at full length.

The decimation-in-frequency and decimation-in-time stages compute the DFT in bit-reversed and natural order, and their pairing computes the cyclic convolution full

This proof shows: correctness, complexity.

Setting. RR is a commutative ring, n=2tn = 2^t with t≥0t \ge 0, and ω∈R\omega \in R satisfies ωn=1\omega^n = 1 and, if t≥1t \ge 1, ωn/2=−1\omega^{n/2} = -1. This implies that ω\omega is a principal nn-th root of unity (proved on the page on roots of unity). Conversely, a principal root has ωn/2=−1\omega^{n/2} = -1 whenever n2⋅1\frac{n}{2} \cdot 1 is not a zero divisor, for then ∑j<n(ωn/2)j=n2(1+ωn/2)=0\sum_{j<n} (\omega^{n/2})^j = \frac{n}{2}(1 + \omega^{n/2}) = 0 forces ωn/2=−1\omega^{n/2} = -1; this covers every field of characteristic other than 22, every Z/pZ\mathbb{Z}/p\mathbb{Z} with pp odd, and every ring in which nn is a unit. (Without it the radix-2 split fails: in Z/4Z\mathbb{Z}/4\mathbb{Z}, ω=1\omega = 1 is a principal 44-th root, but ω2≠−1\omega^2 \ne -1.) If t≥2t \ge 2, the element ω2\omega^2 has the same two properties for n/2n/2, since (ω2)n/4=ωn/2=−1(\omega^2)^{n/4} = \omega^{n/2} = -1; this is what the inductions use. For 0≤i<2t0 \le i < 2^t let revt(i)\mathrm{rev}_t(i) be ii with its tt binary digits reversed, and let (Py)i=yrevt(i)(Py)_i = y_{\mathrm{rev}_t(i)}. Since revt\mathrm{rev}_t is an involution, P−1=PP^{-1} = P. Two facts about digits are used: for 0≤q<2t−10 \le q < 2^{t-1},

revt(q)=2 revt−1(q),revt(2t−1+q)=2 revt−1(q)+1,(1)\mathrm{rev}_t(q) = 2\,\mathrm{rev}_{t-1}(q), \qquad \mathrm{rev}_t(2^{t-1} + q) = 2\,\mathrm{rev}_{t-1}(q) + 1, \tag{1}

because the top digit of qq is 00 and that of 2t−1+q2^{t-1} + q is 11, and reversal moves the top digit to the bottom. Also, revt(2q)=revt−1(q)\mathrm{rev}_t(2q) = \mathrm{rev}_{t-1}(q) and revt(2q+1)=2t−1+revt−1(q)\mathrm{rev}_t(2q + 1) = 2^{t-1} + \mathrm{rev}_{t-1}(q) by the same reasoning.

Lemma 1 (decimation in frequency). Let DtωD_t^\omega be the map of lines L3 to L10 on an array of length 2t2^t, with W[k]=ωkW[k] = \omega^k. Then Dtω(x)=P DFTω(x)D_t^\omega(x) = P\,\mathrm{DFT}_\omega(x).

Proof. Induction on tt. For t=0t = 0 the loop does nothing and PP is the identity. Let t≥1t \ge 1 and n=2tn = 2^t. The first pass has h=n/2h = n/2, one block s=0s = 0, and stride n/(2h)=1n/(2h) = 1; its butterflies touch the disjoint pairs (k,k+n/2)(k, k + n/2), read both cells before writing, and produce

uj=xj+xj+n/2,vj=ωj(xj−xj+n/2),0≤j<n/2.u_j = x_j + x_{j + n/2}, \qquad v_j = \omega^j (x_j - x_{j + n/2}), \qquad 0 \le j < n/2.

Split the sum for XkX_k at n/2n/2 and use ω(j+n/2)k=ωjk(−1)k\omega^{(j + n/2)k} = \omega^{jk} (-1)^k:

Xk=∑j<n/2(xj+(−1)kxj+n/2)ωjk.X_k = \sum_{j < n/2} \bigl(x_j + (-1)^k x_{j+n/2}\bigr) \omega^{jk}.

For k=2mk = 2m this is ∑juj(ω2)jm\sum_j u_j (\omega^2)^{jm}, and for k=2m+1k = 2m + 1 it is ∑j(xj−xj+n/2)ωj(ω2)jm=∑jvj(ω2)jm\sum_j (x_j - x_{j + n/2}) \omega^j (\omega^2)^{jm} = \sum_j v_j (\omega^2)^{jm}. So (X2m)m=DFTω2(u)(X_{2m})_m = \mathrm{DFT}_{\omega^2}(u) and (X2m+1)m=DFTω2(v)(X_{2m+1})_m = \mathrm{DFT}_{\omega^2}(v).

The later passes have h≤n/4h \le n/4, so every block of length 2h2h lies inside one half of the array, and no butterfly mixes the halves. On each half, the pass with half length hh reads W[k⋅n/(2h)]=ωkn/(2h)=(ω2)k⋅(n/2)/(2h)W[k \cdot n/(2h)] = \omega^{k n/(2h)} = (\omega^2)^{k \cdot (n/2)/(2h)}, which is the twiddle factor of the pass with half length hh of Dt−1ω2D_{t-1}^{\omega^2}. So the later passes apply Dt−1ω2D_{t-1}^{\omega^2} to uu and to vv separately. By the induction hypothesis, for 0≤q<n/20 \le q < n/2, position qq ends with X2 revt−1(q)X_{2\,\mathrm{rev}_{t-1}(q)}, and position n/2+qn/2 + q ends with X2 revt−1(q)+1X_{2\,\mathrm{rev}_{t-1}(q) + 1}. By (1) these are Xrevt(q)X_{\mathrm{rev}_t(q)} and Xrevt(n/2+q)X_{\mathrm{rev}_t(n/2 + q)}. □\square

Correctness of ITERATIVE-FFT. Lines L11 and L12 visit each pair {j,revt(j)}\{j, \mathrm{rev}_t(j)\} with j≠revt(j)j \ne \mathrm{rev}_t(j) once, at its smaller element, and swap it, so they apply PP. By Lemma 1 the result is PP DFTω(x)=DFTω(x)P P\, \mathrm{DFT}_\omega(x) = \mathrm{DFT}_\omega(x).

Lemma 2 (decimation in time). Let TtωT_t^\omega be the map of lines L16 to L22 on an array of length 2t2^t with V[k]=ωkV[k] = \omega^k. Then Ttω(Pz)=DFTω(z)T_t^\omega(P z) = \mathrm{DFT}_\omega(z) for each z∈R2tz \in R^{2^t}.

Proof. Induction on tt; t=0t = 0 is trivial. Let t≥1t \ge 1, n=2tn = 2^t, and y=Pzy = Pz. The passes with h≤n/4h \le n/4 never mix the halves, and on each half they are the passes of Tt−1ω2T_{t-1}^{\omega^2}, by the same computation of the twiddle factors as in Lemma 1. By the facts after (1), for q<n/2q < n/2, yq=zrevt(q)=z2 revt−1(q)y_q = z_{\mathrm{rev}_t(q)} = z_{2\,\mathrm{rev}_{t-1}(q)} and yn/2+q=z2 revt−1(q)+1y_{n/2 + q} = z_{2\,\mathrm{rev}_{t-1}(q) + 1}. So the first half of yy is Pt−1eP_{t-1} e with em=z2me_m = z_{2m}, and the second half is Pt−1oP_{t-1} o with om=z2m+1o_m = z_{2m+1}. By the induction hypothesis, after the first t−1t - 1 passes the halves hold E=DFTω2(e)E = \mathrm{DFT}_{\omega^2}(e) and O=DFTω2(o)O = \mathrm{DFT}_{\omega^2}(o). The last pass, h=n/2h = n/2, maps (Ek,Ok)(E_k, O_k) to (Ek+ωkOk, Ek−ωkOk)(E_k + \omega^k O_k,\ E_k - \omega^k O_k). Splitting XkX_k by the parity of jj gives Xk=Ek mod n/2+ωkOk mod n/2X_k = E_{k \bmod n/2} + \omega^k O_{k \bmod n/2}, and ωk+n/2=−ωk\omega^{k + n/2} = -\omega^k, so these two values are XkX_k and Xk+n/2X_{k + n/2}. □\square

Correctness of CYCLIC-CONVOLUTION. By Lemma 1, after line L13, aa and bb hold Pa^P\hat a and Pb^P\hat b, where a^=DFTω(a)\hat a = \mathrm{DFT}_\omega(a). Since (Py)i=yrevt(i)(P y)_i = y_{\mathrm{rev}_t(i)}, line L14 gives c=P(a^⊙b^)c = P(\hat a \odot \hat b) with the entrywise product ⊙\odot. The element ω−1=ωn−1\omega^{-1} = \omega^{n-1} is again a principal nn-th root of unity (its powers are those of ω\omega in another order), so Lemma 2 applies with the root ω−1\omega^{-1} and gives DFTω−1(a^⊙b^)\mathrm{DFT}_{\omega^{-1}}(\hat a \odot \hat b) after line L22. By the convolution theorem, a^⊙b^=DFTω(a∗b)\hat a \odot \hat b = \mathrm{DFT}_\omega(a \ast b), where (a∗b)m=∑jajb(m−j) mod n(a \ast b)_m = \sum_j a_j b_{(m-j) \bmod n}: indeed ∑m(a∗b)mωmk=∑jajωjk∑mb(m−j) mod nω(m−j)k\sum_m (a \ast b)_m \omega^{mk} = \sum_j a_j \omega^{jk} \sum_m b_{(m-j) \bmod n} \omega^{(m - j)k}, and the inner sum is b^k\hat b_k because ωn=1\omega^n = 1. Finally, DFTω−1(DFTω(y))=ny\mathrm{DFT}_{\omega^{-1}}(\mathrm{DFT}_\omega(y)) = n y, since its entry jj is ∑mym∑kω(m−j)k=nyj\sum_m y_m \sum_k \omega^{(m - j)k} = n y_j by the definition of a principal root. So after line L22, c=n(a∗b)c = n (a \ast b), and since nn is a unit, line L23 returns a∗ba \ast b.

Operation count. In every pass there are n/(2h)n/(2h) blocks of hh butterflies, so n/2n/2 butterflies, each with one addition, one subtraction and one multiplication. There are t=lg⁡nt = \lg n passes. So lines L3 to L10, and also lines L16 to L22, do exactly nlg⁡nn \lg n additions and subtractions and n2lg⁡n\frac{n}{2}\lg n multiplications, for every input, and ITERATIVE-FFT does no further ring operation except at most n/2n/2 multiplications for the table of line L2. CYCLIC-CONVOLUTION does three such transforms, nn multiplications in line L14 and nn in line L23: 3nlg⁡n3 n \lg n additions and 32nlg⁡n+2n\frac{3}{2} n \lg n + 2n multiplications, besides the two tables. The index work is proportional to the number of butterflies plus O(n)O(n) for the permutation, so the time is Θ(nlog⁡n)\Theta(n \log n) for every input. The transforms write only into the arrays they are given; the tables take Θ(n)\Theta(n) extra space. ■\blacksquare

Back to Iterative FFT