n=input('Enter n- ');
x=zeros(1,n);
fx=zeros(1,n);
for i=1:n
x(i)=input('enter x- ');
fx(i)=input('enter fx- ');
end;
X=input('enter X for which we want fX- ');
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
);
bj1pbnB1dCgnRW50ZXIgbi0gJyk7Cng9emVyb3MoMSxuKTsKZng9emVyb3MoMSxuKTsKZm9yIGk9MTpuCiAgICB4KGkpPWlucHV0KCdlbnRlciB4LSAnKTsKICAgIGZ4KGkpPWlucHV0KCdlbnRlciBmeC0gJyk7CmVuZDsKWD1pbnB1dCgnZW50ZXIgWCBmb3Igd2hpY2ggd2Ugd2FudCBmWC0gJyk7CnRhYmxlPXplcm9zKG4sbik7CnRhYmxlKDosMSk9Zng7CmZvciBqPTI6bgogICAgZm9yIGk9ajpuCiAgICAgICAgdGFibGUoaSxqKT10YWJsZShpLGotMSktdGFibGUoaS0xLGotMSk7CiAgICBlbmQ7CmVuZDsKdT0oWC14KG4pKS8oeCgyKS14KDEpKTsKcmVzdWx0PXRhYmxlKG4sMSk7CmZvciBpPTI6bgogICAgdGVybT0xOwogICAgdGVybT10ZXJtKnRhYmxlKG4saSk7CiAgICB0ZXJtPXRlcm0vZmFjdG9yaWFsKGktMSk7CiAgICB1cz11OwogICAgaWYoaT4yKQogICAgICAgIGZvciBqPTE6aS0yCiAgICAgICAgICAgIHVzPXVzKih1K2opOwogICAgICAgIGVuZDsKICAgIGVuZDsKICAgIHRlcm09dGVybSp1czsKICAgIHJlc3VsdD1yZXN1bHQrdGVybTsKZW5kOwpmcHJpbnRmKCd0aGUgdmFsdWUgb2YgZlggZm9yIFggaXMtICVmJyxyZXN1bHQpOw==