0% found this document useful (0 votes)
15 views4 pages

018 (Week1 Matlab)

The document describes the Newton forward and backward difference interpolation methods. It calculates the difference table for given x and y data points. It then uses the difference table to calculate the interpolated y value for a given x value using the Newton interpolation formula involving factorials. The key steps are: 1) Calculate the difference table involving first, second and higher order differences 2) Input the interpolation point xj 3) Use the Newton interpolation formula to calculate the interpolated yj value at xj 4) Display the difference table and interpolated yj value

Uploaded by

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

018 (Week1 Matlab)

The document describes the Newton forward and backward difference interpolation methods. It calculates the difference table for given x and y data points. It then uses the difference table to calculate the interpolated y value for a given x value using the Newton interpolation formula involving factorials. The key steps are: 1) Calculate the difference table involving first, second and higher order differences 2) Input the interpolation point xj 3) Use the Newton interpolation formula to calculate the interpolated yj value at xj 4) Display the difference table and interpolated yj value

Uploaded by

Ahsan Farooq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Newton Forward Difference Interpolation Method:

x=[40:40:360]
y=[98 145 167 189 240 286 388 498 677]
a=length(x)
b=length(y)
for n=1:8
del(1,n)=y(n+1)-y(n);
end
dell=[ del';0]
for m=1:7
squaredel(1,m)=del(m+1)-del(m);
end
squaredell=[squaredel';0;0]
for t=1:6
cubedel(1,t)=squaredel(t+1)-squaredel(t);
end
cubedell=[cubedel';0;0;0]
for u=1:5
fourdel(1,u)=cubedel(u+1)-cubedel(u);
end
fourdell=[fourdel';0;0;0;0]
for v=1:4
fivedel(1,v)=fourdel(v+1)-fourdel(v);
end
fivedell=[fivedel';0;0;0;0;0]
for w=1:3
sixdel(1,w)=fivedel(w+1)-fivedel(w);
end
sixdell=[sixdel';0;0;0;0;0;0]
for i=1:2
sevendel(1,i)=sixdel(i+1)-sixdel(i);
end
sevendell=[sevendel';0;0;0;0;0;0;0]
for j=1:1
eightdel(1,j)=sevendel(j+1)-sevendel(j);
end
eightdell=[eightdel';0;0;0;0;0;0;0;0]

dt=[x' y' dell squaredell cubedell fourdell fivedell sixdell sevendell eightdell]
xj=50
h=x(1,2)-x(1,1);
xo=x(1,1);
p=(xj-xo)/h;
a=(p*dell(1,1));
b=(p*(p-1)*squaredell(1,1))/factorial(2);
c=(p*(p-1)*(p-2)*cubedell(1,1))/factorial(3);
d=(p*(p-1)*(p-2)*(p-3)*fourdell(1,1))/factorial(4);
e=(p*(p-1)*(p-2)*(p-3)*(p-4)*fivedell(1,1))/factorial(5);
f=(p*(p-1)*(p-2)*(p-3)*(p-4)*(p-5)*sixdell(1,1))/factorial(6);
g=(p*(p-1)*(p-2)*(p-3)*(p-4)*(p-5)*(p-6)*sevendell(1,1))/factorial(7);
l=(p*(p-1)*(p-2)*(p-3)*(p-4)*(p-5)*(p-6)*(p-7)*eightdell(1,1))/factorial(8);
yj=y(1,1)+a+b+c+d+e+f+g+l;
disp('the difference table is as under')
dt
h
xo
p
xj
fprintf('the required value of the function is %f\n',yj)

Newton Backward Difference Interpolation Method:


x=[19:19:171]
y=[33 56 98 123 167 197 290 378 478 ]
a=length(x)
b=length(y)
for n=1:8
del(1,n)=y(1+n)-y(n);
end

dell=[0;del']
for m=1:7
squaredel(1,m)=del(1+m)-del(m);
end
squaredell=[0;0;squaredel'];
for o=1:6
cubedel(1,o)=squaredel(1+o)-squaredel(o);
end
cubedell=[0;0;0;cubedel'];
for p=1:5
fourdel(1,p)=cubedel(1+p)-cubedel(p);
end
fourdell=[0;0;0;0;fourdel']
for q=1:4
fivedel(1,q)=fourdel(1+q)-fourdel(q);
end
fivedell=[0;0;0;0;0;fivedel']
for r=1:3
sixdel(1,r)=fivedel(1+r)-fivedel(r)
end
sixdell=[0;0;0;0;0;0;sixdel']
for s=1:2
sevendel(1,s)=sixdel(1+s)-sixdel(s);
end
sevendell=[0;0;0;0;0;0;0;sevendel']
for t=1:1
eightdel(1,t)=sevendel(1+t)-sevendel(t);
end
eightdell=[0;0;0;0;0;0;0;0;eightdel']

dt=[x' y' dell squaredell cubedell fourdell fivedell sixdell sevendell eightdell];
xj=130;
h=x(1,2)-x(1,1);
xn=x(1,9);
p=(xj-xn)/h;
a=(p*dell(9,1));
b=(p*(p+1)*squaredell(9,1))/factorial(2);
c=(p*(p+1)*(p+2)*cubedell(9,1))/factorial(3);
d=(p*(p+1)*(p+2)*(p+3)*fourdell(9,1))/factorial(4);
e=(p*(p+1)*(p+2)*(p+3)*(p+4)*fivedell(9,1))/factorial(5);
f=(p*(p+1)*(p+2)*(p+3)*(p+4)*(p+5)*sixdell(9,1))/factorial(6);
g=(p*(p+1)*(p+2)*(p+3)*(p+4)*(p+5)*(p+6)*sevendell(9,1))/factorial(7);
j=(p*(p+1)*(p+2)*(p+3)*(p+4)*(p+5)*(p+6)*(p+7)*eightdell(9,1))/factorial(8);
yj=y(1,9)+a+b+c+d+e+f+g+j;
disp('the difference table is as under')
dt
h
xn
p
xj
fprintf('the required value of the function is %f\n',yj)

You might also like