I would like to know why an polynomial fit is divergent on the boundaries of the fit interval (as shown on the doc site of the matlab polyfit function). And why a polynomial fit on a data set is a very bad extrapolation technique for data just outside of the fit interval.
Method used to compute coefficients: least square method.
It seems that splines are better techniques for that but I try to understand why polynomial fits have these drawbacks.
Because every polynomial blows up at infinity, and the closer you get to infinity, the faster they blow up. Most real-world functions don't work like this. For example, if you're trying to fit stock-market data, you probably want to assume a priori that there's a certain maximum size a company can grow to based on the size of its industry. Beyond that, it can't grow any further.