Algorithm Search⌘K

Proofs: Fast multipoint evaluation

These are the human proofs of Fast multipoint evaluation, at full length.

FAST-MULTIPOINT-EVAL returns f(u_0), ..., f(u_{n-1}) in O(M(n) log n) operations full

This proof shows: correctness.

Let RR be a commutative ring with 11, f∈R[x]f \in R[x], n≥1n \ge 1, and u0,…,un−1∈Ru_0, \ldots, u_{n-1} \in R. For a node (j,k)(j, k) of the subproduct tree, let Sj,kS_{j,k} be the set of indices ii of the leaves below it, so that mj,k=∏i∈Sj,k(x−ui)m_{j,k} = \prod_{i \in S_{j,k}} (x - u_i).

Lemma 1 (the tree). For each level jj, the sets Sj,0,Sj,1,…S_{j,0}, S_{j,1}, \ldots are consecutive blocks that partition {0,…,n−1}\{0, \ldots, n-1\} in order. For each node, mj,k=∏i∈Sj,k(x−ui)m_{j,k} = \prod_{i \in S_{j,k}} (x - u_i) is monic of degree ∣Sj,k∣|S_{j,k}|. If j≥1j \ge 1, then Sj,k=Sj−1,2k∪Sj−1,2k+1S_{j,k} = S_{j-1,2k} \cup S_{j-1,2k+1}, where the second set is empty if node 2k+12k + 1 does not exist at level j−1j - 1. The top level h=⌈log⁡2n⌉h = \lceil \log_2 n \rceil has one node, with Sh,0={0,…,n−1}S_{h,0} = \{0, \ldots, n - 1\}.

Proof. At level 00 the blocks are the single indices, and m0,i=x−uim_{0,i} = x - u_i. If the claim holds at level j−1j - 1 with cc nodes, then level jj has ⌈c/2⌉\lceil c/2 \rceil nodes, node kk is the product of nodes 2k2k and 2k+12k + 1, or a copy of node 2k2k if 2k+1=c2k + 1 = c, and the union of two consecutive blocks is a block. A product of monic polynomials is monic and its degree is the sum of the degrees. The number of nodes ⌈n/2j⌉\lceil n / 2^j \rceil is 11 exactly when j≥⌈log⁡2n⌉j \ge \lceil \log_2 n \rceil. □\square

Lemma 2 (remainders keep values). Let mm be monic, let g∈R[x]g \in R[x], and let u∈Ru \in R with m(u)=0m(u) = 0. Then (g mod m)(u)=g(u)(g \bmod m)(u) = g(u).

Proof. Division by a monic polynomial is defined over any commutative ring: g=qm+(g mod m)g = qm + (g \bmod m). Evaluation at uu is a ring homomorphism, so g(u)=q(u)m(u)+(g mod m)(u)=(g mod m)(u)g(u) = q(u) m(u) + (g \bmod m)(u) = (g \bmod m)(u). □\square

Theorem (correctness). FAST-MULTIPOINT-EVAL returns the list f(u0),…,f(un−1)f(u_0), \ldots, f(u_{n-1}).

Proof. If n=0n = 0, line L1 returns the empty list. Let n≥1n \ge 1. We show by downward induction on jj the invariant: after the remainders for level jj are computed, the list rr has one entry rj,kr_{j,k} per node of level jj, with deg⁡rj,k<deg⁡mj,k\deg r_{j,k} < \deg m_{j,k} and rj,k(ui)=f(ui)r_{j,k}(u_i) = f(u_i) for all i∈Sj,ki \in S_{j,k}.

Level hh. Line L3 sets rh,0=f mod mh,0r_{h,0} = f \bmod m_{h,0}, which has degree less than deg⁡mh,0=n\deg m_{h,0} = n. Each uiu_i is a root of mh,0m_{h,0}, so rh,0(ui)=f(ui)r_{h,0}(u_i) = f(u_i) by Lemma 2.

From level j+1j + 1 to level jj. Line L7 sets rj,k=rj+1,⌊k/2⌋ mod mj,kr_{j,k} = r_{j+1,\lfloor k/2 \rfloor} \bmod m_{j,k}, which has degree less than deg⁡mj,k\deg m_{j,k}. By Lemma 1, Sj,k⊆Sj+1,⌊k/2⌋S_{j,k} \subseteq S_{j+1, \lfloor k/2 \rfloor}. For i∈Sj,ki \in S_{j,k}, uiu_i is a root of mj,km_{j,k}, so by Lemma 2 and the invariant at level j+1j + 1, rj,k(ui)=rj+1,⌊k/2⌋(ui)=f(ui)r_{j,k}(u_i) = r_{j+1,\lfloor k/2 \rfloor}(u_i) = f(u_i).

Level 00. Node kk is x−ukx - u_k with S0,k={k}S_{0,k} = \{k\}, and r0,kr_{0,k} has degree less than 11, so it is a constant cc (the zero polynomial gives c=0c = 0). By the invariant, c=r0,k(uk)=f(uk)c = r_{0,k}(u_k) = f(u_k). Line L9 returns these constants in the order of the leaves, which is the order of the points. □\square

Theorem (cost). Assume that multiplying a polynomial with aa coefficients by one with at most aa coefficients costs at most M(a)M(a) ring operations, that M(a)/aM(a)/a is nondecreasing, and that M(2a)≤4M(a)M(2a) \le 4M(a). If deg⁡f<n\deg f < n, then FAST-MULTIPOINT-EVAL uses at most 11M(n)⌈log⁡2n⌉+O(nlog⁡n)11 M(n) \lceil \log_2 n \rceil + O(n \log n) ring operations.

Proof. From M(a)/aM(a)/a nondecreasing, MM is nondecreasing and superadditive: M(a)+M(b)≤M(a+b)M(a) + M(b) \le M(a + b), because M(a)≤aa+bM(a+b)M(a) \le \frac{a}{a+b} M(a+b) and M(b)≤ba+bM(a+b)M(b) \le \frac{b}{a+b} M(a+b). Hence ∑vM(av)≤M(∑vav)\sum_v M(a_v) \le M(\sum_v a_v) for any finite family.

The tree. A node vv of level j≥1j \ge 1 with Dv=deg⁡mvD_v = \deg m_v that is a product costs at most M(Dv+1)M(D_v + 1), since both factors have at most Dv+1D_v + 1 coefficients. A node that is copied costs nothing. At level j≥1j \ge 1 there are ⌈n/2j⌉≤n\lceil n/2^j \rceil \le n nodes, and ∑vDv=n\sum_v D_v = n by Lemma 1, so ∑v(Dv+1)≤2n\sum_v (D_v + 1) \le 2n and the level costs at most M(2n)≤4M(n)M(2n) \le 4M(n). There are h=⌈log⁡2n⌉h = \lceil \log_2 n \rceil levels above the leaves.

The descent. At line L3, deg⁡f<n=deg⁡mh,0\deg f < n = \deg m_{h,0}, so f mod mh,0=ff \bmod m_{h,0} = f costs O(n)O(n). Consider a node vv of level j+1j + 1 with deg⁡mv=D\deg m_v = D and the remainder rvr_v of degree less than DD. If vv is a copy of one child, that child's remainder is rvr_v itself, because deg⁡rv<D\deg r_v < D and the child is mvm_v; this costs O(D)O(D). Otherwise its children have degrees d1+d2=Dd_1 + d_2 = D with d1,d2≥1d_1, d_2 \ge 1. Dividing rvr_v by the child of degree d1d_1 is either trivial, if deg⁡rv<d1\deg r_v < d_1, or a division with a quotient of k=deg⁡rv−d1+1≤d2k = \deg r_v - d_1 + 1 \le d_2 coefficients. By the cost theorem for fast division, it costs at most 4M(k)+M(d1)+2⌈log⁡2k⌉M(k)/k+O(D)4M(k) + M(d_1) + 2\lceil \log_2 k \rceil M(k)/k + O(D). Since 2⌈log⁡2k⌉≤2k2 \lceil \log_2 k \rceil \le 2k for k≥1k \ge 1 and MM is nondecreasing, this is at most 6M(d2)+M(d1)+O(D)6M(d_2) + M(d_1) + O(D). In the same way, the other child costs at most 6M(d1)+M(d2)+O(D)6M(d_1) + M(d_2) + O(D). Together, 7(M(d1)+M(d2))+O(D)≤7M(D)+O(D)7(M(d_1) + M(d_2)) + O(D) \le 7M(D) + O(D). Summing over the nodes of level j+1j + 1, whose degrees sum to nn, a level of the descent costs at most 7M(n)+O(n)7M(n) + O(n). Line L9 costs O(n)O(n).

Adding 4M(n)+7M(n)+O(n)4M(n) + 7M(n) + O(n) over h=⌈log⁡2n⌉h = \lceil \log_2 n \rceil levels gives the bound. ■\blacksquare

Back to Fast multipoint evaluation