% 此函数的简短摘要。
% 此函数的详细说明。


function  EvaInterp(x,y)
%% 输入值分配，x_input,y_input均为数组,y_0,y_n为x_0,x_n分别对应的一阶导数值
x_input = x;
y_input = y;

%% 
[~,number] = size(x_input); %获取输入x_input的大小1×number

 
for i =1:number-1
    % 获取相邻两点间的插值函数
     x_ = linspace(x_input(1,i),x_input(1,i+1));

    h=cubic_Hermite(x_input(1,i),x_input(1,i+1),sin(x_input(1,i)),sin(x_input(1,i+1)),cos(x_input(1,i)),cos(x_input(1,i+1)));
    s=polyval(h,x_);

    ResHermite=plot(x_,abs(s-sin(x_)),"Color",[0.8 0.2 0.2],"Marker","*");
    hold on;
end

%比较牛顿法

N=my_newton(x,y);
t=linspace(x(1),x(end),1001);
P2=polyval(N,t);

ResNewTon=plot(t,abs(P2-sin(t)),"Color",[0 0.2 0.2],"Marker","*");
%hold on;


legend([ResNewTon,ResHermite],{'NewTon误差','Hermite误差'})


maxy=max(abs(P2-sin(t)));
miny=-max(abs(P2-sin(t)));
xlim([x(1) x(end)]);
ylim([2*miny 2*maxy]);
clear;