x 1 , x 2 , and x 3 are chosen randomly and independently on the interval [ 0 , 2 π ] and let f ( x ) = sin ( x ) .
What is the average area of the triangle created with the three vertices below (to two significant figures)?
P 1 = ( x 1 , f ( x 1 ) ) , P 2 = ( x 2 , f ( x 2 ) ) , P 3 = ( x 3 , f ( x 3 ) )
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Did the Monte-Carlo way an got 0.668537 with 10,000,000,000 samples.
Log in to reply
Agreed - My Monte Carlo ( GCC (and libraries) - double floating points - 7.3.0 x86 architecture) gives 0.66853x on about 10^9 samples. Rounding errors would probably go the other way, not adding very small areas to a very large total accumulator.
numerical integration using mpmath library gives the result of 0.668481 with an error of 1e-7
Wrote a Python program generating pair of three random vertices (x, sin(x)) and calculated the average of area of 10000 random triangles using:
Area=abs[0.5{x1 (y2-y3)+x2 (y3-y1)+x3*(y1-y2)}]
Answer=0.668
Python3 Program on Ubuntu 18.04
import math
import random
n = int(input("Maximal Number? "))
TArea=0
counter = 0
while counter <= n-1:
x1=(2*math.pi)*random.random()
y1=math.sin(x1)
x2=(2*math.pi)*random.random()
y2=math.sin(x2)
x3=(2*math.pi)*random.random()
y3=math.sin(x3)
Area=abs(0.5*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)))
TArea +=Area
counter += 1
print("Answer",TArea/counter)
Same here, and got the value 0.669. My code is almost identical to yours!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
The program below is equivalent to calculating 800^3=512 million triangles, evenly distributed over the range. It is somewhat optimised for speed. I trust the answer upto 5 decimal places: 0.66852....
Some playing with parameter count and considering differences of the calculated values made me realize there a some small, but systematic underestimation due to discrete values being the same more likely than in a true random case. The error in these calculations is an underestimate that diminishes by a factor 4 when count doubles:
count | result | delta |
25 | 0.661540 | |
0.0053 | ||
50 | 0.666807 | |
0.0013 | ||
100 | 0.668096 | |
0.00032 | ||
200 | 0.668419 | |
0.000081 | ||
400 | 0.668500 | |
0.000020 | ||
800 | 0.6685203 |
Considering this, the true value must be close to 0 . 6 6 8 5 2 7 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Using the Shoelace Theorem, we have the area is 2 1 ∣ x 1 sin x 2 + x 2 sin x 3 + x 3 sin x 1 − x 2 sin x 1 − x 3 sin x 2 − x 1 sin x 2 ∣ We then use a program to find the average area to get a value of approximately 0 . 6 7 .
One can find the exact average by executing a triple integral with integrand as the shoelace area mentioned in other answers and parameters of each x value going from 0 to 2pi and dividing by the input volume. This gives exactly two-thirds.
That integral is unsolvable and computing that integral numerically gives about 0.66 or 0.67 .
Unless you show how, this answer must be considered as bluff. And the answer is not exactly 2/3.
area = Function[{a, b, c}, Block[{p1 = {a, Sin[a]}, p2 = {b, Sin[b]}, p3 = {c, Sin[c]}}, Area[ SSSTriangle[ EuclideanDistance[p1, p2], EuclideanDistance[p2, p3], EuclideanDistance[p3, p1]] ] ] ];
z = Table[area @@ t, {t, RandomReal[{0, 2 [Pi]}, {1000000, 3}]}]
z1 = Select[z, # [Element] Reals &]
(* One generated triangle was so degenerate that it failed sum of side test for a triangle. I substituted 0 as its area. *)
Length[z1] is 999 999
Mean[Join[z1, {0.}]] is 0.669701546195
(* Mathematica 11.3 used *)
what are you sying
Log in to reply
I have been a programmer for more than a half century. I gave the source code for the Monte Carlo simulation I used. Line for line not including comments in (* *): 1. Define a function that computes the area of a triangle whose three sides are specified by three points whose x-coordinates are arguments and their y-coordinates by Sin[x-coordinate].
Compute a one million entry table of areas of such triangles.
Select those areas which give real results. There was one triangle that was degenerate.
Add in a zero area for the degenerate triangle and compute the mena of the table.
Q.E.D.
Problem Loading...
Note Loading...
Set Loading...
By the shoelace theorem , the area of the triangle is given by
Δ = 2 ∣ ( x 1 sin x 2 + x 2 sin x 3 + x 3 sin x 1 ) − ( x 2 sin x 1 + x 3 sin x 2 + x 1 sin x 3 ) ∣
The average area can be evaluated numerically either by scanning over the parameter space (ie letting x 1 , x 2 , x 3 each step from 0 to 2 π in small intervals, calculating the area for each of these, then averaging) or with a Monte-Carlo implementation (ie picking a large number of values for x 1 , x 2 , x 3 uniformly at random and again averaging).
The result comes out at 0 . 6 7 , and seems to be a little higher than 3 2 . Did anyone manage to find an exact value without resorting to numerical methods?