Boundary integral

I want to integrate two dimensional function.it is easy when boundary is constant.I mean boundary is number.How can ı calculate when boundary is variable…
Example f(x,y)=x*y^2
boundary x change y to 1 and boundary y change 0 to 1.

Can anybody help me?

Well, a “brutal fix” would be to redefine your function:
if (x >= y) return f(x, y); else return 0;
and then integrate it from 0 to 1 in both dimensions (i.e. in a 2D rectangular region).
Some warnings: Creating TF1 from TGraph - #10 by Pepe_Le_Pew and Convolution of two TF1 - #8 by Pepe_Le_Pew

BTW. Note that there’s a special “Stat and Math Tool Support” forum here.

Thank you for your reply…I dont know what is brutal fix mean.This is my code.but here the boundary x change from 0 to 1 and there is no problem.How can ı change my code when boundary x change y to 1.

double f2(const double *x) {
return x[0]*x[1];
} 

void deneme()
{
ROOT::Math::Functor wf(&f2,2);
double a[2] = {0,0};
double b[2] = {1,1};
  ROOT::Math::IntegratorMultiDim ig(ROOT::Math::IntegrationMultiDim::kADAPTIVE); 
  ig.SetFunction(wf);
double val = ig.Integral(a,b);
   std::cout << "integral result is " << val << std::endl;

}
double f2(const double *x) {
  if (x[0] >= x[1]) return (x[0] * x[1]);
  return 0; // out of boundaries
}
double f2(const double *x) {
  if (x[0] < x[1]) return 0; // out of boundaries
  return (x[0] * x[1]);
}

thank yo so much.I dont understand but it works…

Here’s the “proper solution”:

// Problem: integrate a two dimensional function "f(x,y)" using limits:
// "y" from 0 to 1 and "x" from "y" to 1.
// Solution: change the variable "x:[y, 1]" -> "t:[0, 1]" and
// then the integration goes from 0 to 1 in both dimensions.
// So "x = (1 - y) * t + y" and "dx/dt = (1 - y)".
// See also:
// http://en.wikipedia.org/wiki/Integration_by_substitution
// http://en.wikipedia.org/wiki/Multiple_integral#Change_of_variables
//
double f2(const double *X)
{
  double f = 0.0;
  double t = X[0]; // "t" (i.e. the original "x")
  double y = X[1]; // "y"
  double x = (1.0 - y) * t + y; // calculate new "x"
  
  // calculate the original function "f(x,y)"
  f = x * y; // f(x,y) = x * y
  // f = x * y * y; // f(x,y) = x * y^2
  
  f *= (1.0 - y); // multiply the result by "dx/dt"
  return f;
}

Just for reference: “Non-rectangular region integration

oo excellent…I understood …I can solve my complex integral now:) Thank you very much for your great explanation.