Fits functions to a polynomial curve of appropriate number of terms