
clc,clear;
x=-5:1:5;
y=sin(x);
hermite(x,y)

%
% 这里对于写hermite插值的函数进行一些测试

syms x x1 x2 d1 d2 y1 y2;
x1=1;
x2=2;
y1=2;
y2=2;
d1=2;
d2=2;
p=(((x-x2)/(x1-x2))^2)*(1+2*(x-x1)/(x2-x1))*y1+(((x-x1)/(x2-x1))^2)*(1+2*(x-x2)/(x1-x2))*y2+(((x-x2)/(x1-x2))^2)*(x-x1)*d1+(((x-x1)/(x2-x1))^2)*(x-x2)*d2
%simplify(p)
p=collect(p)
h=sym2poly(p)

%

h=cubic_Hermite(-1,1,sin(-1),sin(1),cos(-1),cos(1))

%
% 扩展研究

clc,clear;
x=100:1:105;
y=sin(x);
hermite(x,y)

%

clc,clear;
x=100:1:105;
y=sin(x);
EvaInterp(x,y)

%
% 现在考察插值的误差

clc,clear;

%

x=100:1:105;
y=sin(x);
hermite(x,y)

%

EvaInterp(x,y)

%

clc,clear;
x=-5:1:5;
y=sin(x);
hermite(x,y)
EvaInterp(x,y)

%

clc,clear;
x=-10:1:10;
y=sin(x);
hermite(x,y)

%

EvaInterp(x,y)

%

clc,clear;
x=-10:0.5:10;
y=sin(x);
hermite(x,y)

%

EvaInterp(x,y)