function infinitas(x,y,xb)
m(:,1)=x;
m(:,2)=y;
c=0;
r=zeros(length(x)-1,length(x)+1);
for i=3:length(x)+1
c=c+1;
for j=1:length(y)-c
m(j,i)=y(j+1)-y(j);
end
y=m(:,i);
end
p(1)=1;
p1(1)=1;
c=length(x);
for i=1:length(x)-1
for j=1:i
p1(2)=-x(j);
p=conv(p,p1);
end
k=1;
in=c;
ind2=1;
while k<=length(p);
r(i,in)=p(ind2);
k=k+1;
in=in+1;
ind2=ind2+1;
end
c=c-1;
p=ones(1);
end
h=x(2)-x(1);
disp(m);
ind=1;
for i=1:length(x)+1
for j=3:length(x)+1
r(ind,i)=r(ind,i)*(m(1,j)/(fact(ind)*(h^ind)));
ind=ind+1;
end
ind=1;
end
pol=zeros(1,length(x)+1);
for i=1:length(x)+1
for j=1:length(x)-1
pol(i)=pol(i)+r(j,i);
end
end
pol(length(x)+1)=pol(length(x)+1)+m(1,2);
f=poli(pol,xb);
disp(r);
disp(pol);
disp(f);
--------------------------------------------------------
function s=poli(x,y)
s=0;
n=length(x);
for i=1:n
s=s+x(i)*y^(n-i);
end
-----------------------------------------------------
function f=fact(x)
f=1;
for i=1:x
f=f*i;
end
No hay comentarios:
Publicar un comentario