A clock has an hour, minute, and second hand, all of length 1. Let T be the triangle formed by the ends of these hands. A time of day is chosen uniformly at random. What is the expected value of the area of T?
The problem is equivalent to placing 3 random points on a unit circle and calculating the area of the resulting triangle. wlog, one point can be considered fixed.
Dividing the circle into 1000 segments yields an answer of:
0.4774632584782688
----------
import math
def area(s1,t1):
""" Assume a and b are degrees between 0 and 360, and
the 3 vertices of a triangle are at (0,1),
(cos s, sin s) and (cos t, sin t)
return the area """
pi = math.pi
s = s1 * pi / 180
t = t1 * pi / 180
x = [0, math.cos(s), math.cos(t), 0]
y = [1, math.sin(s), math.sin(t), 1]
d = []
for i in range(3):
d.append( ( (x[i+1]-x[i])**2 + (y[i+1]-y[i])**2 )**.5 )
semip = sum(d)/2
terms = [ max(semip-d[i],0) for i in range(3)]
ans = ( (semip-d[0])*(semip-d[1])*(semip-d[2])*semip )**.5
ans = ( terms[0] * terms[1] * terms[2] * semip )**.5
return ans
count = 0
total = 0
mesh = 1000
for i in range(mesh):
a = i * 360 / mesh
for j in range(mesh):
b = j * 360 / mesh
count += 1
total += area(a,b)
print(total/count)
|
Posted by Larry
on 2023-08-23 11:33:58 |