// Enter Function, f (x)

f[x_] = Sin[3  Pi*x]

//Enter set of points,  
        store number of points

xset = {1/2, 1/4, 1/10, 1/20, 1/100}
n = Length[xset]

//Main algorithm, sets g(x) = Lagrange approximation of f(x)

g[x_] = (∑_(k = 1)^n)(f[
              xset[[k]]]*(((∏_(i = 1)^(k - 1))((x - xset[[i]])/(xset[[k]] - xset[[i]])))*((∏_(i = k + 1)^n)(( x - xset[[i]])/(xset[[k]] - xset[[i]])))))

// Display of the actual points, in order of x0, x1, x2, ..., xn
//and test if actual and approximation points match

f[xset]
g[xset]
f[xset] == g[xset]