Newton's Backward Interpolation in MATLAB

Newton's Backward Interpolation in MATLAB

X=[2 2.1 2.2 2.3];
Y=[1.7314 1.7811 1.8219 1.8535];
x=2.28;  
n=4;   
h=X(2)-X(1);
t=(x-X(n))/h;
y=Y(n);
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 :

>> back.m

d =

    0.0497   -0.0089   -0.0003   45.0000
    0.0408   -0.0092   10.0000         0
    0.0316  -10.0000         0         0

y =

    1.8443


Top