Está en la página 1de 1

function lagrange

f=input('ingrese la funcion f=','s');


x=input('ingrese el valor de x=');
n=input('ingrese los valores de n=');
%y=input('ingrese los valores de y=');
G=inline(f);
y=feval(G,x);
plot(x,y,'or')
hold on
Px=0;
for h=1:n
L=x. 0;falta
D=1;
for k=1:n
if k~=h
L=L.*(x-x(k));
D=D*(x(h)-x(k));
end
end
L=L/D;
Px=Px+y(h)*L
end

También podría gustarte