# Integration over a triangle

Let $\Delta$ be a triangle with vertices $(0,0)$, $(0,1)$ and $(1,0)$ in ${\bf R}^2$. I want to compute $$I=\int\limits_\Delta x^2\mathrm{e}^{y^2}\;\mathrm{d}A.$$ This is what I've done so far: Note that the hypotenuse is given by the line $y=1-x$. Keep $x\in[0,1]$ fixed, then $y$ is between $1$ and $1-x$ this gives $I=\int_0^1\int_1^{1-x}x^2\mathrm{e}^{y^2}\;\mathrm{d}y\;\mathrm{d}x$, which can't be computed. But when $y\in[0,1]$ is fixed, $x$ is between $0$ and $1-y$, which gives $$I=\int\limits_0^1\int\limits_1^{1-y}x^2\mathrm{e}^{y^2}\;\mathrm{d}x\;\mathrm{d}y=\frac13\int\limits_0^1(1-y)^3\mathrm{e}^{y^2}\;\mathrm{d}y,$$ which gives the same trouble.

As you can see, I keep ending up with some sort of Gaussian integral, which is impossible to compute. Does anyone know how to compute this integral?

-
Quote: "then $y$ is in between $1$ and $1-x$" No, it's in between $0$ and $1-x$. You wrote the bounds incorrectly in a similar way on the 1st $\iint$ in the 2nd line of your question too. Here's a picture to keep track of the region of integration. W|A says the integral evaluates to something non-elementary, unfortunately, so I'm not sure if there's a nice answer here. –  anon Mar 27 '12 at 13:33
@anon. Oh, I see. Thank you for pointing it out. If I keep my $y$ fixed, is $x$ then between $1-y$ and $1$?, i.e. do I get the integral $\int_0^1 \int_{1-y}^1 ... dx dy?$ –  KLM Mar 27 '12 at 14:54
KLM, please think about the picture I linked. If $y$ is fixed it forms a horizontal line through the triangle. Does it look like where the shaded intersects the horizontal line, $x$ goes from the diagonal line $x=1-y$ to the vertical $x=1$ line? –  anon Mar 27 '12 at 15:27
@KLM: The integral is either $\int_0^1 dx \ \int_0^{1-x} dy$ or $\int_0^1 dy \ \int_0^{1-y} dx$. Notice that the hypotenuse is given by the formula $y=1-x$ (otherwise known as $x=1-y$). See anon's figure. –  user26872 Mar 27 '12 at 19:33
Let's integrate over $x$ first, then $y$, $$\begin{eqnarray} I &=& \int_0^1 dy \ e^{y^2} \int_0^{1-y} x^2 \\ &=& \frac{1}{3} \int_0^1 dy \ e^{y^2}(1-y)^3 \\ &=& \frac{1}{3} \left(\langle 1\rangle - 3\langle y\rangle + 3\langle y^2\rangle - \langle y^3\rangle\right), \end{eqnarray}$$ where, for convenience, we define $$\langle y^n\rangle = \int_0^1 dy \ e^{y^2}y^n.$$ Using integration by parts show that the integrals are related in the following way for $n>1$ $$\langle y^n\rangle = \frac{1}{2}e - \frac{n-1}{2}\langle y^{n-2}\rangle.$$ Thus, we need only calculate the integrals $$\begin{eqnarray} \langle 1\rangle &=& \int_0^1 dy \ e^{y^2} = \frac{\sqrt{\pi}}{2} \mathrm{erfi}(1) \\ \langle y\rangle &=& \int_0^1 dy \ e^{y^2} y = \frac{1}{2}(e-1) \end{eqnarray}$$ since $\langle y^2\rangle$ and $\langle y^3\rangle$ can be found in terms of them. (Above, $\mathrm{erfi}$ is the imaginary error function.) The integral $\langle 1\rangle$ is the only nontrivial integral we must calculate. It is enough to recognize that it is a standard integral.
Putting this all together we find $$I = \frac{1}{3}-\frac{\sqrt{\pi}}{12} \mathrm{erfi}(1).$$