Calculating the integral using TF1 and TGraph

Dear all,

I have a data set and I want to integrate it. I have plotted the data with TGraph and using TGraph::Integral(), I calculate the integral but I have some doubts about the result. In order to understand if I am proceeding on the right way, I have executed a test: The integral of X^2 between 2 and 8 (for example).

First, I used:

TF1* func=new TF1("func","x^2",1,8);
double integral=func->Integral(1.,8.);

and the results is right, ~170.333.

Now, I used:

TGraph* grap=new TGraph(func);
double integr=grap->Integral();

and the result is ~55.4631, it isn’t the result I expected. I don’t know if I am doing something wrong or …??

Any idea,

Thanks in advance,



this is perfectly correct as the TGraph::Integral function returns the area of the polygon enclosed by the points of the graph (see … h:Integral).


Hi Danilo,

Thanks for your prompt reply.

Is there any way else to calculate the integral of a data set?