## [Matplotlib-users] Bug in polyfit

 [Matplotlib-users] Bug in polyfit From: Axel Kowald - 2005-02-28 22:40:22 ```Hi, I'm using matplotlib 0.71 and I think I found a bug in polyfit. This simple linear regression on two data points gives the correct answer: >>> polyfit([731.924,731.988],[915,742],1) array([ -2703.12505517, 1979397.10294428]) However, if I multiply my x values by 1000 the result is wrong: >>> polyfit([731924,731988],[915,742],1) array([ 5.17650790e-009, 8.28496211e+002]) Could that be some kind of overflow problem ??? Alex ```

 [Matplotlib-users] Bug in polyfit From: Axel Kowald - 2005-02-28 22:40:22 ```Hi, I'm using matplotlib 0.71 and I think I found a bug in polyfit. This simple linear regression on two data points gives the correct answer: >>> polyfit([731.924,731.988],[915,742],1) array([ -2703.12505517, 1979397.10294428]) However, if I multiply my x values by 1000 the result is wrong: >>> polyfit([731924,731988],[915,742],1) array([ 5.17650790e-009, 8.28496211e+002]) Could that be some kind of overflow problem ??? Alex ```
 Re: [Matplotlib-users] Bug in polyfit From: John Hunter - 2005-03-01 03:28:34 ```>>>>> "Axel" == Axel Kowald writes: Axel> Hi, I'm using matplotlib 0.71 and I think I found a bug in Axel> polyfit. Axel> This simple linear regression on two data points gives the Axel> correct answer: >>>> polyfit([731.924,731.988],[915,742],1) ^^^^ floats Axel> However, if I multiply my x values by 1000 the result is Axel> wrong: >>>> polyfit([731924,731988],[915,742],1) ^^^^ integers Both of these should work print polyfit([731.924,731.988],[915.,742.],1) print polyfit([731924.,731988.],[915.,742.],1) I fixed the polyfit code to explicitly convert the input arrays to floats arrays, which fixes this bug. Thanks for the report. JDH ```