kristen kaasbjerg wrote:
When i try to fit a polynomial of order 4 to 5 data
points, I get an answer far from what I would expect.
If I run your script and print out the polynomial coefficients, they are very large and alternate in sign:
In : p
array([ -1779.1645838 , 7613.24170642, -12137.79572888,
8529.6429996 , -2239.34146635])
This means that the problem is ill posed. In general, high order polynomial fitting is a bad idea; if you just want an interpolant and don't care about coefficients, use a cubic spline.