Professional Documents
Culture Documents
formula
Code:
clear; clc;
x=input("Enter the values for x : ");
y=input("Enter the values for y : ");
n=length(x);
%to construct difference table we create a zero matrix of order n%
d=zeros(n,n);
for i=1:n
d(i,1)=y(i);
end
for i=2:n
for j=i:n
d(j,i)=d(j,i-1)-d(j-1,i-1);
end
end
fprintf("Difference table\n");
disp(d)
Output:
Enter the values for x :
[1 2 3 4 5]
Enter the values for y :
[10 26 58 112 194]
Difference table
10 0 0 0 0
26 16 0 0 0
58 32 16 0 0
112 54 22 6 0
194 82 28 6 0
Code:
clear; clc;
x=input("Enter the values for x : ");
y=input("Enter the values for y : ");
n=length(x);
%to construct difference table we create a zero matrix of order n%
d=zeros(n,n);
for i=1:n
d(i,1)=y(i);
end
for i=2:n
for j=i:n
d(j,i)=d(j,i-1)-d(j-1,i-1);
end
end
fprintf("Difference table\n");
Output:
x0=5
required value is 115
x0=7
required value is 329