Double precision lost

Dear all,

I am fitting data, with pol2, pol3, pol4,…
To describe the data best, I tries to fit them with pol5, of course now the function describes the data very well, but I found that in output text file, some output lines of the command
is strange. for example

-0.0548926 1 0.0025458 1 -1.32294e-07 1 1.26921e-10 1 -5.60118e-14 1 9.03258e-18 0.000552717
-0.0510844 1 0.00255203 1 -2.14847e-07 1 1.94146e-10 1 -8.04038e-14 1 1.22641e-17   1

the error of a parameter is larger than the parameter, and it’s a very int 1…
when I tried to fit using pol4, error is usually 2-3 orders smaller than the parameter.
It’s seems the precision of error was lost, even for a large parameter like -0.0548926, right?

How can I keep the right errors of the large parameters at least?

Thank you.

could you please provide the data you are using or at least a small reproducer in order to investigate the problem.


hi @caid,

Your introduction has a statement that is statistically speaking not correct:

To describe the data best, I tries to fit them with pol5, of course now the function describes the data very well

The fact that the line is closer to the points does not imply that it describes the data very well. This statement should be quantified with an F-test.


Hello Stefano,
Thanks for your reply, I deleted some lines, the code can reproduce the problem I introduced, if you change the value of npol to be 4 or smaller you will find the output parameters keep their precision. please find the attachments.
The output parameters would be saved in outputx.txt file.

ch2v_demo.C (2.4 KB)
pksx.txt (44.4 KB)


Thank you Eddy,
I will try to see if pol5 is an appropriate function to fit the data.

Hi Jiawei,

Looking at your script+Data I notice that you do many fits with 30 points,
Each data point has x,y,dx,dy where dy is always 1.e-8.

Fitting a pol5 (6 parameters) you get results like

FCN=7296.59 FROM MINOS     STATUS=PROBLEMS     1749 CALLS        9751 TOTAL
                     EDM=1.39941e-05    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0          -3.39492e-02   2.63602e-05   2.90635e-08  -1.06365e+02
   2  p1           2.44712e-03   5.98027e-08  -6.42361e-11  -1.56948e+05
   3  p2          -7.96638e-08   1.88004e-11  -1.07878e-14  -5.84373e+08
   4  p3           3.36353e-11   5.13638e-15   1.63028e-17  -2.17246e+12
   5  p4          -6.75592e-15   1.97983e-18  -2.42450e-21  -7.16996e+15
   6  p5           5.07464e-19   2.58296e-22   2.58296e-22  -1.45940e+20

Now realize that with doubles for delta < 1e-16, 1+delta = 1, so things are getting
suspicious around p4.

(Entertaining write-up about representation of numbers here)

If you are really interested in these high-order terms, you should represent your data differently .
Fit it first with “cheb2”, a seconder order member of the orthogonal set of Chebyshev functions.
Now subtract this fit from the data points and proceed with a cheb5, (the first three coefficients should be zero, or at least very close to it because the fit is non-linear).


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.