# Integrals on symbolic regions

Let's define a region as r=Polygon[{{-a,0},{a,0},{a,h}}]. I want to integrate some function over that area. Say x^2. So, Assuming[a>0&&h>0,Integrate[x^2,Element[{x,y},r]]] I get a^3h/3, as expected.

But, what if I want to have a four-sided polygon instead? If I redefine the region as r=Polygon[{{-a,0},{a,0},{a,h},{0,h}}], and then do Assuming[a>0&&h>0,Integrate[x^2,Element[{x,y},r]]], it can't do the integral.

• r = Polygon[{{-a, 0}, {a, 0}, {a, h}, {0, h}}]; Area[r, Assumptions -> h > 0 && a > 0] Commented Apr 27, 2022 at 22:40
• This works for areas. What if I want to integrate some function over the region, like x^2? I've modified the question to reflect this. Commented Apr 29, 2022 at 15:37

Clear["Global*"]

r = Polygon[{{-a, 0}, {a, 0}, {a, h}, {0, h}}];


As pointed out by cvgmt in a comment, the area is

area = Assuming[a > 0 && h > 0, Area[r]]

(* (3 a h)/2 *)


As a workaround to do the integral, break the region r into three triangular regions

r21 = Polygon[{{-a, 0}, {0, 0}, {0, h}}];
r22 = Polygon[{{0, 0}, {0, h}, {a, 0}}];
r23 = Polygon[{{0, h}, {a, h}, {a, 0}}];


The integral can be done over the subregions

area == Assuming[a > 0 && h > 0,
Total[Integrate[1, {x, y} ∈ #] & /@ {r21, r22, r23}]]

(* True *)


EDIT: For a more complicated integrand

f[x_, y_] := (x^2 + 3) (x + y)

Assuming[a > 0 && h > 0,
Total[Integrate[f[x, y], {x, y} ∈ #] & /@ {r21, r22, r23}] //
Simplify]

(* 1/60 a h (60 a + 12 a^3 + 120 h + 11 a^2 h) *)


EDIT 2: The subdivisions do not need to be only triangles; however, there are limitations. Arbitrary polygons cannot be handled. Even a Polygon representing a Rectangle fails.

r31 = Polygon[{{0, 0}, {0, h}, {a, h}, {a, 0}}];

Assuming[a > 0 && h > 0,
Total[Integrate[f[x, y], {x, y} ∈ #] & /@ {r21, r31}] // Simplify]


However, the equivalent Rectangle works

r32 = Rectangle[{0, 0}, {a, h}];

Assuming[a > 0 && h > 0,
Total[Integrate[f[x, y], {x, y} ∈ #] & /@ {r21, r32}] // Simplify]

(* 1/60 a h (60 a + 12 a^3 + 120 h + 11 a^2 h) *)
`
• My edit yesterday specifically addressed an integral other than an area calculation. Commented Apr 29, 2022 at 15:41
• Breaking it up works, but are we really limited only to triangular regions? Commented Apr 29, 2022 at 15:41
• Hmm. That's a bummer. Commented May 4, 2022 at 15:55