# Integrating $x(xy+(1-x)(1-y))^{n-1}$ over Unit Square

I'm trying to integrate the following function ( which comes out of calculations regarding reliability polynomials of graphs ):

$$x\,\left[\, xy + \left(\, 1 - x\,\right)\left(\, 1 - y\,\right)\,\right] ^{\, n - 1}$$

over the unit square $\left(\vphantom{\large A}\,\mbox{i.e.,}\ 0 \le x \le 1,\,\,\, 0 \le y \le 1\,\right)$. I haven't found anything through searching, and evaluating the expression in WolframAlpha does not finish within the standard time limit.

However, when I ask Mathematica, there is an answer, which is quite complicated:

Is there analytical reasoning as to why this is the result?

Edit: since we can assume $n \ge 0$ and is an integer, we can use Assuming in Mathematica:

f[n_] := Integrate[x (x*y + (1 - x) (1 - y))^(n - 1), {x, 0, 1}, {y, 0, 1}]
Assuming[n >= 0 && Element[n, Integers], f[n]]


to achieve:

$$-\,2^{-2 - n}\,\,\, \frac{\left(\, -1\,\right)^{n}\,\beta\left(\,-1,-n,1 + n\,\right) + \beta\left(\, 2,1 + n,0\,\right) + \pi\left[\,\mathrm{i} + \cot\left(\, n\pi\,\right)\right]}{n}$$

where $\beta\left(\, a,b,c\,\right)$ is the incomplete beta function. I would still like to know how this is expression is derived.

• You may try to tell Wolfram that $n$ is an integer (if that's the case). That may avoid too special functions ... Sep 4, 2016 at 20:45
• @H.H.Rugh Of course, but I'd rather know what happens for any positive integer value of $n$ in general. Sep 4, 2016 at 20:46
• The hypergeometric function is defined also for real and complex values so very general. When $n$ is an integer there might be simpler functions available and if it is possible in WolframAlpha to specify that $n$ is an integer it may (?) come up with a simpler expression. But it's just an idea... Have no idea if it works. Sep 4, 2016 at 20:59
• @H.H.Rugh is there a way of inputting that $n$ is a fixed positive integer into Mathematica/WolframAlpha? Sep 4, 2016 at 21:00
• Unfortunately I don't know those sufficiently well. You may do so in Maple where one writes: assume (n::integer) I would guess that there is something similar in other languages (but don't know) Sep 4, 2016 at 21:04

Put yourself in baricentric coordinates (which is always good when you are integrating over a symmetric domain). $$x = u + 1/2,\;\;y = v + 1/2$$ then $$\begin{gathered} f(u,v,n) = \left( {1/2 + u} \right)\left( {\left( {1/2 + u} \right)\left( {1/2 + v} \right) + \left( {1/2 - u} \right)\left( {1/2 - v} \right)} \right)^{\,n - 1} = \hfill \\ = \left( {1/2 + u} \right)\left( {1/2 + 2\,u\,v} \right)^{\,n - 1} = \hfill \\ = 1/2\left( {1 + \frac{\partial } {{\partial \,v}}\left( {2\,u\,v} \right)} \right)\left( {1/2 + 2\,u\,v} \right)^{\,n - 1} \hfill \\ = 1/2\left( {\left( {1/2 + 2\,u\,v} \right)^{\,n - 1} + \frac{1} {n}\frac{\partial } {{\partial \,v}}\left( {1/2 + 2\,u\,v} \right)^{\,n} } \right) \hfill \\ \end{gathered}$$ and from here integrate by parts and then - or straightly - apply binomial expansion considering that $uv$ is odd in both variables, and so are its odd powers.
Approximation: You may use that either $xy\leq 1/4$ or $(1-x)(1-y)\leq 1/4$. For large $n$ you may then use the approximation $$(xy+(1-x)(1-y))^{n-1} \approx (xy)^{n-1} + ((1-x)(1-y))^{n-1}$$ so that the integral becomes: $$\int_0^1\int_0^1 x (xy)^{n-1} + (1 - (1-x))(1-x)^{n-1}(1-y))^{n-1} \; dx \;dy= \int_0^1\int_0^1 x^{n-1}y^{n-1} \; dx\;dy = \frac{1}{n^2}$$ You may try to compare with numerics (or the Wolfram result) for different $n$ values.
• For $n \le 20$, numerically there seems to be good convergence here. Sep 4, 2016 at 22:20
• OK, in principle should be better the large the value of $n$. Seems also that $n^{2} - \frac12 n^{-3} ...$ might be closer. Sep 4, 2016 at 22:33