legendre_fit function

generate curve based on legendre polynomials