Square triangle picking is the selection of triples of points (corresponding to endpoints of a triangle) randomly placed inside a square. random triangles can be picked in a unit square in the Wolfram Language using the function RandomPoint[Rectangle[], n, 3].
Given three points chosen at random inside a unit square, the average area of the triangle determined by these points is given analytically by the multiple integrals
(1)
| |||
(2)
|
Here, represent the polygon vertices of the triangle for , 2, 3, and the (signed) area of these triangles is given by the determinant
(3)
| |||
(4)
|
The solution was first given by Woolhouse (1867). Since attempting to do the integrals by brute force result in intractable integrands, the best approach using computer algebra is to divide the six-dimensional region of integration into subregions using cylindrical algebraic decomposition such that the sign of does not change, do the integral in each region directly, and then combine the results (Trott 1998). Depending on the order in which the integration variables are ordered, between 32 and 4168 regions are obtained. The result of combining these pieces gives the mean triangle area
(5)
|
(Ambartzumian 1987, Pfiefer 1989, Trott 1998; Trott 2006, pp. 303-304).
Once is known, the variance in area is easily calculated by first computing the raw moment ,
(6)
| |||
(7)
|
giving
(8)
| |||
(9)
| |||
(10)
|
The distribution function for the area of a random triangle inscribed in a square is given exactly by
(11)
|
(M. Trott, pers. comm., Jan. 27, 2005; Trott 2006, p. 306). The corresponding distribution function is given by
(12)
|
(Philip).
satisfies the beautiful fourth-order ordinary differential equation
(13)
|
(M. Trott, pers. comm., Jan. 27, 2005; Trott 2006, p. 307).
This gives the beautiful formula for raw moments as
(14)
|
where is a harmonic number, so the raw moments for , 2, ... are 11/144, 1/96, 137/9000, 1/2400, 363/109760, ... (OEIS A093158 and A093159).
A closed form is more difficult to compute for the th central moments , but the first few for , 2, ... are 0, 95/20736, 75979/186624000, 1752451/17915904000, ... (OEIS A103281 and A103282; Trott 2006, p. 307).
A closed form for the probability that a given point lies within a randomly picked triangle can also be obtained as
(15)
|
where
(16)
|
(M. Trott, pers. comm., Jan. 31, 2005; Trott 2006, p. 310). This is expression is valid for and , with the expression over the whole unit square given by symmetry as
(17)
|
As expected, this expression satisfies
(18)
|
Pick three points at random in the unit square, and denote the probability that the three points form an obtuse triangle by . Langford (1969) proved that
(19)
| |||
(20)
|
(OEIS A093072).