Newton's Forward Interpolation in MATLAB

Newton's Forward Interpolation in MATLAB


X=[10 20 30 40 50];
Y=[600 512 439 346 243];
x=12;  
n=5;   
h=X(2)-X(1);
t=(x-X(1))/h;
y=Y(1);
for i=1:n-1
    d(i,1)=Y(i+1)-Y(i);
end
for j=2:n-1
    for i=1:n-j
        d(i,j)=d(i+1,j-1)-d(i,j-1)
    end
end
s=1;q=1;
for k=1:n-1
    s=s*(t-k+1);
    q=q*k;
    y=y+(s/q)*d(1,k);
end
y



Output :

>> forw.m

d =

   -88    15   -35    45
   -73   -20    10     0
   -93   -10     0     0
  -103     0     0     0


y =

  578.0080

Top