Artificial intelligent assistant

Integral of a quadratic function over a triangle Consider a triangle given its three vertices in 3 space, $a, b, c$. Is there an expression or a way to calculate it better then monte carlo, for computing the the integral over this triangle, of the product of the linear function which is 1 at one vertice, and 0 at the two others and another which is 1 at some vertice and 0 at the two others. So input is the three vertice is three space, and the two vertices at which the two functions is 1. Edit: In this question it is seen that if the two vertices chosen for the two functions are not equal there is a simple expression, namely Area/12, is there one when the two vertices are the same aswell?

**Hint:**

Use an affine coordinate transform and set

$$p=(x_0,x_1,x_2)=a+u(b-a)+v(c-a).$$

The Jacobian of the transformation is the determinant of the matrix formed with $b-a$ and $c-a$, a constant (the area of the parallelogram built on $a,b,c$).

Then

$$\iint_T \,dx_i\,dx_j=J\int_{u=0}^1\int_{v=0}^u\,dv\,du.$$

$$\iint_T x_i\,dx_i\,dx_j=J\int_{u=0}^1\int_{v=0}^u(a_i+u(b_i-a_i))\,dv\,du.$$

$$\iint_T x_ix_j\,dx_i\,dx_j=J\int_{u=0}^1\int_{v=0}^u(a_i+u(b_i-a_i))(a_j+v(c_j-a_j))\,dv\,du.$$

We have

$$ \int_{u=0}^1\int_{v=0}^u1\,dv\,du=\frac12,\\\ \int_{u=0}^1\int_{v=0}^uu\,dv\,du=\frac13,\\\ \int_{u=0}^1\int_{v=0}^uv\,dv\,du=\frac16,\\\ \int_{u=0}^1\int_{v=0}^uuv\,dv\,du=\frac18.\\\ $$

By combining these results, you can easily obtain the integral of any quadratic function of $p$, such as yours,

$$f(p)=\frac{((p-a)\times(p-b))^2}{((c-a)\times(c-b))^2}=\frac{(p\times(b-a)+a\times b)^2}{((c-a)\times(c-b))^2}.$$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy f93c3a50255faa06b22ae7aba6120cfc