Algorithm Search⌘K

Proofs: Real-valued FFT

These are the human proofs of Real-valued FFT, at full length.

REAL-FFT returns X_0, …, X_(n/2) of a real sequence with n lg n + 3n + 8 real multiplications and (3/2) n lg n + (5/2) n + 8 real additions full

This proof shows: correctness, complexity.

Setting. Let KK be C\mathbb{C} with complex conjugation, or Zp[i]=Zp[t]/(t2+1)\mathbb{Z}_p[i] = \mathbb{Z}_p[t]/(t^2 + 1) for an odd prime pp with a+bi‾=a−bi\overline{a + bi} = a - bi. In both cases conjugation is a ring automorphism of order at most 22 that fixes the subring FF of "real" elements (R\mathbb{R} or Zp\mathbb{Z}_p) and sends ii to −i-i, and 22 and ii are units. Let n=2hn = 2h with h=2sh = 2^{s}, s≥0s \ge 0, and let ω∈K\omega \in K satisfy ωn=1\omega^n = 1, ωh=−1\omega^h = -1 and ωωˉ=1\omega \bar\omega = 1. Over C\mathbb{C}, ω=e−2πi/n\omega = e^{-2\pi i/n} satisfies all three.

Statement. For every x∈Fnx \in F^n, REAL-FFT returns X0,…,XhX_0, \ldots, X_h, where Xk=∑j=0n−1xjωjkX_k = \sum_{j=0}^{n-1} x_j \omega^{jk}, and moreover Xn−k=Xk‾X_{n-k} = \overline{X_k} for all kk. If moreover ωk−1\omega^k - 1 is a unit for 0<k<n0 < k < n (true over C\mathbb{C}, in the field Zp[i]\mathbb{Z}_p[i] for p≡3(mod4)p \equiv 3 \pmod 4, and for the roots used in the tests when p≡1(mod4)p \equiv 1 \pmod 4, whose images in Zp×Zp\mathbb{Z}_p \times \mathbb{Z}_p are (ak−1,a−k−1)(a^k - 1, a^{-k} - 1) with aa of order nn), the inverse procedure of the page returns xx from X0,…,XhX_0, \ldots, X_h. Counting a multiplication in KK as 44 multiplications and 22 additions in FF, and an addition in KK as 22 additions in FF, REAL-FFT does nlg⁡n+3n+8n \lg n + 3n + 8 multiplications and 32nlg⁡n+52n+8\frac32 n \lg n + \frac52 n + 8 additions in FF.

Conjugation of a transform. For y∈Fmy \in F^m and ν∈K\nu \in K with νm=1\nu^m = 1 and ννˉ=1\nu \bar\nu = 1, write Yk=∑j<myjνjkY_k = \sum_{j<m} y_j \nu^{jk}. Then νˉ=ν−1\bar\nu = \nu^{-1}, so Yk‾=∑jyjν−jk=∑jyjνj(m−k)=Ym−k\overline{Y_k} = \sum_j y_j \nu^{-jk} = \sum_j y_j \nu^{j(m-k)} = Y_{m-k}, using yˉj=yj\bar y_j = y_j and νjm=1\nu^{jm} = 1. Applied to xx and ω\omega this gives Xn−k=Xk‾X_{n-k} = \overline{X_k}. (1)\quad (1)

The pieces. Let ν=ω2\nu = \omega^2, so νh=1\nu^h = 1 and ννˉ=1\nu \bar\nu = 1, and let ej=x2je_j = x_{2j}, oj=x2j+1o_j = x_{2j+1} for 0≤j<h0 \le j < h, with transforms Ek=∑jejνjkE_k = \sum_j e_j \nu^{jk} and Ok=∑jojνjkO_k = \sum_j o_j \nu^{jk}, defined for all integers kk and of period hh. Splitting the sum for XkX_k by the parity of the index,

Xk=∑jx2jω2jk+∑jx2j+1ω(2j+1)k=Ek+ωkOkfor all k.(2)X_k = \sum_j x_{2j} \omega^{2jk} + \sum_j x_{2j+1} \omega^{(2j+1)k} = E_k + \omega^k O_k \quad\text{for all } k. \tag{2}

Lines L2 to L4. Line L2 sets zj=ej+iojz_j = e_j + i o_j. Line L3 computes Zk=∑jzjνjkZ_k = \sum_j z_j \nu^{jk} for 0≤k<h0 \le k < h: the radix-2 FFT of length hh with root ν\nu is correct when νh/2=−1\nu^{h/2} = -1 for h≥2h \ge 2, which holds since νh/2=ωh=−1\nu^{h/2} = \omega^h = -1 (see the iterative FFT page for its proof). By linearity, Zk=Ek+iOkZ_k = E_k + i O_k. Line L4 extends ZZ by period hh, which is consistent since νjh=1\nu^{jh} = 1.

Lines L6 and L7. By (1) for ee and oo with root ν\nu, Eh−k‾=Ek\overline{E_{h-k}} = E_k and Oh−k‾=Ok\overline{O_{h-k}} = O_k. Hence Zh−k‾=Eh−k‾+iˉ Oh−k‾=Ek−iOk\overline{Z_{h-k}} = \overline{E_{h-k}} + \bar i\, \overline{O_{h-k}} = E_k - i O_k. So Zk+Zh−k‾=2EkZ_k + \overline{Z_{h-k}} = 2 E_k and Zk−Zh−k‾=2iOkZ_k - \overline{Z_{h-k}} = 2i O_k, and since 22 and ii are units, lines L6 and L7 set E=EkE = E_k and O=OkO = O_k, for each 0≤k≤h0 \le k \le h.

Line L8. By (2), E+ωkO=XkE + \omega^k O = X_k. So the returned list is (X0,…,Xh)(X_0, \ldots, X_h). For n=1n = 1 the procedure returns x0=X0x_0 = X_0 directly.

Inverse. Given X0,…,XhX_0, \ldots, X_h of a real xx, (1) gives Xk+h=Xh−k‾X_{k+h} = \overline{X_{h-k}} for 0≤k<h0 \le k < h. By (2) and the period hh of E,OE, O, Xk=Ek+ωkOkX_k = E_k + \omega^k O_k and Xk+h=Ek+ωk+hOk=Ek−ωkOkX_{k+h} = E_k + \omega^{k+h} O_k = E_k - \omega^k O_k. So 12(Xk+Xh−k‾)=Ek\frac12(X_k + \overline{X_{h-k}}) = E_k and 12(Xk−Xh−k‾)ω−k=Ok\frac12 (X_k - \overline{X_{h-k}}) \omega^{-k} = O_k, and the procedure forms Zk=Ek+iOkZ_k = E_k + i O_k, which is the transform of z=e+ioz = e + i o with root ν\nu. The inverse transform of length hh, with ν−1\nu^{-1} and the factor 1/h1/h, returns zz: for 0<k<h0 < k < h, νk−1=ω2k−1\nu^k - 1 = \omega^{2k} - 1 is a unit by hypothesis, so ∑j<hνjk=(νkh−1)/(νk−1)=0\sum_{j<h} \nu^{jk} = (\nu^{kh} - 1)/(\nu^k - 1) = 0, which is the orthogonality the inverse needs, and hh is a unit because 22 is. Writing zj=ej+iojz_j = e_j + i o_j with ej,oj∈Fe_j, o_j \in F, the real and imaginary parts give x2j=ejx_{2j} = e_j and x2j+1=ojx_{2j+1} = o_j, because F⊕Fi=KF \oplus F i = K is a direct sum.

Operation count. The radix-2 FFT of length h=2sh = 2^s does h2s\frac{h}{2} s multiplications and hsh s additions in KK, one multiplication and two additions for each of the h2\frac h2 butterflies of each of the ss stages. With s=lg⁡n−1s = \lg n - 1 and h=n/2h = n/2, this is n4(lg⁡n−1)\frac{n}{4}(\lg n - 1) multiplications and n2(lg⁡n−1)\frac n2 (\lg n - 1) additions in KK, so n(lg⁡n−1)n (\lg n - 1) multiplications and n2(lg⁡n−1)+n(lg⁡n−1)=32n(lg⁡n−1)\frac n2 (\lg n - 1) + n (\lg n - 1) = \frac32 n (\lg n - 1) additions in FF. Each of the h+1h + 1 iterations of lines L5 to L8 does: at L6, one addition in KK (22 in FF) and a scaling by 12\frac12 (22 multiplications in FF); at L7, one addition in KK (22) and a scaling by 12i=−i2\frac{1}{2i} = -\frac{i}{2}, which maps a+bia + bi to b2−a2i\frac b2 - \frac a2 i (22 multiplications); at L8, one multiplication in KK (44 multiplications and 22 additions) and one addition in KK (22). That is 88 multiplications and 88 additions in FF per iteration, 4n+84n + 8 of each in total, since h+1=n2+1h + 1 = \frac n2 + 1. Conjugation is a sign change and is not counted. Adding up, the multiplications number n(lg⁡n−1)+4n+8=nlg⁡n+3n+8n(\lg n - 1) + 4n + 8 = n \lg n + 3n + 8 and the additions 32n(lg⁡n−1)+4n+8=32nlg⁡n+52n+8\frac32 n(\lg n - 1) + 4n + 8 = \frac32 n \lg n + \frac52 n + 8. ■\blacksquare

Back to Real-valued FFT