# How to include integral function in TF1?

**URL:** <https://root-forum.cern.ch/t/how-to-include-integral-function-in-tf1/24723>\
**Category:** ROOT\
**Created:** [May 11, 2017, 7:16am UTC](https://root-forum.cern.ch/t/how-to-include-integral-function-in-tf1/24723 "2017-05-11T07:16:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandeep\_Hundal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sandeep_hundal/32/19366_2.png) [@Sandeep\_Hundal](https://root-forum.cern.ch/u/Sandeep_Hundal)\
**Post date:** [May 11, 2017, 7:16am UTC](https://root-forum.cern.ch/t/how-to-include-integral-function-in-tf1/24723/1 "2017-05-11T07:16:06Z")

</div>

Hello everyone  
I have function f(x)=integration limits(0-10) [y^2 \*exp(x-y) dy]  
I need to plot f(x) wrt x in ROOT using TF1.I know how to call a function in TF1 like  
TF1 f1(“f1”,myfunction,0,24,5);  
But I dont know how to define this myfunction so that for every x it calculate the integration given above and return f(x).  
Please enlighten How to do it.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![mwojtas](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@mwojtas](https://root-forum.cern.ch/u/mwojtas)\
**Post date:** [May 11, 2017, 9:55am UTC](https://root-forum.cern.ch/t/how-to-include-integral-function-in-tf1/24723/2 "2017-05-11T09:55:29Z")

</div>

You can try something along these lines:

```auto
TF1 *fa = new TF1("fa","(x^2)*exp(x-[0])",0,10);
Double_t myfunction(Double_t x){
   fa->SetParameter(0,x);
   Double_t f = fa->Integral(0,10);
   return f;
}
TF1 *DesiredFunction=new TF1("DesiredFunction","myfunction(x)",0,24);

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 25, 2017, 9:56am UTC](https://root-forum.cern.ch/t/how-to-include-integral-function-in-tf1/24723/3 "2017-05-25T09:56:31Z")

</div>

Closed on May 25, 2017, 9:56am UTC

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