Given data points (X[i],F[i]), i=1..N.
Compute Newton divided differences.
F will be over-written by new data.


> NDD := proc(N,X,F)

# NDD := proc(N::integer,X::array,F::array) is better

local i,j;

for j from 2 to N do

for i from N to j by -1 do

     F[i]:=(F[i]-F[i-1])/(X[i]-X[i-j+1]);

   od;

   printf("\n"); for i from 1 to N do printf("%f ",F[i]); od; printf("\n");

  od;

end:

 




> N:=4: X:=array(1..4,[2,4,1,3]): F:=array(1..4,[60,210,24,120]):

NDD(N,X,F);

print(F);

 

60.000000 75.000000 62.000000 48.000000

 

60.000000 75.000000 13.000000 14.000000

 

60.000000 75.000000 13.000000 1.000000

 

[60, 75, 13, 1]

 

 

Arrange the order of data points:

> N:=4: X:=array(1..4,[1,2,3,4]): F:=array(1..4,[24,60,120,210]):

NDD3(N,X,F);

print(F);

 

24.000000 36.000000 60.000000 90.000000

 

24.000000 36.000000 12.000000 15.000000

 

24.000000 36.000000 12.000000 1.000000

 

                           [24, 36, 12, 1]

 

Will these two sets of coefficients result in different polynomials?