title: polyfit max degree of polynom
body: <p>I am fitting my data, and trying to find best polynome order.
  Here is the code:</p>
  
  <pre><code>cov = 1
  o = 2
  print 'begin polyfit'
  for z in range(15, 65):
      ttt = np.polyfit(phase3, data3, z, full=True)
      p_k_t = ttt[0]
      cov_t = ttt[1]
      if (len(cov_t)&gt;0) and (cov_t &lt; cov):
          p_k = p_k_t
          o = z
          cov = cov_t
  print 'End polyfit, best order = ', o
  </code></pre>
  
  <p>But every time (data is changing) I get best order = 30. Fit looks not very good, can be better.
  Start thinking that its a maximal value of polynom order. Can it be true ? Or then I must have error on 31 order ? </p>
  
  <p>Green line is a polyfit
  <a href="https://i.stack.imgur.com/H5IPx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H5IPx.png" alt="Green line is a polyfit"></a></p>
  
  <p><strong>UPDATE:</strong>
  Residuals (cov) cant be computed after order 30 </p>