Following on from this question:
There are several solutions out there but each has a different outcome.
I'm trying to calculate the expected area of a random triangle with a fixed perimeter of 1.
My initial plan was to create an ellipse where one point on the ellipse is moved around and the triangle that is formed with the foci as the two other vertices (which would have a fixed perimeter) would have all the varying areas. But then I realized that I wouldn't account for ALL triangles using that method. For example, an equilateral triangle with side lengths one third would not be included.
Can anyone suggest how to solve this problem? Thanks.
When I ran a script that randomly selects a triangle with a perimeter of length 1 according to how @Sheheryar Zaidi specified in his answer:
Let $0<x<y<1$ be the points at which the "stick is broken", and so $x, y-x, 1-y$ are the lengths of the three segments. For a triangle to be formed, the sum of any two sides must be greater than the third side. Therefore we get the following inequalities: $$x+(y-x)>1-y \\ (y-x)+(1-y)>x \\ (1-y)+x>y-x$$ Plotting these on a coordinate system gives a triangular region with vertices $(0, 1/2), (1/2, 1/2), (1/2,1)$. So any pair $(x, y)$ contained within that region results in a triangle of perimeter 1. I parameterize these pairs: $$\left(\frac{a_1}{2}, \frac{1+a_2}{2}\right),$$ for $0<a_2<a_1<1$. Now these can be plugged in Heron's formula (and simplified): $$A(a_1, a_2)=\frac{1}{4}\sqrt{(1-a_1)(a_1-a_2)(a_2)}$$
the average area of $10^7$ attempts came out 0.026179216476998588.
The closest result is of @Sheheryar Zaidi, but I do not know what exactly is A(R) in $E(A)=\frac{1}{A(R)}\int_0^1\!\!\!\int_0^{a_1}A(a_1, a_2)\,da_2da_1$.
Here's the Python code:
import random
import math
def areaOfRandomTriangle():
x = random.random()
y = random.uniform(0,x)
A = x/2
B = (1+y)/2 - A
C = 1 - (B+A)
s = (A + B + C)/2
area = math.sqrt(s*(s-A)*(s-B)*(s-C))
return area
n = 10**7
c = 0
for i in range(n):
c += areaOfRandomTriangle()
print('Average Area:',c/n)
Average Area: $0.026179216476998588$
But when I chose the random triangle in another way suggested there - by using an ellipse, i.e .:
- Side A of the triangle is uniformly selected from $[0,\frac{1}{2}]$.
- An ellipse is constructed whose distance between the foci is A (parameters a, b of the ellipse can be found by the condition $2a +A = 1$).
- Select a point from the circumference of the ellipse uniformly as suggested here.
- We will define the other two sides of the triangle B, C to be the distance of the point from the focal points respectively.
- Calculate the area of the triangle A, B, C.
The area average of $10^5$ attempts is $0.02184924698584864$.
So my question is how to choose the triangle randomly and what is the expectation of the area?