Find the lagrange polynomial. This is quite a literal implementation, nothing is optimised.