n=input('Enter n-1 ');
x=zeros(1,n);
fx=zeros(1,n);
for i=1:n
x(i)=input('enter x-1 ');
fx(i)=input('enter fx-1 ');
end;
X=input('enter X for which we want fX-1 ');
table=zeros(n,n);
table(:,1)=fx;
for j=2:n
for i=j:n
table(i,j)=table(i,j-1)-table(i-1,j-1);
end;
end;
u=(X-x(n))/(x(2)-x(1));
result=table(n,1);
for i=2:n
term=1;
term=term*table(n,i);
term=term/factorial(i-1);
us=u;
if(i>2)
for j=1:i-2
us=us*(u+j);
end;
end;
term=term*us;
result=result+term;
end;
fprintf('the value of fX for X is- %f',result
);
bj1pbnB1dCgnRW50ZXIgbi0xICcpOwp4PXplcm9zKDEsbik7CmZ4PXplcm9zKDEsbik7CmZvciBpPTE6bgogICAgeChpKT1pbnB1dCgnZW50ZXIgeC0xICcpOwogICAgZngoaSk9aW5wdXQoJ2VudGVyIGZ4LTEgJyk7CmVuZDsKWD1pbnB1dCgnZW50ZXIgWCBmb3Igd2hpY2ggd2Ugd2FudCBmWC0xICcpOwp0YWJsZT16ZXJvcyhuLG4pOwp0YWJsZSg6LDEpPWZ4Owpmb3Igaj0yOm4KICAgIGZvciBpPWo6bgogICAgICAgIHRhYmxlKGksaik9dGFibGUoaSxqLTEpLXRhYmxlKGktMSxqLTEpOwogICAgZW5kOwplbmQ7CnU9KFgteChuKSkvKHgoMikteCgxKSk7CnJlc3VsdD10YWJsZShuLDEpOwpmb3IgaT0yOm4KICAgIHRlcm09MTsKICAgIHRlcm09dGVybSp0YWJsZShuLGkpOwogICAgdGVybT10ZXJtL2ZhY3RvcmlhbChpLTEpOwogICAgdXM9dTsKICAgIGlmKGk+MikKICAgICAgICBmb3Igaj0xOmktMgogICAgICAgICAgICB1cz11cyoodStqKTsKICAgICAgICBlbmQ7CiAgICBlbmQ7CiAgICB0ZXJtPXRlcm0qdXM7CiAgICByZXN1bHQ9cmVzdWx0K3Rlcm07CmVuZDsKZnByaW50ZigndGhlIHZhbHVlIG9mIGZYIGZvciBYIGlzLSAlZicscmVzdWx0KTs=