# Integral of TGraph

**URL:** <https://root-forum.cern.ch/t/integral-of-tgraph/4745>\
**Category:** ROOT\
**Created:** [May 7, 2007, 11:59am UTC](https://root-forum.cern.ch/t/integral-of-tgraph/4745 "2007-05-07T11:59:23Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [September 29, 2015, 9:11am UTC](https://root-forum.cern.ch/t/integral-of-tgraph/4745/12 "2015-09-29T09:11:39Z")

</div>

If you want the integral under the graph curve I would create first a TF1 from the Graph and integrate the function, as in this example

```auto
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);
```

Lorenzo

---

_[View the full topic](https://root-forum.cern.ch/t/integral-of-tgraph/4745)._
