function p = lagrange1(n,x,y,t) p = 0; for i=1:n l = 1; for j=1:n if j ~= i l = l*(t-x(j))/(x(i)-x(j)); end end p = p + l*y(i); end return