Algorithm Search⌘K

Proofs: Fast wavelet transform

These are the human proofs of Fast wavelet transform, at full length.

The periodic fast wavelet transform is orthogonal, its transposed cascade inverts it, and its rounding error grows linearly in the number of levels full

This proof shows: correctness, complexity, error-bound.

Let h=(h0,…,hL−1)h = (h_0, \ldots, h_{L-1}) be real with LL even and ∑lhlhl+2s=δs,0\sum_l h_l h_{l + 2s} = \delta_{s,0} for every integer ss, where hl=0h_l = 0 outside 0≤l<L0 \le l < L and δ\delta is the Kronecker delta. Let gl=(−1)lhL−1−lg_l = (-1)^l h_{L-1-l}, also zero outside 0≤l<L0 \le l < L. For an even m≥2m \ge 2, let WmW_m be the m×mm \times m matrix with

(Wm)i,c=∑l : 2i+l≡c (mod m)hl,(Wm)m/2+i,c=∑l : 2i+l≡c (mod m)gl,0≤i<m/2,(W_m)_{i, c} = \sum_{l \,:\, 2i + l \equiv c \ (\mathrm{mod}\ m)} h_l, \qquad (W_m)_{m/2 + i, c} = \sum_{l \,:\, 2i + l \equiv c \ (\mathrm{mod}\ m)} g_l, \qquad 0 \le i < m/2,

so that lines L6 and L7 compute (s,d)=Wma(s, d) = W_m a for the block aa of length mm.

Lemma 1 (filter identities). For every integer ss, ∑lglgl+2s=δs,0\sum_l g_l g_{l+2s} = \delta_{s,0} and ∑lhlgl+2s=0\sum_l h_l g_{l+2s} = 0.

Proof. With r=L−1−lr = L - 1 - l, ∑lglgl+2s=∑l(−1)2l+2shL−1−lhL−1−l−2s=∑rhrhr−2s=δs,0\sum_l g_l g_{l+2s} = \sum_l (-1)^{2l + 2s} h_{L-1-l} h_{L-1-l-2s} = \sum_r h_r h_{r - 2s} = \delta_{s,0}, by the hypothesis with the shift −s-s. Next, P=∑lhlgl+2s=∑l(−1)lhlhL−1−2s−lP = \sum_l h_l g_{l+2s} = \sum_l (-1)^l h_l h_{L-1-2s-l}, using (−1)2s=1(-1)^{2s} = 1. Substitute l′=L−1−2s−ll' = L - 1 - 2s - l: P=∑l′(−1)L−1−2s−l′hL−1−2s−l′hl′=−∑l′(−1)l′hl′hL−1−2s−l′=−PP = \sum_{l'} (-1)^{L-1-2s-l'} h_{L-1-2s-l'} h_{l'} = -\sum_{l'} (-1)^{l'} h_{l'} h_{L-1-2s-l'} = -P, because L−1−2sL - 1 - 2s is odd. So P=0P = 0. □\square

Lemma 2 (periodization). Let p,qp, q be filters with ∑lplql+2s=c δs,0\sum_l p_l q_{l+2s} = c \, \delta_{s,0} for every integer ss, and let mm be even. Then for 0≤i,i′<m/20 \le i, i' < m/2, ∑c=0m−1Pi,cQi′,c=c δi,i′\sum_{c=0}^{m-1} P_{i,c} Q_{i',c} = c \, \delta_{i,i'}, where Pi,c=∑l:2i+l≡cplP_{i,c} = \sum_{l : 2i + l \equiv c} p_l and Qi′,cQ_{i',c} is defined in the same way from qq.

Proof. Expanding, ∑cPi,cQi′,c=∑l,l′plql′[2i+l≡2i′+l′(modm)]\sum_c P_{i,c} Q_{i',c} = \sum_{l, l'} p_l q_{l'} [2i + l \equiv 2i' + l' \pmod m]. The condition says l′=l+2(i−i′)+tml' = l + 2(i - i') + t m for some integer tt, and since mm is even, 2(i−i′)+tm=2σt2(i - i') + tm = 2\sigma_t with σt=i−i′+tm/2\sigma_t = i - i' + tm/2. So the sum is ∑t∑lplql+2σt=c∑tδσt,0\sum_t \sum_l p_l q_{l + 2\sigma_t} = c \sum_t \delta_{\sigma_t, 0}. Since ∣i−i′∣<m/2|i - i'| < m/2, σt=0\sigma_t = 0 holds for at most one tt, namely t=0t = 0 when i=i′i = i', and for no tt when i≠i′i \ne i'. □\square

Theorem 1 (one level). WmW_m is orthogonal for every even m≥2m \ge 2.

Proof. The rows of WmW_m are the periodized shifts of hh (rows i<m/2i < m/2) and of gg (rows m/2+im/2 + i). Lemma 2 with (p,q)=(h,h)(p, q) = (h, h) and c=1c = 1 (the hypothesis), with (g,g)(g, g) and c=1c = 1, and with (h,g)(h, g) and c=0c = 0 (Lemma 1) gives WmWmT=IW_m W_m^{\mathsf T} = I. A square matrix with WWT=IW W^{\mathsf T} = I is orthogonal. □\square

Theorem 2 (forward and inverse). Let nn be divisible by 2J2^J, and let T=(Wn/2J−1⊕I)⋯(Wn/2⊕In/2)WnT = (W_{n/2^{J-1}} \oplus I) \cdots (W_{n/2} \oplus I_{n/2}) W_n, where Wm⊕IW_m \oplus I acts on the first mm entries and fixes the rest. Then FWT(x,h,J)(x, h, J) returns TxT x, TT is orthogonal, and INVERSE-FWT(Tx,h,J)=x(T x, h, J) = x.

Proof. Keep the array z=(a,y[m…n−1])z = (a, y[m \ldots n-1]), the current smooth block followed by the details already stored. Initially (line L3) z=xz = x. A pass of lines L5 to L8 replaces the first mm entries of zz by Wma=(s,d)W_m a = (s, d), storing dd at positions m/2,…,m−1m/2, \ldots, m - 1 and keeping ss as the new smooth block of length m/2m/2; so it multiplies zz by Wm⊕IW_m \oplus I. Each block length m=n/2ℓ−1m = n/2^{\ell - 1} for ℓ≤J\ell \le J is even because 2J∣n2^J \mid n. After JJ passes and line L9, y=Txy = T x. Each factor is orthogonal by Theorem 1, so TT is orthogonal, with T−1=TT=WnT(Wn/2T⊕I)⋯T^{-1} = T^{\mathsf T} = W_n^{\mathsf T} (W_{n/2}^{\mathsf T} \oplus I) \cdots. For the inverse, line L14 computes, for the block (a,d)(a, d) with d=y[m…2m−1]d = y[m \ldots 2m - 1],

bc=∑i<m∑l:2i+l≡c (mod 2m)(hlai+gldi)=∑r<2m(W2m)r,c (a,d)r=(W2mT(a,d))c.b_c = \sum_{i < m} \sum_{l : 2i + l \equiv c \ (\mathrm{mod}\ 2m)} (h_l a_i + g_l d_i) = \sum_{r < 2m} (W_{2m})_{r, c} \, (a, d)_r = \left(W_{2m}^{\mathsf T} (a, d)\right)_c.

So the passes of lines L12 to L15 apply W2mTW_{2m}^{\mathsf T} for 2m=n/2J−1,…,n2m = n/2^{J-1}, \ldots, n, in the reverse order of the forward passes, each to the leading block, while the details still to be used stay in place in yy. This is TTT^{\mathsf T}, so INVERSE-FWT(Tx)=TTTx=x(T x) = T^{\mathsf T} T x = x. With J=0J = 0, T=IT = I and both procedures return their input. □\square

Lemma 3 (counting). For a filter pp of even length LL with ∑lpl2=1\sum_l p_l^2 = 1, an even mm and a vector a∈Rma \in \mathbb{R}^m, ∑i<m/2(∑l∣pl∣ ∣a(2i+l) mod m∣)2≤L2∥a∥22\sum_{i < m/2} \left(\sum_l |p_l| \, |a_{(2i + l) \bmod m}|\right)^2 \le \frac{L}{2} \lVert a \rVert_2^2.

Proof. By the Cauchy-Schwarz inequality the left side is at most ∑i∑la(2i+l) mod m2\sum_i \sum_l a_{(2i+l) \bmod m}^2. For a fixed index rr, the pairs (i,l)(i, l) with 2i+l≡r(modm)2i + l \equiv r \pmod m are, for each ll with l≡r(mod2)l \equiv r \pmod 2, exactly one i∈[0,m/2)i \in [0, m/2), and none for the other ll, because mm is even. There are L/2L/2 such ll, so each ar2a_r^2 appears exactly L/2L/2 times. □\square

Theorem 3 (rounding error). Suppose the stored filter satisfies ∣h^l−hl∣≤μ∣hl∣|\hat h_l - h_l| \le \mu |h_l|, so also ∣g^l−gl∣≤μ∣gl∣|\hat g_l - g_l| \le \mu |g_l|, and each dot product of length LL in lines L6 and L7 is evaluated in floating point with unit roundoff uu and γL=Lu/(1−Lu)\gamma_L = Lu/(1 - Lu). Then the computed y^\hat y satisfies

∥y^−Tx∥2≤JL (μ+γL) ∥x∥2+O(u2).\lVert \hat y - T x \rVert_2 \le J \sqrt L \, (\mu + \gamma_L) \, \lVert x \rVert_2 + O(u^2).

Proof. Let z0=xz_0 = x and let zℓz_\ell be the computed array after the pass ℓ\ell, and write Mℓ=Wmℓ⊕IM_\ell = W_{m_\ell} \oplus I with mℓ=n/2ℓ−1m_\ell = n/2^{\ell-1}. Lines L8 and L9 only copy, so zℓ=Mℓzℓ−1+eℓz_\ell = M_\ell z_{\ell-1} + e_\ell, where eℓe_\ell is zero outside the first mℓm_\ell entries. Write aa for the first mℓm_\ell entries of zℓ−1z_{\ell - 1}. The standard bound for a dot product computed with perturbed coefficients gives, for each output, ∣s^i−si∣≤(μ+γL(1+μ))∑l∣hl∣ ∣a(2i+l) mod mℓ∣|\hat s_i - s_i| \le \left(\mu + \gamma_L (1 + \mu)\right) \sum_l |h_l| \, |a_{(2i+l) \bmod m_\ell}|, and the same with gg for did_i. Since ∑lhl2=∑lgl2=1\sum_l h_l^2 = \sum_l g_l^2 = 1, Lemma 3 for hh and for gg gives ∥eℓ∥22≤(μ+γL)2L∥a∥22+O(u3)\lVert e_\ell \rVert_2^2 \le (\mu + \gamma_L)^2 L \lVert a \rVert_2^2 + O(u^3), so ∥eℓ∥2≤L(μ+γL)∥zℓ−1∥2+O(u2)\lVert e_\ell \rVert_2 \le \sqrt L (\mu + \gamma_L) \lVert z_{\ell-1} \rVert_2 + O(u^2). By induction, using linearity, zJ=MJ⋯M1x+∑ℓ=1JMJ⋯Mℓ+1eℓz_J = M_J \cdots M_1 x + \sum_{\ell=1}^{J} M_J \cdots M_{\ell+1} e_\ell. Each MkM_k is orthogonal by Theorem 1, and ∥zℓ−1∥2=∥x∥2+O(u)\lVert z_{\ell - 1} \rVert_2 = \lVert x \rVert_2 + O(u), so

∥y^−Tx∥2≤∑ℓ=1J∥eℓ∥2≤JL (μ+γL) ∥x∥2+O(u2).□\lVert \hat y - T x \rVert_2 \le \sum_{\ell=1}^{J} \lVert e_\ell \rVert_2 \le J \sqrt L \, (\mu + \gamma_L) \, \lVert x \rVert_2 + O(u^2). \qquad \square

The same argument, with Lemma 3 applied to the transposed sums of line L14 (each output bcb_c is a sum of LL products, L/2L/2 from each filter), gives a bound of the same form for INVERSE-FWT.

Operation count. The pass for the block length mm computes m/2m/2 dot products of length LL with hh and m/2m/2 with gg: LmL m multiplications and (L−1)m(L - 1) m additions. Summing over m=n,n/2,…,n/2J−1m = n, n/2, \ldots, n/2^{J-1} gives Ln(2−21−J)<2LnL n (2 - 2^{1-J}) < 2 L n multiplications and (L−1)n(2−21−J)<2(L−1)n(L - 1) n (2 - 2^{1-J}) < 2 (L - 1) n additions. Line L2 costs nothing but sign changes. The inverse pass for the output length 2m2m does 2Lm2Lm multiplications and 2Lm2Lm additions, so less than 2Ln2 L n of each in total. Both procedures therefore run in Θ(Ln)\Theta(L n) time, independent of JJ. ■\blacksquare

Back to Fast wavelet transform