function l(k,t) r=1 for j=1:n if j!=k r=r*(t-x[j])/(x[k]-x[j]) end end return r end x=[1,2,3,5,6,7] y=rand(6) function p(t) s=0 for k=1:n s=s+y[k]*l(k,t) end return s end using Plots display(scatter(x,y)) xs=[1:0.1:7;]; n=6 display(plot!(xs,p.(xs)))