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

Newtons Interpolation

This document describes Newton's interpolation method to calculate the value of a function at a given point using forward and backward difference tables. It takes user input for data points and their corresponding values, and the point to calculate the value. It then constructs the appropriate difference table based on whether the point is before or after the midpoint. The value is calculated by summing the differences multiplied by coefficients moving down the table.

Uploaded by

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

Newtons Interpolation

This document describes Newton's interpolation method to calculate the value of a function at a given point using forward and backward difference tables. It takes user input for data points and their corresponding values, and the point to calculate the value. It then constructs the appropriate difference table based on whether the point is before or after the midpoint. The value is calculated by summing the differences multiplied by coefficients moving down the table.

Uploaded by

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

% Newton's Interpolation

clc;
clear all;
X = input('Enter the data points--');
Y = input('Enter the values of corresponding values--');
Xr = input('Enter the point at which value is to be calculated--');
z = size(X);
n = z(2);
T=Y;
K=Y;
Q= (X(1,1)+X(1,n))/2


if Xr<Q

%Forward Difference Table


for i=2:n
for j=1:n+1-i
T(i,j)= T(i-1,j+1) - T(i-1,j);
end
end
disp('Forward difference Table is--')
T


%Calculating FXr By Forward Difference Table
h = X(1,2)-X(1,1);
r = (Xr - X(1,1))/ h;
FXr = Y(1,1);
for i=1:n-1
p=1;
for j=1:i
p= p * (r+1-j)/j;
end
FXr = FXr + p * T(i+1,1);
end
disp('The value at point is--')
FXr




else


%Backward Difference Table


for p=2:n
for q=n:-1:p
K(p,q)= K(p-1,q) - K(p-1,q-1);
end
end
disp('Backward difference Table is--')
K




%Calculating FXr By Backward Difference Table
h = X(1,2)-X(1,1);
r = (Xr - X(1,n))/ h;
FXr = Y(1,n);
for i=1:n-1
b=1;
for j=1:i
b= b * (r-1+j)/j;
end
FXr = FXr + b * K(i+1,n);
end
disp('The value at point is--')
FXr


end

You might also like