
clc,clear

%% 初始化
A = zeros(6);
A(:,1) = [1, 0.995, 0.98007, 0.95534, 0.92106, 0.87758];

%% 计算差商
for m = 2:size(A,2)
    
    A(1:end-m+1,m) = diff(A(1:end-m+2,m-1)); 
    
end

%% 牛顿插值多项式
syms t
N = A(1,1);
omega =1; 
for n = 2:size(A,1)-1
    
    omega = omega*(t-n+2)/(n-1);
        N = N + A(1,n)*omega;
    
end

%% 输出
fprintf('\tf(x)  一阶差商   二阶差商   三阶差商    四阶差商    五阶差商\n')
disp(A);
fprintf('N(x)=%s\n',vpa(simplify(N)));
fprintf('N(0.048)=%s\n',vpa(subs(N,0.48)));

