The current Lagrange polynomial is copied from existing ancient code. There might be existing libraries that can provide this function.