function [yy,phi] = lagrange_(xx,x,y)
% returnx lagrange interpolant in xx from data in [x,y]

m = size(x ,2);
n = size(xx,2);
yy = 0*xx;

phi = ones(m,n);
tmp = ones(m,1);
% Lagrange function phi_i
for i = 1:m
  for j = 1:n
    for k = [1:i-1,i+1:m]
      phi(i,j) = phi(i,j)*(xx(1,j)-x(1,k));
    end
  end
  for k = [1:i-1,i+1:m]
    tmp(i,1) = tmp(i,1)*( x(1,i)-x(1,k));
  end
end
phi = phi./tmp;
yy = y*phi;