Professional Documents
Culture Documents
NSM Practical
NSM Practical
n=length(x);
if(length(x)<>length(y)) then
disp("Not Possible");
abort;
end
h=x(2)-x(1);
p=(xg-x(1))/h;
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
disp("The Values of x",x);
disp("The Values of y",y);
disp("Forward Difference Table",d);
term(1)=p;
for i=2:n-1
term(i)=term(i-1)*(p+1-i);
end
t=0;
for i=1:n-1
t=t+((term(i)*d(1,i))/factorial(i));
end
ye=y(1)+t;
disp("The estimated value of y is",ye);
endfunction
x=[5,10,15,20];
y=[50,70,100,145];
xg=8;
newtonsforward(x, y, xg)
Output
Startup execution:
loading initial environment
The Values of x
The Values of y
20. 10. 5.
30. 15. 0.
45. 0. 0.
61.08