MIXED-RADIX-FFT computes the DFT of length r_1 ⋯ r_t with n Σ (r_i − 1) additions and at most as many multiplications full
This proof shows: correctness, complexity.
Statement. Let R be a commutative ring, t≥0, r1,…,rt≥2 integers, n=r1⋯rt, and ω∈R with ωn=1. For every x∈Rn, MIXED-RADIX-FFT(x,ω,(r1,…,rt)) returns X with Xk=∑j=0n−1xjωjk for 0≤k<n. It does exactly A(n)=n∑i=1t(ri−1) additions and at most M(n)=n∑i=1t(ri−1) multiplications in R, with equality for M when every ri is prime, besides building the table of powers of ω. If moreover ω is a principal n-th root of unity and n is a unit, running it with ω−1 and dividing by n inverts it.
Lemma 1 (the splitting). Let n=rm, ωn=1, and for 0≤l<r let Yk(l)=∑q=0m−1xrq+l(ωr)qk for 0≤k<m. Then for 0≤k<m and 0≤s<r,
Xk+ms=l=0∑r−1(ωlkYk(l))(ωm)ls. Proof. Every j∈[0,n) is uniquely j=rq+l with 0≤q<m and 0≤l<r (division by r). So
Xk+ms=l=0∑r−1q=0∑m−1xrq+lω(rq+l)(k+ms). Expand the exponent: (rq+l)(k+ms)=rqk+rqms+lk+lms. Here ωrqms=(ωn)qs=1, ωrqk=(ωr)qk and ωlms=(ωm)ls. Factoring out the terms that do not depend on q gives ∑lωlk(ωm)ls∑qxrq+l(ωr)qk, which is the claim. □
Correctness. By induction on t. If t=0 then n=1, line L2 returns x, and X0=x0ω0=x0. Let t≥1, r=r1, m=n/r=r2⋯rt. Since (ωr)m=ωn=1, the induction hypothesis for the t−1 radices (r2,…,rt) shows that line L5 sets Y(l) to the DFT of length m with root ωr of the subsequence (xrq+l)q, which is the Y(l) of Lemma 1. For fixed k, line L7 sets tl=ωlkYk(l), and line L9 sets Xk+ms=t0+∑l≥1ωmlstl=∑l(ωm)lstl, because (ωm)0⋅s=1. By Lemma 1 this is the correct value. The map (k,s)↦k+ms from [0,m)×[0,r) to [0,n) is a bijection (division by m), so every output is written exactly once, by the loops at lines L6 and L8. So the returned vector is X.
Inverse. If ω is a principal n-th root of unity, so is ω−1, and ω−n=1, so the program with ω−1 returns Zj=∑kXkω−jk=∑ixi∑kω(i−j)k=nxj, since the inner sum is n for i=j and 0 otherwise by principality. Dividing by the unit n gives x.
Operation count. Let At and Mt be the counts for t radices, as functions of the radices. For t=0 both are 0. For t≥1, line L5 makes r calls of length m, costing rAt−1(r2,…,rt) additions. Lines L6 to L9 run for m values of k; for each, line L7 does r−1 multiplications (t0 needs none), and line L9 does, for each of the r values of s, exactly r−1 additions and one multiplication for each l≥1 with ls≡0(modr), as in the implementation, which uses the table entry ωm(lsmodr) and skips the factor 1. That is r(r−1) additions and at most (r−1)2 multiplications per k (the pairs l,s≥1), with equality when r is prime, since then ls≡0 for 1≤l,s<r. So the stage costs exactly m⋅r(r−1)=n(r−1) additions and at most m((r−1)+(r−1)2)=mr(r−1)=n(r−1) multiplications. Hence
At=n(r1−1)+r1At−1(r2,…,rt)withAt−1(r2,…,rt)=mi≥2∑(ri−1) by induction, so At=n(r1−1)+r1m∑i≥2(ri−1)=n∑i=1t(ri−1). The same computation with inequalities gives Mt≤n∑i(ri−1), with equality when every ri is prime.
Time and space. The index arithmetic per counted operation is O(1), and each call does O(r) work besides its stage, so the time is Θ(At+Mt+number of calls). The calls at level i number n/ni≤n, with ni=ri⋯rt, and t≤lgn, so the time is Θ(n∑iri), since n(ri−1)≥nri/2. The recursion holds at most one partial result per level along the current path, of total size ∑ini≤2n, plus the table of n powers, so the extra space is Θ(n). ■