Question: How to perform double integration over subdomain

Hi, friends

I need to calculate the double integral over a non-rectangular domain.

Say, the domain is the triangle (in red)

When I enter

int(int((x^2+y^2)*`if`((y-x-1/2 <= 0) and (y+2*x-2<=0) and (y+x/2-1/2>=0), 1, 0), x=0..1, numeric = true), y=0..1, numeric = true);

or 

int(int((x^2+y^2)*eval(`if`((y-x-1/2 <= 0) and (y+2*x-2<=0) and (y+x/2-1/2>=0), 1, 0)), x=0..1, numeric = true), y=0..1, numeric = true);

an error occur (Error, (in int) cannot determine if this expression is true or false: y-x <= 1/2 and y+2*x <= 2 and 0 <= y+(1/2)*x-1/2)

For me, it is desirable to write boundary conditions in the int operator itself, not as a separate expession.

 

Please Wait...