The point-value operations, barycentric evaluation and divided differences are correct full
This proof shows: correctness.
Let F be a field, n≥1, and U=(u0,…,un−1) distinct points of F. Write Pn for the set of polynomials in F[x] of degree less than n, and evU(f)=(f(u0),…,f(un−1)).
Lemma 1 (interpolation is unique and exists). The map evU:Pn→Fn is a bijection. Its inverse is given by Lagrange's formula L(y)=∑iyiℓi with ℓi=∏j=i(x−uj)/(ui−uj).
Proof. Each ℓi has degree n−1, and ℓi(uk) is 1 for k=i and 0 for k=i, because the factor x−uk vanishes at uk and the denominators are nonzero since the points are distinct. So L(y)∈Pn and evU(L(y))=y; the map is onto. If f,g∈Pn have the same values, then f−g∈Pn has the n distinct roots u0,…,un−1. By the root bound of the factor theorem, a nonzero polynomial of degree less than n has fewer than n roots over a field, so f−g=0; the map is one-to-one. □
Lemma 2 (ADD and MUL). Let y=evU(f) and z=evU(g) with f,g∈Pn. Then ADD(y,z)=evU(f+g), and if degf+degg<n, MUL(y,z)=evU(fg). Without the degree condition, MUL(y,z)=evU(fgmodm) with m=∏i(x−ui).
Proof. Evaluation at ui is a ring homomorphism F[x]→F, so (f+g)(ui)=f(ui)+g(ui)=yi+zi and (fg)(ui)=yizi. The sum f+g is in Pn, so by Lemma 1 it is the polynomial that ADD(y,z) represents. If degf+degg<n then fg∈Pn, and the same argument applies. In general write fg=qm+r with degr<n. Since m(ui)=0, r(ui)=(fg)(ui)=yizi, and r∈Pn, so MUL(y,z) represents r=fgmodm. □
Lemma 3 (EVALUATE-AT). Let wi=1/∏j=i(ui−uj), as computed by lines L1 to L3, and f=L(y). For every t∈F, EVALUATE-AT(y,t)=f(t).
Proof. If t=uk, line L6 returns yk=f(uk). Otherwise t−ui=0 for each i. Let ℓ(t)=∏j(t−uj). For each i,
ℓi(t)=j=i∏ui−ujt−uj=wij=i∏(t−uj)=wit−uiℓ(t). So f(t)=∑iyiℓi(t)=ℓ(t)∑it−uiwiyi, which lines L7 and L8 compute. □
Lemma 4 (divided differences). For 0≤j≤i≤n−1 let pj,i∈F[x] be the polynomial of degree at most i−j with pj,i(ul)=yl for j≤l≤i (it exists and is unique by Lemma 1 for the points uj,…,ui), and let f[uj,…,ui] be the coefficient of xi−j in it. Then f[ui]=yi and, for j<i,
f[uj,…,ui]=ui−ujf[uj+1,…,ui]−f[uj,…,ui−1]. Proof. The constant yi interpolates at the single point ui. For j<i let
q=ui−uj(x−uj)pj+1,i−(x−ui)pj,i−1. Its degree is at most i−j. At uj the first term vanishes, and q(uj)=−(uj−ui)yj/(ui−uj)=yj. At ui the second term vanishes, and q(ui)=(ui−uj)yi/(ui−uj)=yi. At ul with j<l<i, both pj+1,i and pj,i−1 take the value yl, so q(ul)=yl((ul−uj)−(ul−ui))/(ui−uj)=yl. By uniqueness, q=pj,i. The coefficient of xi−j in q is the difference of the coefficients of xi−j−1 in pj+1,i and pj,i−1, divided by ui−uj, which is the recurrence. □
Lemma 5 (line L10). After round k of line L10 (and before round 1, for k=0), d[i]=f[ui−k,…,ui] for i≥k, and d[i]=f[u0,…,ui] for i<k.
Proof. Induction on k. For k=0, d=y and f[ui]=yi. Suppose the claim holds after round k−1. Round k updates d[i] for i=n−1 down to k, in decreasing order, so when d[i] is updated, d[i−1] still holds the value from round k−1. By the hypothesis, the new value is
ui−ui−kf[ui−k+1,…,ui]−f[ui−k,…,ui−1]=f[ui−k,…,ui] by Lemma 4. The entry d[k−1] is not updated in round k and equals f[u0,…,uk−1] from round k−1; the entries below it were final before. □
Lemma 6 (Newton form). Let dk=f[u0,…,uk] and f=L(y). Then
f=k=0∑n−1dkj<k∏(x−uj). Proof. Let Nk=∑l=0kdl∏j<l(x−uj). We show Nk=p0,k by induction. For k=0, N0=y0=p0,0. For k≥1, the polynomial p0,k−p0,k−1 has degree at most k and vanishes at u0,…,uk−1, so by the factor theorem it equals c∏j<k(x−uj) for a constant c. Comparing the coefficients of xk gives c=dk, because p0,k−1 has degree less than k. So p0,k=Nk−1+dk∏j<k(x−uj)=Nk. For k=n−1, p0,n−1=f. □
Lemma 7 (lines L11 to L13). Lines L11 and L12 compute ∑kdk∏j<k(x−uj), and line L13 returns its normalized coefficient list.
Proof. We claim that after the step of line L12 with index i (and after line L11, with i=n−1), c=∑k=in−1dk∏j=ik−1(x−uj). Line L11 sets c=dn−1, the case i=n−1. The step with index i multiplies by (x−ui) and adds di:
(k=i+1∑n−1dkj=i+1∏k−1(x−uj))(x−ui)+di=k=i∑n−1dkj=i∏k−1(x−uj). For i=0 this is the Newton form. Line L13 removes only zero top entries, which does not change the polynomial. □
Theorem. For distinct points U, every list in Fn represents exactly one polynomial in Pn; ADD, MUL (under degf+degg<n), EVALUATE-AT and TO-COEFFICIENTS return the representation, the value, and the normalized coefficient list of the right polynomial.
Proof. Lemma 1 gives the representation, Lemma 2 the pointwise operations, Lemma 3 the evaluation, and Lemmas 5, 6 and 7 give TO-COEFFICIENTS(y) =L(y). ■