implement Lagrange polynomials from thesis