# Help with TF2 integral

**URL:** <https://root-forum.cern.ch/t/help-with-tf2-integral/45326>\
**Category:** Newbie\
**Tags:** python, cling\
**Created:** [June 10, 2021, 6:48am UTC](https://root-forum.cern.ch/t/help-with-tf2-integral/45326 "2021-06-10T06:48:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rpitta](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rpitta](https://root-forum.cern.ch/u/rpitta)\
**Post date:** [June 10, 2021, 10:59pm UTC](https://root-forum.cern.ch/t/help-with-tf2-integral/45326/4 "2021-06-10T22:59:57Z")

</div>

So, I’ve tried some functions. For instance, first I tried to compute

> Int\_0^2 dx Int\_0^2 dy x\*y

using this code:

```auto
double func2(const double *x){

	return x[0]*x[1];

}

void integral(){

ROOT::Math::Functor f2(& func2, 2);
double a[2] = {0,2};
double b[2] = {1,2};

ROOT::Math::IntegratorMultiDim ig1(ROOT::Math::IntegrationMultiDim::kADAPTIVE);
ig1.SetFunction(f2);
double val = ig1.Integral(a,b);

cout<<val<<endl;
}

```

It worked. Them, I tried to change the y integration limits to

> Blockquote int\_fmin(x)^fmax(x)

like in the code, to simulate the lambda function in the python code:

```auto
**Python code**

eLow = lambda u: eMin(u, m_X)
	eHigh = lambda u: eMax(element, m_X, u)
	integral = integrate.dblquad(integrand, uLow, uHigh, eLow, eHigh)[0]

```

```auto
**cling**

double fmin(x){
	
	return x+1;
	
}

double fmax(x){

	return 2*x+2;

}

void integral(){

ROOT::Math::Functor f2(& func2, 2);
double a[2] = {0,fmin(x[0])};
double b[2] = {1,fmax(x[0])};

ROOT::Math::IntegratorMultiDim ig1(ROOT::Math::IntegrationMultiDim::kADAPTIVE);
ig1.SetFunction(f2);
double val = ig1.Integral(a,b);

cout<<val<<endl;
}

```

this didn’t worked. If you could provide any help, I would appreciate.

Thank you,  
Bests  
Ricardo

---

_[View the full topic](https://root-forum.cern.ch/t/help-with-tf2-integral/45326)._
