Use graph->Integral() encouter problem

Hi experts,
I met an incredible problem when use graph->Integral(). I integrate a graph from the first point to the third point using graph->Integral(0,2), then it return a value 0 but it should have not be zero. I have outputed the first, second and third point and find they are all larger than zero, so the integral should not be zero. the code I wrote and parts of output are given below. Hope you can help me resolve the problem. thank you.

0.0839837 0.141478 0.198973
xstart:0 xend:2 Integral: 4.44089e-16
340 0.0839837
350 0.141478
360 0.198973
370 0.256467
380 0.313961
390 0.286965
400 0.259969


I am using this function. it has problem.

Thank you Wile,
Now I realized that this function computes the area of the polygon enclosed by the points of the graph. This is not the function I wanna. I wanna integrate the graph from xlow to xup. Would you mind telling me how can I make it?

I found an example for calculating the area under the graph.

double x[] = { 1,2,3,4,5,6,7,8,9,10};
double y[] = { 1,2,3,4,5,6,7,8,9,10}; 
TGraph g(10,x,y);
TF1 f1("f",[&](double *x, double *){ return g.Eval(x[0]); },1,10,0);
double integral = f1.Integral(1,10);

cite: Integral of TGraph

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