Least-squares polynomial fitting