0% found this document useful (0 votes)
19 views2 pages

Newton's Forward Difference Method

This MATLAB function uses Newton's forward difference formula to estimate the value of a function y at a given x value xg, by taking the x and y value pairs as inputs and calculating the forward difference table, then estimating yg as the sum of y1 plus the weighted differences. It displays the input x and y values, the calculated forward difference table, and estimated yg value.

Uploaded by

CHAVAN AJAY
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ZIP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Newton's Forward Difference Method

This MATLAB function uses Newton's forward difference formula to estimate the value of a function y at a given x value xg, by taking the x and y value pairs as inputs and calculating the forward difference table, then estimating yg as the sum of y1 plus the weighted differences. It displays the input x and y values, the calculated forward difference table, and estimated yg value.

Uploaded by

CHAVAN AJAY
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ZIP, PDF, TXT or read online on Scribd

function newtonsforward(x, y, xg)

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

--> exec('/Users/ajaymahadevchavan/practica;[Link]', -1)

5. 10. 15. 20.

The Values of x

50. 70. 100. 145.

The Values of y

20. 10. 5.
30. 15. 0.
45. 0. 0.

Forward Difference Table

61.08

The estimated value of y is

You might also like