# expected area of a triangle determined by randomly placed points

Three points are placed at independently and at random in a unit square. What is the expected value of the area of the triangle formed by the three points?

-
See here and here for related questions and answers. – cardinal Mar 20 '11 at 3:37

This isn't a full solution, but it goes most of the way there.

The area of a triangle $(x_1, y_1),(x_2,y_2),(x_3,y_3)$ is given by the formula

$A(x_1,x_2,x_3,y_1,y_2,y_3)= | \frac{x_1(y_2-y_3) + x_2 (y_3-y_1) + x_3 (y_1-y_2)}{2}|$

If $x_1, x_2, x_3, y_1, y_2, y_3$ are all independently identically uniformly distributed over $[0,1]$, then the average area is just given by:

$\int_0^1 \int_0^1 \int_0^1 \int_0^1 \int_0^1 \int_0^1 A(x_1,x_2,x_3,y_1,y_2,y_3) d x_1 d x_2 d x_3 d y_1 d y_2 d y_3$

At this point, it's a fairly simple, though tedious, calculation. I recommend using Mathematica or some other computational software if you have access to it. There are also ways to simplify the computation based on inherent symmetries in the problem.

I can't post the final answer because I want to avoid giving a wrong answer, which is totally possible (I don't claim to be able to do the above integral by hand without errors). I can check the answer in Mathematica if you don't have access to it, though it will have to wait until at least Monday.

-

See here.

-
to be honest, I haven't read the answer too closely, but I'm a little surprised the argument doesn't fall victim to something like Jensen's inequality. It looks like a "mean-field" like argument to me where the expectation of a function is replaced by a function of the expectation. But, I undoubtedly haven't looked close enough. Like @Sol, I was able to "verify" the answer by Monte Carlo. – cardinal Mar 21 '11 at 13:56
@cardinal: The answer is correct, there's just a small error in the case distinction. The answer is based on the fact that the for fixed orientation area of the triangle is linear in each of the coordinates of the points, since it's the absolute value of a polynomial that's linear in each of the coordinates and changes sign when the orientation changes. Thus the case distinction has to be such that each case only covers triangles with the same orientation. For the case S1, the author seems to have had in mind a mapping from the rectangle formed by $A$ and $C$ to the unit square. (...) – joriki May 9 '13 at 6:57
(...) That may be why in "within the square one of the diagonals of which joins the 2 other points" it says "square" where it should say "rectangle", and, crucially, further down in item 2) the condition is stated as $b\lt v$ where in fact it should say that $B$ is above the diagonal $AC$. With that condition, it's OK to use linearity of expectation, since this is the condition that separates the two orientations of the triangle. – joriki May 9 '13 at 7:01

Here's a perl script that confirms the answer Shai linked to via a Monte Carlo approach.

#!/usr/bin/perl -w

$numTrials = 1000000 ; sub distance { my$point1 = $_[0] ; my$point2 = $_[1] ; return sqrt(($x[$point1]-$x[$point2])**2 + ($y[$point1]-$y[$point2])**2) ; } sub heron { my$a = $legLength[$_[0]] ;
my $b =$legLength[$_[1]] ; my$c = $legLength[$_[2]] ;
my $s = ($a + $b +$c ) / 2 ;
return sqrt( $s * ($s - $a ) * ($s - $b ) * ($s - $c ) ) ; } sub doAtriangle() { for ( my$j = 0; $j <= 2 ;$j++ ) {
$x[$j] = rand(1) ;
$y[$j] = rand(1) ;
}
$legLength[0] = distance(0,1) ;$legLength[1] = distance(1,2) ;
$legLength[2] = distance(2,0) ; return heron(0,1,2) ; } for ($i = 0 ; $i <$numTrials ; $i++ ) {$sum += doAtriangle() ;
}

print $sum/$numTrials . "\n" ;

-
0.5*(+/%#)(([: | [: -/ .* (3 1 \$1) ,.~ 3 2 \$ [: ? 6 # ])"0) 1000000#0 NB. A terse way in J ! – gar Jun 1 '14 at 12:39