These are the human proofs of Fast Hartley transform, at full length.
The radix-2 fast Hartley transform computes the DHT, is its own inverse up to 1/n, and has a first-order error bound linear in lg n full
This proof shows: correctness, complexity, error-bound.
Let n=2t, let x∈Rn be the input and x′ the array as the algorithm changes it. For a vector y of length N, write DHTN(y)k=∑mymcas(2πmk/N), with indices of DHTN(y) taken modulo N. As in the proof for the FFT, for h=2q and h∣s let c(s,h)=revt−q(s/h) and let x(s,h) be the subsequence xm(s,h)=xc(s,h)+mn/h, 0≤m<h.
Lemma 1 (cas of a sum).cas(a+b)=cosbcasa+sinbcas(−a).
Proof.cos(a+b)+sin(a+b)=cosacosb−sinasinb+sinacosb+cosasinb=cosb(cosa+sina)+sinb(cosa−sina), and cosa−sina=cas(−a). □
Lemma 2 (merge). Let N=2h, y∈RN, and let E and O be the DHTs of length h of (y0,y2,…) and (y1,y3,…). Put θk=2πk/N. Then for 0≤k<h,
Proof. Split the sum by the parity of the index. For any integer k′, the even part is ∑my2mcas(2πmk′/h)=Ek′, and the odd part is ∑my2m+1cas(2πmk′/h+θk′), which by Lemma 1 equals cosθk′Ok′+sinθk′∑my2m+1cas(−2πmk′/h)=cosθk′Ok′+sinθk′O−k′. For k′=k this is the first formula. For k′=k+h, E and O have period h, and θk+h=θk+π flips the signs of cos and sin, which gives the second formula. □
Lemma 3 (the four-point butterfly). For 1≤k<h/2, lines L10 to L13 store the four values of Lemma 2 for the indices k, k+h, h−k and 2h−k of a block, and lines L6 and L7 store those for k=0, h, h/2 and 3h/2.
Proof. In line L9, c=cosθk and σ=sinθk with θk=πk/h. Line L10 reads a=Ok and b=Oh−k and sets t1=cosθkOk+sinθkOh−k. Since θh−k=π−θk, cosθh−k=−c and sinθh−k=σ, so the odd term of Lemma 2 for the index h−k is −cOh−k+σOk=t2. Line L11 saves Ek and Eh−k, and lines L12 and L13 store Ek±t1 and Eh−k±t2 at the places k, k+h, h−k, 2h−k, which are the values of Lemma 2. The four cells read are the four cells written, and the sets {k,h−k} for 1≤k<h/2 are disjoint from each other and from {0,h/2}, so no value is overwritten before it is read. For k=0, θ0=0 and Oh=O0, giving E0±O0 (line L6); for k=h/2, θ=π/2 and Oh−h/2=Oh/2, giving Eh/2±Oh/2 (line L7). For h=1 only k=0 occurs, and for h=2 only k=0 and k=1=h/2. □
Theorem 1 (forward). FHT(x) replaces x by DHTn(x).
Proof. The invariant is: when line L4 tests h=2q, for every block start s with h∣s, x′[s…s+h−1]=DHTh(x(s,h)). After line L2, x′[j]=xrevt(j)=x0(j,1), and a DHT of length 1 is the identity, so the invariant holds for h=1. If it holds for h<n, take a block start s with 2h∣s. By Lemma 2 of the FFT proof (which concerns only the indices), x(s,h) and x(s+h,h) are the even and the odd entries of x(s,2h), so the two halves of the block hold E and O for y=x(s,2h). By Lemma 3, one pass of lines L6 to L13 writes DHT2h(y) into the block, and different blocks are disjoint. After line L14 the invariant holds for 2h. When h=n, the only block is s=0 with x(0,n)=x. □
Theorem 2 (inverse).Hn2=nI, so INVERSE-FHT(DHTn(x))=x.
Proof.(Hn2)jl=∑kcasαkcasβk with αk=2πjk/n and βk=2πlk/n. Expanding, casacasb=cosacosb+sinasinb+sinacosb+cosasinb=cos(a−b)+sin(a+b). Now ∑kcos(2π(j−l)k/n)+i∑ksin(2π(j−l)k/n)=∑ke2πi(j−l)k/n, which is n if j≡l and 0 otherwise, by the summation lemma; so ∑kcos(αk−βk)=n[j=l]. Similarly ∑ksin(2π(j+l)k/n) is the imaginary part of a sum that is real (n or 0), so it is 0. Hence Hn2=nI. By Theorem 1, line L15 computes HnHnx=nx, and line L16 divides by n. □
Operation count. For h=1, each of the n/2 blocks does line L6 only: 2 additions. For h≥2, each of the n/(2h) blocks does lines L6 and L7 (4 additions) and h/2−1 butterflies of lines L10 to L13, each with 4 multiplications and 2+4=6 additions. So the pass for h≥2 costs 2hn(2h−4)=n−h2n multiplications and 2hn(3h−2)=23n−hn additions. Summing over h=2q, 1≤q≤t−1, with ∑q=1t−12−q=1−21−t, the total for n≥2 is
Theorem 3 (rounding error). Suppose the computed pair (c^,σ^) in line L9 satisfies (c^−c)2+(σ^−σ)2≤μ, and let u be the unit roundoff and γ2=2u/(1−2u). Then the computed H^ satisfies ∥H^−H∥2≤lgnη∥H∥2+O(u2), with η=u+2(μ+γ2).
Proof. Write the pass for h as a matrix Sq (h=2q−1) acting on the whole array. On a block it maps (E,O) to (E+RO,E−RO), where R fixes O0 and Oh/2 and maps each pair (Ok,Oh−k), 1≤k<h/2, by the matrix with rows (c,σ) and (σ,−c), a reflection. So R is orthogonal, and SqTSq=2I block by block: Sq=2Qq with Qq orthogonal.
Local error of one pass. Let z be the computed array before the pass. For a butterfly with a=Ok, b=Oh−k, the computed t^1=fl(c^a+σ^b) satisfies ∣t^1−t1∣≤∣(c^−c)a+(σ^−σ)b∣+γ2(∣c^a∣+∣σ^b∣)≤(μ+γ2)a2+b2+O(u2) by the Cauchy-Schwarz inequality, and the same holds for t^2. So the errors τ of all the t values of a block satisfy ∑τ2≤2(μ+γ2)2∥O∥22+O(u3). Each τ enters two outputs, e±t^, and each output addition adds a relative error at most u. Hence the error of the pass is eq with
using ∥Sqz∥2=2∥z∥2. Lines L6 and L7 contribute only the term with u.
Accumulation. Line L2 is exact. With z0 the permuted input and zq=Sqzq−1+eq, linearity gives zt=St⋯S1z0+∑q=1tSt⋯Sq+1eq. Since ∥St⋯Sq+1w∥2=2(t−q)/2∥w∥2 and ∥Sqzq−1∥2=2q/2∥x∥2(1+O(u)), each term has norm at most η2t/2∥x∥2+O(u2)=η∥H∥2+O(u2), because ∥H∥2=n∥x∥2 by Theorem 2. Summing t=lgn terms gives the bound. ■