def Lagrange_polynomial(x, i, points): p = 1 for k in range(len(points)): if k != i: p *= (x - points[k])/(points[i] - points[k]) return p