Code that runs polyfit and finds error