Implementation of polynomial curve fitting