0% found this document useful (0 votes)
19 views

'Enter The Value of X in Vector Form:' 'Enter The Value of y in Vector Form:' 'Enter The Point To Be Interpolated:' Long

The program calculates the value of a function at a given point using backward difference interpolation. It takes as input vectors for x, y, and the interpolation point b. It then calculates the difference table and the Newton backward formula coefficients to determine the interpolated function value. When run with sample input data, it outputs the interpolated function value at point 40 as 0.866.

Uploaded by

devarshi saksena
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)
19 views

'Enter The Value of X in Vector Form:' 'Enter The Value of y in Vector Form:' 'Enter The Point To Be Interpolated:' Long

The program calculates the value of a function at a given point using backward difference interpolation. It takes as input vectors for x, y, and the interpolation point b. It then calculates the difference table and the Newton backward formula coefficients to determine the interpolated function value. When run with sample input data, it outputs the interpolated function value at point 40 as 0.866.

Uploaded by

devarshi saksena
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/ 3

Programme

function fx = backward(x, y, b)
clc;
x = input('Enter the Value of x in Vector form:')
y = input('Enter the Value of y in Vector form:')
b = input('Enter the Point to be Interpolated:')
n = length(x);
format long
%Now we wrte the code for difference table
for i = 1:n-1%assigns value of row
del(i,1) = y(i+1) - y(i);%We find first difference table column
end
for k = 2:n-1%assigns value of column
for i = 1:n-k%finds second to nth difference table columns
del(i,k) = del(i+1,k-1) - del(i,k-1);
end
end
del
h =x(2) - x(1);

%Code of newton forward formula coefficient loop


p = (b - x(n))/h;
for j = i:(n-1)
if j==1 %NBF 2nd term
c(1) = p*del(n-1,j);
else
t=p;
for f = 1:j-1 %NBF 3,4,5th... term
t = t*(p+f);
end
c(j) = t*del(n-j,j)/factorial(j);
end
end
sum(c);
ans = y(n) + sum(c)
end

Input and Output

Enter the Value of x in Vector form:[10 15 30 35 45 60]

x=

10 15 30 35 45 60

Enter the Value of y in Vector form:[0.1736 0.2588 .5 .5735 0.7071 0.866]


y=

0.173600000000000 0.258800000000000 0.500000000000000 0.573500000000000


0.707100000000000 0.866000000000000

Enter the Point to be Interpolated:40

b=

40

del =

0.085200000000000 0.156000000000000 -0.323700000000000 0.551500000000000 -


0.814100000000000

0.241200000000000 -0.167700000000000 0.227800000000000 -0.262600000000000 0

0.073500000000000 0.060100000000000 -0.034800000000000 0 0

0.133600000000000 0.025300000000000 0 0 0

0.158900000000000 0 0 0 0

Enter Value of n:

Enter Value of n:

ans =
0.866000000000000

You might also like