Is this Hermite interpolation correct?

Someone can explain this hermit interpolation algorithm with example?

Thank you,

function [H]=hermite(X,x,f,fd);
m=length(x);
for i=1:m
z(2*i-1)=x(i);
Q(2*i-1,1)=f(i);
z(2*i)=x(i);
Q(2*i,1)=f(i);
Q(2*i,2)=fd(i);
if i~=1
Q(2*i-1,2)=(Q(2*i-1,1)-Q(2*i-2,1))/(z(2*i-1)-z(2*i-2));
end;
end;
for i=3:2*m
for j=3:i
Q(i,j)=(Q(i,j-1)-Q(i-1,j-1))/(z(i)-z(i-j+1));
end
end
p=1;
H=Q(1,1);
for i=2:2*m
p=p.*(X-z(i-1));
H=H+p.*Q(i,i);
end;

-
You'll want to see Krogh's paper. – J. M. Nov 4 '11 at 1:01

1 Answer

The next time you post raw code, please show the basic courtesy of telling us what language it's in.

You'll find an explanation of the algorithm underlying this code together with an example in the Wikipedia article on Hermite interpolation, unsurprisingly. Also take note of the article on divided differences that it links to. If there is something in those articles that you don't understand, please ask a specific question about that particular aspect.

-