All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Triangular Cubes II (Posted on 2010-12-21) Difficulty: 2 of 5
Three points have been chosen randomly from the vertices of a tesseract (4-cube).

What is the probability that they form (a) an acute triangle; (b) a right triangle?

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 2

There are 16 vertices on a tesseract. Taken 3 at a time, there are 560 combinations that can be chosen.

The program numbers the vertices 0 through 15 and assigns w, x, y and z positions at all combinations of 0 and 1:

w  x  y  z
0  0  0  0
1  0  0  0
0  1  0  0
1  1  0  0
0  0  1  0
1  0  1  0
0  1  1  0
1  1  1  0
0  0  0  1
1  0  0  1
0  1  0  1
1  1  0  1
0  0  1  1
1  0  1  1
0  1  1  1
1  1  1  1

It checks all 560 possible triplets of these vertices, using the law of cosines to compute each angle. To guard against rounding error leading to non-right angles, if a cosine falls within a small allowable range it's counted as zero, for a right angle.  A check is made on all sums of the angles of the triangle and they each indeed come out to 180 degrees total.

The final count is 400 right triangles and 160 acute triangles, giving probabilities of 400/560 = 5/7 of being right and 160/560 = 2/7 of being acute.

DEFDBL A-Z
pi = ATN(1) * 4
DIM w(15), x(15), y(15), z(15)
CLS

FOR i = 0 TO 15
 w(i) = i MOD 2: PRINT w(i);
 x(i) = (i \ 2) MOD 2: PRINT x(i);
 y(i) = (i \ 4) MOD 2: PRINT y(i);
 z(i) = (i \ 8) MOD 2: PRINT z(i)
NEXT

FOR a = 0 TO 13
FOR b = a + 1 TO 14
FOR c = b + 1 TO 15
  d1 = SQR((w(a) - w(b)) ^ 2 + (x(a) - x(b)) ^ 2 + (y(a) - y(b)) ^ 2 + (z(a) - z(b)) ^ 2)
  d2 = SQR((w(c) - w(b)) ^ 2 + (x(c) - x(b)) ^ 2 + (y(c) - y(b)) ^ 2 + (z(c) - z(b)) ^ 2)
  d3 = SQR((w(a) - w(c)) ^ 2 + (x(a) - x(c)) ^ 2 + (y(a) - y(c)) ^ 2 + (z(a) - z(c)) ^ 2)


  ca1 = (d2 ^ 2 + d3 ^ 2 - d1 ^ 2) / (2 * d2 * d3)
  ca2 = (d1 ^ 2 + d3 ^ 2 - d2 ^ 2) / (2 * d1 * d3)
  ca3 = (d2 ^ 2 + d1 ^ 2 - d3 ^ 2) / (2 * d2 * d1)

  IF ABS(ca1) < .000000001# THEN ca1 = 0
  IF ABS(ca2) < .000000001# THEN ca2 = 0
  IF ABS(ca3) < .000000001# THEN ca3 = 0

  sa1 = SQR(1 - ca1 * ca1)
  sa2 = SQR(1 - ca2 * ca2)
  sa3 = SQR(1 - ca3 * ca3)
  IF ca1 = 0 THEN a1 = 90:  ELSE a1 = 180 * ATN(sa1 / ca1) / pi
  IF ca2 = 0 THEN a2 = 90:  ELSE a2 = 180 * ATN(sa2 / ca2) / pi
  IF ca3 = 0 THEN a3 = 90:  ELSE a3 = 180 * ATN(sa3 / ca3) / pi
  PRINT a1 + a2 + a3;

  IF ca1 = 0 OR ca2 = 0 OR ca3 = 0 THEN
      rtCt = rtCt + 1
  ELSEIF ca1 > 0 AND ca2 > 0 AND ca3 > 0 THEN
      acCt = acCt + 1
  ELSE
      obCt = obCt + 1
  END IF
NEXT
NEXT
NEXT

PRINT rtCt, acCt, obCt

 


  Posted by Charlie on 2010-12-21 13:48:39
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information