Algorithm Search⌘K

Proofs: Estrin's scheme

These are the human proofs of Estrin's scheme, at full length.

ESTRIN returns f(x) with n additions, n + ceil(log2(n + 1)) - 1 multiplications and depth at most 2 ceil(log2(n + 1)) full

This proof shows: correctness.

Let RR be a commutative ring, a=[a0,…,an]a = [a_0, \ldots, a_n] with n≥0n \ge 0, f=∑k=0nakxkf = \sum_{k=0}^{n} a_k x^k, and fix the point x∈Rx \in R. Write ℓk\ell_k for the length of the list cc at the start of the kk-th pass through line L3 (counting from k=0k = 0), and pkp_k for the value of pp then.

Lemma 1 (one round). Let c=[c0,…,cℓ−1]c = [c_0, \ldots, c_{\ell - 1}] with ℓ≥2\ell \ge 2, let p∈Rp \in R, and let c′c' be the list built by lines L4 and L5. Then ∑ici′(p2)i=∑icipi\sum_{i} c'_i (p^2)^i = \sum_i c_i p^i, and c′c' has ⌈ℓ/2⌉\lceil \ell/2 \rceil entries.

Proof. For 0≤i<⌊ℓ/2⌋0 \le i < \lfloor \ell/2 \rfloor, ci′=c2i+c2i+1pc'_i = c_{2i} + c_{2i+1} p, and ci′(p2)i=c2ip2i+c2i+1p2i+1c'_i (p^2)^i = c_{2i} p^{2i} + c_{2i+1} p^{2i+1}. If ℓ\ell is odd, the last entry is c(ℓ−1)/2′=cℓ−1c'_{(\ell-1)/2} = c_{\ell - 1}, and cℓ−1(p2)(ℓ−1)/2=cℓ−1pℓ−1c_{\ell-1} (p^2)^{(\ell-1)/2} = c_{\ell - 1} p^{\ell - 1}. Every index of cc appears in exactly one of these terms, so the sums agree. The count is ⌊ℓ/2⌋\lfloor \ell/2 \rfloor, plus 11 if ℓ\ell is odd, which is ⌈ℓ/2⌉\lceil \ell/2 \rceil. □\square

Theorem (correctness). ESTRIN(a,x)(a, x) returns f(x)f(x).

Proof. We show that at the start of each pass through line L3, ∑icipi=f(x)\sum_i c_i p^i = f(x). At the first pass, c=ac = a and p=xp = x by lines L1 and L2, so the sum is f(x)f(x). If the loop body runs, then cc has ℓ≥2\ell \ge 2 entries, and by Lemma 1 the new list c′c' satisfies ∑ici′(p2)i=f(x)\sum_i c'_i (p^2)^i = f(x). Line L6 sets c←c′c \leftarrow c'. If c′c' has more than one entry, line L7 sets p←p2p \leftarrow p^2 and the invariant holds. If c′c' has one entry, pp is not updated, but then ∑ici′qi=c0′\sum_i c'_i q^i = c'_0 for every qq, so the invariant holds as well. The length goes from ℓ\ell to ⌈ℓ/2⌉<ℓ\lceil \ell/2 \rceil < \ell for ℓ≥2\ell \ge 2, so the loop ends, with one entry c0=∑icipi=f(x)c_0 = \sum_i c_i p^i = f(x), which line L8 returns. For an empty list the implementation returns 0=f(x)0 = f(x). □\square

Theorem (cost). For n≥1n \ge 1, let L=⌈log⁡2(n+1)⌉L = \lceil \log_2(n + 1) \rceil. ESTRIN uses exactly nn additions and n+L−1n + L - 1 multiplications, and its depth, the longest chain of operations each of which uses the result of the one before, is at most 2L2L.

Proof. Rounds. We have ℓ0=n+1\ell_0 = n + 1 and ℓk+1=⌈ℓk/2⌉\ell_{k+1} = \lceil \ell_k / 2 \rceil. By induction, ℓk=⌈(n+1)/2k⌉\ell_k = \lceil (n + 1)/2^k \rceil, because ⌈⌈m/2k⌉/2⌉=⌈m/2k+1⌉\lceil \lceil m/2^k \rceil / 2 \rceil = \lceil m / 2^{k+1} \rceil for positive integers mm. So ℓk=1\ell_k = 1 exactly when 2k≥n+12^k \ge n + 1, that is k≥Lk \ge L, and the loop body runs LL times.

Additions and multiplications in line L4. A round on a list of length ℓ\ell does ⌊ℓ/2⌋=ℓ−⌈ℓ/2⌉\lfloor \ell/2 \rfloor = \ell - \lceil \ell/2 \rceil additions and as many multiplications. Summed over the rounds this telescopes to ℓ0−ℓL=(n+1)−1=n\ell_0 - \ell_L = (n + 1) - 1 = n.

Squarings. Line L7 squares after each round except the last, where the new list has one entry: L−1L - 1 squarings.

Depth. Let δk\delta_k be the largest depth of an entry of cc at the start of round kk, and let πk\pi_k be the depth of pkp_k. Then δ0=0\delta_0 = 0 and π0=0\pi_0 = 0, since the inputs have depth 00. Line L7 gives πk+1=πk+1\pi_{k+1} = \pi_k + 1, so πk=k\pi_k = k. Line L4 gives δk+1≤max⁡(δk,πk)+2=max⁡(δk+2,k+2)\delta_{k+1} \le \max(\delta_k, \pi_k) + 2 = \max(\delta_k + 2, k + 2), since an entry c2i+c2i+1pc_{2i} + c_{2i+1} p needs one multiplication after c2i+1c_{2i+1} and pp are known, and one addition after that. By induction, δk≤2k\delta_k \le 2k: it holds for k=0k = 0, and δk+1≤max⁡(2k+2,k+2)=2(k+1)\delta_{k+1} \le \max(2k + 2, k + 2) = 2(k + 1). After LL rounds the depth of the result is at most 2L2L. ■\blacksquare

Back to Estrin's scheme