# Integrating a polynomial over the product of two 2D regions

Consider a region $$P$$, a polygon. Denote $$x_1,x_2$$ the coordinates in the plane of $$P$$. Then it is well known that $$I(p,q)=\int_P x_1^px_2^q$$ is explicit in terms of the coordinates. However, the resulting formula is quite complicated.

I am moreover, interested in computing integrals of the form $$\iint_{P\times P} Q(x_1,x_2,y_1,y_2)dxdy$$ where $$(x_1,x_2), (y_1,y_2)$$ belong to $$P$$ and $$Q$$ is a polynomial (of reasonable degree). This integral can be reduced to a sum of products of integrals of the form $$I(p,q)$$.

Can the following questions be solved with Mathematica, for a given particular polygon $$P$$?

1. Compute $$I(p,q)$$ for given $$(p,q)$$, pair of non-negative integers.

2. Compute the double integral $$\iint_{P\times P} Q(x_1,x_2,y_1,y_2)dxdy$$ for a general polynomial $$Q$$?

This is taken straight from the Help (see the part about Region[]). First set up a region corresponding to a polygon

mr=Region[MeshRegion[{{0,0},{1,0},{1, 2},{1/2,3},{0,1}},Polygon[{1,2,3,4,5}]]];


Then define the $$I(p,q)$$ integrals:

int[p_,q_]:=Integrate[x^p y^q,{x,y}\[Element] mr]


and this calculates (quite quickly!) the integrals for various values of $$p$$ and $$q$$:

data = Flatten[Table[{p, q, int[p, q]}, {p, 1, 4}, {q, 1, 4}], 1]
(* {{1, 1, 1.48958}, {1, 2, 2.49167}, {1, 3, 4.7625}, {1, 4, 9.84643}, {2, 1, 0.979167}, {2, 2, 1.61667}, {2, 3, 3.04464}, {2, 4, 6.19777}, {3, 1, 0.706771}, {3, 2, 1.14271}, {3, 3, 2.10642}, {3,4, 4.19707}, {4, 1, 0.543452}, {4, 2, 0.859933}, {4, 3, 1.55025}, {4, 4, 3.01971}} *)


The example can be adapted for other polygons as well (just change the MeshRegion[] in the beginning).

The question about the integration over $$Q$$ looks like a separate issue to be honest, some clarification on where is the problem, would be desirable.