This document presents the numerical analysis of Newton forward and backward difference interpolation methods using MATLAB. It defines the x and y data points, calculates the successive differences between the y values, and uses these differences in Newton's interpolation formula to estimate the y value at an input x value. The forward method estimates y at x=30 while the backward method estimates y at x=90. Both display the interpolated y value and confirm the analysis.
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 ratings0% found this document useful (0 votes)
51 views4 pages
Fa20-Bme-005 (Week1 Matlab)
This document presents the numerical analysis of Newton forward and backward difference interpolation methods using MATLAB. It defines the x and y data points, calculates the successive differences between the y values, and uses these differences in Newton's interpolation formula to estimate the y value at an input x value. The forward method estimates y at x=30 while the backward method estimates y at x=90. Both display the interpolated y value and confirm the analysis.
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
MIRPUR UNIVERSITY OF SCIENCE
AND TECHNOLOGY(MUST)
NUMERICAL ANALYSIS (MATLAB)
NAME: AHSAN FAROOQ
ROLL NO:FA20-BME-005 SECTION:A DEPARTMENT: MECHANICAL ENGINEERING Newton Forward Difference Interpolation Method: x=[20:20:180]; y=[42 63 88 97 109 138 160 181 194]; a=length(x); b=length(y); fprintf(' x y dell squaredell cubedell fourdell fivedell sixdell sevendell eightdell\n') 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]; xj=30; 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; fprintf('%f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\n',[x',y',dell,squaredell,cubedell,fourdell,fivedel l,sixdell,sevendell,eightdell]') h; xo; p; xj; fprintf('the required value of the function is %f\n',yj)
Newton Backward Difference Interpolation Method:
x=[15:15:135]; y=[16 54 78 104 169 233 301 403 690]; a=length(x); b=length(y); fprintf(' x y dell squaredell cubedell fourdell fivedell sixdell sevendell eightdell\n') 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']; xj=90; 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); l=(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+l; fprintf('%f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\n',[x',y',dell,squaredell,cubedell,fourdell,fivedel l,sixdell,sevendell,eightdell]') h; xn; p; xj; fprintf('the required value of the function is %f\n',yj)