Given a 1*1 square.
Find the area of the subset of points that are closer to its center than to any of the square’s sides.
(In reply to
solution by Charlie)
hit=0;
for trial=1:10000000
x=rand-.5;
y=rand-.5;
s=[x+.5 .5-x y+.5 .5-y norm([x y])];
s2=find(s==min(s));
if s2==5
hit=hit+1;
end
end
hit/trial
finds
ans =
0.2189057
agreeing with the analytic answer.
|
Posted by Charlie
on 2024-03-28 19:53:08 |