Newton divided rule Method

2 Ansichten (letzte 30 Tage)
Loo Yong Jian
Loo Yong Jian am 31 Mär. 2020
Bearbeitet: Geoff Hayes am 31 Mär. 2020
Given the data x and y, I am require to find the value of y when x is equal to 40. However the code give me the answer is out of range. I would like to know where is the problem thank you.
n = 7;
x = [20,23,34,49,53,58,61];
y = [166,193,212,220,228,241,268];
plot(x,y,'-o')
grid on
x0 = 40;
n = size(x,1);
if n == 1
n = size(x,2);
end
for i = 1:n
D(i,1) = y(i);
end
for i = 2:n
for j = 2:i
D(i,j)=(D(i,j-1)-D(i-1,j-1))/(x(i)-x(i-j+1));
end
end
fx0 = D(n,n);
for i = n-1:-1:1
fx0 = fx0*(x0-x(i)) + D(i,i);
end
fprintf('Newtons iterated value: %11.8f \n', fx0)

Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by