How to include integral function in TF1?

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

You can try something along these lines:

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);
1 Like

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