# Interpolação Polinomial

L(i, X) := product(if i=j then 1 else (x-X[j])/(X[i]-X[j]) , j, 1, length(X))$
plagrange(X, Y) := sum(Y[i]*L(i, X), i, 1, length(X))$

X: makelist(i, i, 1, 5)$
Y: [2, 5, 1.5, 0.5, 1]$
p: plagrange(X,Y)$
wxplot2d([p, [discrete, X, Y]], [x, 0, 6], [y, 0, 6], [style, [lines, 1], [points, 2, 2, 1]]);