# polyfit degree problem ?

Dear All,

I have a problem using polyfit with a degree greater than 118 :

The code is :
matplotlib.mlab.polyfit( x, y, pow ) # pow is degree of polynomial

for pow in range 118 and 238 the error is :
LinAlgError, 'singular martix'

and for pow greater than 237 this error raise :
OverflowError : math range error

···

View this message in context: http://www.nabble.com/polyfit-degree-problem---tp17032710p17032710.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

matplotlib.mlab.polyfit is deprecated (and is a thin wrapper to
numpy.polyfit in the current implementation). Please direct polyfit
questions and problems to the numpy list.

JDH

···

On Sat, May 3, 2008 at 3:11 AM, sa6113 <s.payandeh@...287...> wrote:

Dear All,

I have a problem using polyfit with a degree greater than 118 :

The code is :
matplotlib.mlab.polyfit( x, y, pow ) # pow is degree of polynomial

for pow in range 118 and 238 the error is :
LinAlgError, 'singular martix'

and for pow greater than 237 this error raise :
OverflowError : math range error

sa6113 wrote:

Dear All,

I have a problem using polyfit with a degree greater than 118 :

The problem is that polynomial fitting generally doesn't make sense for degree higher than 4 or 5--if that--and at very high degree it is inevitable that the matrix will become singular. In other words, there is not enough information in the data to uniquely determine the fit. Whatever it is you are trying to to, fitting a polynomial with a high degree is the wrong way to do it.

Eric

···

The code is :
matplotlib.mlab.polyfit( x, y, pow ) # pow is degree of polynomial

for pow in range 118 and 238 the error is :
LinAlgError, 'singular martix'

and for pow greater than 237 this error raise :
OverflowError : math range error