您的位置:首页 > 编程语言 > MATLAB

Matlab之用牛顿均差求插值多项式

2014-06-30 01:12 302 查看
% page 151 3

% 写出一个插值多项式

% input :vector(x,y),interpolation point x0

% output:the result at x = x0

function y0 = page_157_1(x ,y,x0)

format long

n = length(x);

for j = 1:n %fill in y colum of Newton triangle

v(j,1) = y(j);

end

for i = 2:n %for colum i

for j = 1:n+1-i %fill in colum from top to bottom

v(j,i) = (v(j+1,i-1) - v(j,i-1))/(x(j+i-1)-x(j));

end

end

for i = 1:n

v(i) = v(1,i); %read along top of triangle

end %output coefficients

y0 = v(n)*(x0 - x(n-1)) + v(n-1); %initial nest

for i = 1:n-2 %use nest

y0 = y0*(x0 - x(n-1-i)) + v(n-1-i);

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: