TSpline::GetCoeff delivers wrong results (factor 2)


i am reading a *.csv into a TTree, then I plot a graph from it.
I then make the TSpline on this graph, which works fine.
Then I call TSpline->GetCoeff, and write those values in an array for each node. I then plot the arrays I want to see.

What puzzles me, is that “c”, the second coefficient, always seems to be missing factor 2.
So when I make .csv-files with numerical defined x^2, 2x^2 and x^3, I get 1, 2, and 3*x for “c”.

This is true for both TSpline3 and TSpline5.

This is, what the source-file says about the coefficient:

Double_t fC; // second order expansion coefficient : fC*2! is the second derivative at x

What am I missing?


Here is a snippet that resembles the problem.
The fourth column in the output is the one I mistrust.

TF1 *f1 = new TF1("f1","x*x",0,2);
Double_t *a = new Double_t[5];
Double_t *b = new Double_t[5];


for (Int_t i=0; i<5; i++){b[i] = f1->Eval(a[i]);}

TGraph *g = new TGraph(5,a,b);
TSpline3 *s = new TSpline3("spline",g);

for (Int_t i=0; i<4; i++){
 Double_t *x = new Double_t;
 Double_t *y = new Double_t;
 Double_t *b = new Double_t;
 Double_t *c = new Double_t;
 Double_t *d = new Double_t;


Hey folks,

i even get bad results for the third derivative of TSpline.
For x^3 i get 1 where it should be 6, for 2x^3 I get 2 where it should be 12.

If I get it right (ROOT newbe), than the method BuildCoeff() is the point, where the math happens.

Is there anybody into this?



The coefficients are defined as documented in root.cern.ch/root/html/TSplinePoly3.html.

2!*C is the second derivative and 3! * D is the third derivative. So the value you are getting seems to me what is expected.

Sorry for the late reply.

Best Regards