Polynomial Multipoint Evaluation and Fast Interpolation

Multipoint Evaluation of a Polynomial

Description

Given a polynomial f(x)f\left(x\right) and nn points x1,x2,…,xnx_{1},x_{2},\dots,x_{n}, compute

f(x1),f(x2),…,f(xn)f\left(x_{1}\right),f\left(x_{2}\right),\dots,f\left(x_{n}\right)

Solution

Consider using divide and conquer to halve the size of the problem.

Split the given points into two parts:

X0={x1,x2,…,x⌊n2⌋}X1={x⌊n2⌋+1,x⌊n2⌋+2,…,xn}\begin{aligned} X_{0}&=\left\{x_{1},x_{2},\dots,x_{\left\lfloor\frac{n}{2}\right\rfloor}\right\}\\ X_{1}&=\left\{x_{\left\lfloor\frac{n}{2}\right\rfloor+1},x_{\left\lfloor\frac{n}{2}\right\rfloor+2},\dots,x_{n}\right\} \end{aligned}

Construct the polynomial

g0(x)=∏xi∈X0(x−xi)g_{0}\left(x\right)=\prod_{x_{i}\in X_{0}}\left(x-x_{i}\right)

Then ∀x∈X0:g0(x)=0\forall x\in X_{0}:g_{0}\left(x\right)=0.

Consider expressing f(x)f\left(x\right) in the form g0(x)Q(x)+f0(x)g_{0}\left(x\right)Q\left(x\right)+f_{0}\left(x\right), namely:

f0(x)≡f(x)(modg0(x))f_{0}\left(x\right)\equiv f\left(x\right)\pmod{g_{0}\left(x\right)}

Then ∀x∈X0:f(x)=g0(x)Q(x)+f0(x)=f0(x)\forall x\in X_{0}:f\left(x\right)=g_{0}\left(x\right)Q\left(x\right)+f_{0}\left(x\right)=f_{0}\left(x\right); the same holds for X1X_{1}.

The problem size has now been halved, so it can be solved with divide and conquer plus polynomial modulo.

The time complexity is

T(n)=2T(n2)+O(nlog⁡n)=O(nlog⁡2n)T\left(n\right)=2T\left(\frac{n}{2}\right)+O\left(n\log{n}\right)=O\left(n\log^{2}{n}\right)

Fast polynomial interpolation

Description

Given a set of n+1n+1 points

X={(x0,y0),(x1,y1),…,(xn,yn)}X=\left\{\left(x_{0},y_{0}\right),\left(x_{1},y_{1}\right),\dots,\left(x_{n},y_{n}\right)\right\}

find an nn-degree polynomial f(x)f\left(x\right) satisfying ∀(x,y)∈X:f(x)=y\forall\left(x,y\right)\in X:f\left(x\right)=y.

Solution

Consider the Lagrange interpolation formula

f(x)=∑i=1n∏j≠ix−xjxi−xjyif(x) = \sum_{i=1}^{n} \prod_{j\neq i }\frac{x-x_j}{x_i-x_j} y_i

Let M(x)=∏i=1n(x−xi)M(x) = \prod_{i=1}^n (x - x_i). By l'Hôpital's rule,

∏j≠i(xi−xj)=lim⁡x→xi∏j=1n(x−xj)x−xi=M′(xi)\prod_{j\neq i} (x_i - x_j) = \lim_{x\rightarrow x_i} \frac{\prod_{j=1}^n (x - x_j)}{x - x_i} = M'(x_i)

Therefore, the polynomial can be written as

f(x)=∑i=1nyiM′(xi)∏j≠i(x−xj)f(x) = \sum_{i = 1}^n \frac{y_i}{M'(x_i)}\prod_{j \neq i}(x - x_j)

We first use divide and conquer to compute the coefficient representation of M(x)M(x), then use multipoint evaluation to compute every M′(xi)M'(x_i) in O(nlog⁡2n)O(n\log^2 n) time.

Let vi=yiM′(xi)v_i = \frac{y_i}{M'(x_i)}. We now compute f(x)f(x). For n=1n = 1, we have f(x)=v1,M(x)=x−x1f(x) = v_1, M(x) = x - x_1. Otherwise, let

f0(x)=∑i=1⌊n2⌋vi∏j≠i∧j≤⌊n2⌋(x−xj)M0(x)=∏i=1⌊n2⌋(x−xi)f1(x)=∑i=⌊n2⌋+1nvi∏j≠i∧⌊n2⌋<j≤n(x−xj)M1(x)=∏i=⌊n2⌋+1n(x−xi)\begin{aligned} f_0(x) & = \sum_{i = 1}^{\left\lfloor \frac n2 \right \rfloor} v_i\prod_{j \neq i \wedge j \le \left\lfloor \frac n2 \right \rfloor}(x - x_j)\\ M_0(x) & = \prod_{i = 1}^{\left\lfloor \frac n2 \right \rfloor} (x - x_i)\\ f_1(x) & = \sum_{i = \left\lfloor \frac n2 \right \rfloor+1}^n v_i\prod_{j \neq i \wedge \left\lfloor \frac n2 \right \rfloor < j \le n}(x - x_j) \\ M_1(x) & = \prod_{i = \left\lfloor \frac n2 \right \rfloor+1}^n (x - x_i) \end{aligned}

Then f(x)=f0(x)M1(x)+f1(x)M0(x),M(x)=M0(x)M1(x)f(x) = f_0(x)M_1(x) + f_1(x)M_0(x), M(x) = M_0(x)M_1(x), so divide and conquer can be used. The complexity of this part is also O(nlog⁡2n)O(n\log^2 n).