Tetrahedron for the HP-41
Overview
0°) Volume of a Tetrahedron
1°) Insphere, Circumsphere and Exspheres
2°) Dihedral Angles
a) Dihedral Angles
b) Volume + Dihedral Angles
3°) Trihedral Angles
4°) Random Tetrahedra
5°) A few Heron Tetrahedra
a) Program#1
b) Program#2 ( Long Integers )
6°) Generating Integer Tetrahedra
-We use the following conventions:
-The edges d , e , f are respectively opposite to a ,
b , c ( non co-planar )
-The edges a , b , c intersect at the same vertex S
C
*
* *
*
*
* d *
*
c *
* e
*
B *
*
*
*
*
b *
* *
* *
f * *
* *
* *
S * *
* * * *
* * * *
* * A
a
0°) Volume of a Tetrahedron
-This program is almost the same as "THV" listed in "Heron Formula and
its generalization"
-But here, R00 and R07 are unused.
-Moreover, a negative number is returned if V2 < 0
to avoid a DATA ERROR in this case
Data Registers: R00 = temp ( Registers R01 thru R06 are to be initialized before executing "THV" )
• R01 = a • R04 = d
• R02 = b • R05 = e
• R03 = c • R06 = f
Flags: /
Subroutines: /
01 LBL "THV" 02 RCL 03 03 X^2 04 4 05 RCL 02 06 X^2 07 STO 00 08 ST* Y 09 RCL 04 10 X^2 |
11 - 12 R^ 13 ST* Z 14 + 15 STO Z 16 X^2 17 - 18 RCL 01 19 X^2 20 ST+ 00 |
21 ST* Y 22 R^ 23 + 24 RCL 05 25 X^2 26 - 27 ST* Z 28 RCL 02 29 * 30 X^2 |
31 - 32 RCL 00 33 RCL 06 34 X^2 35 - 36 ST* Z 37 RCL 03 38 * 39 X^2 40 - |
41 + 42 SIGN 43 LASTX 44 ABS 45 SQRT 46 * 47 12 48 / 49 END |
( 65 bytes / SIZE 007 )
STACK | INPUT | OUTPUT |
X | / | Volume |
---Execution time = 2s---
Example1: a = 6 b = 7 c = 8 d = 9 e = 10 f = 11
-Store these 6 numbers into R01 thru R06
XEQ "THV" >>>> V = 48
Example2: a = 3 b = 5 c = 7 d = 6 e = 8 f = 2
-Store these 6 numbers into R01 thru R06
XEQ "THV" >>>> V = -12
-Since the result is "negative" ( actually V = 12 i ) this
is not a real tetrahedron !
1°) Insphere, Circumsphere and Exspheres
-Given the 6 sides of a tetrahedron a , b , c , d , e , f , this program
computes the volume V of the tetrahedron,
and the radii r , R , r1 , r2 , r3
, r4 of the insphere, the circumsphere and the 4 exspheres.
-There are 3 other "exterior" spheres that are not calculated by this routine
- though they could be...
Formulae:
-The areas W , X , Y , Z of the 4 faces ABC , SBC , SCA , SAB
are calculated by Héron's formula.
V is computed by the formula given in "Héron's Formula and
its Generalization for the HP-41"
-Let P = ( a d + b e + c f ) / 2 we have R = circumradius = (1/(6V)) [ P ( P - a d ) ( P - b e ) ( P - c f ) ] 1/2
W + X + Y + Z = 3V/r and
-W + X + Y + Z = 3V/r1
W - X + Y + Z = 3V/r2
W + X - Y + Z = 3V/r3
W + X + Y - Z = 3V/r4
Data Registers: R00 = 3 V ( Registers R01 thru R06 are to be initialized before executing "THVR" )
• R01 = a • R04 = d
R07 = r1 R09 = r3
R11 thru R13: temp
• R02 = b • R05 = e
R08 = r2 R10 = r4
R14 = r
• R03 = c • R06 = f
Flags: /
Subroutines: /
01 LBL "THVR" 02 RCL 01 03 X^2 04 STO 08 05 RCL 06 06 X^2 07 - 08 RCL 02 09 X^2 10 STO 09 11 ST+ Y 12 RCL 04 13 X^2 14 - 15 RCL 03 16 X^2 17 STO 10 18 + 19 STO 07 20 RCL 08 21 LASTX 22 + 23 RCL 05 24 X^2 25 - 26 STO 00 27 * 28 X<>Y 29 RCL 10 30 * 31 - |
32 * 33 RCL 09 34 RCL 10 35 * 36 4 37 * 38 RCL 07 39 X^2 40 - 41 RCL 08 42 * 43 + 44 RCL 00 45 RCL 02 46 * 47 X^2 48 - 49 SQRT 50 4 51 / 52 STO 00 53 RCL 04 54 RCL 05 55 RCL 06 56 XEQ 00 57 STO 10 58 RCL 02 59 RCL 03 60 RCL 04 61 XEQ 00 62 STO 11 |
63 RCL 01 64 RCL 03 65 RCL 05 66 XEQ 00 67 STO 12 68 RCL 01 69 RCL 02 70 RCL 06 71 XEQ 00 72 STO 13 73 GTO 01 74 LBL 00 75 STO 13 76 X<>Y 77 ST+ 13 78 X<> Z 79 ST+ 13 80 2 81 ST/ 13 82 X<> 13 83 ST- Y 84 ST- Z 85 ST- T 86 * 87 * 88 * 89 CHS 90 SQRT 91 RTN 92 LBL 01 93 RCL 00 |
94 X<>Y 95 RCL 10 96 RCL 11 97 + 98 + 99 RCL 12 100 + 101 / 102 STO 14 103 CLX 104 RCL 11 105 RCL 12 106 + 107 RCL 13 108 + 109 RCL 10 110 - 111 / 112 STO 07 113 CLX 114 RCL 10 115 RCL 11 116 - 117 RCL 12 118 + 119 RCL 13 120 + 121 / 122 STO 08 123 CLX 124 RCL 10 |
125 RCL 11 126 + 127 STO 09 128 RCL 12 129 ST+ 09 130 - 131 RCL 13 132 ST- 09 133 + 134 / 135 X<> 09 136 / 137 STO 10 138 RCL 01 139 RCL 04 140 * 141 RCL 02 142 RCL 05 143 * 144 RCL 03 145 RCL 06 146 * 147 XEQ 00 148 2 149 / 150 RCL 14 151 RCL 00 152 ST/ Z 153 3 154 / 155 END |
( 188 bytes / SIZE 015
)
STACK | INPUTS | OUTPUTS |
Z | / | R |
Y | / | r |
X | / | Volume |
---Execution time = 8 seconds---
Example: a = 3 b = 5 c = 7 d = 6 e = 8 f = 4
3 STO 01 6 STO 04
5 STO 02 8 STO 05
7 STO 03 4 STO 06
XEQ "THVR" >>>> V = 8.426149777
Volume
RDN r = 0.591887583
Insphere
RDN R = 4.350408756
Circumsphere
and the radii of the 4 exspheres
R07 = 1.298308607 = r1
R08 = 1.898591600 = r2
R09 = 1.153025424 = r3
R10 = 0.823182564 = r4
Notes:
-Lines 56-61-66-71-147 may be replaced by XEQ "HERON"
-In this case, delete lines 73 to 92.
Data Registers: R00 = 6 V ( Registers R01 thru R06 are to be initialized before executing "THVR" )
• R01 = a • R04 = d
R07 thru R10: temp
• R02 = b • R05 = e
• R03 = c • R06 = f
Flags: /
Subroutines: /
01 LBL "THVR" 02 1 03 RCL 02 04 X^2 05 RCL 03 06 X^2 07 + 08 RCL 04 09 X^2 10 - 11 RCL 02 12 RCL 03 13 * 14 ST+ X 15 / 16 STO 07 17 X^2 18 - 19 RCL 01 20 X^2 21 RCL 03 22 X^2 23 + 24 RCL 05 25 X^2 26 - 27 RCL 01 28 RCL 03 29 * 30 ST+ X 31 / |
32 STO 08 33 X^2 34 - 35 RCL 01 36 X^2 37 RCL 02 38 X^2 39 + 40 RCL 06 41 X^2 42 - 43 RCL 01 44 RCL 02 45 * 46 STO 10 47 ST+ X 48 / 49 STO 09 50 X^2 51 - 52 RCL 07 53 RCL 08 54 RCL 09 55 * 56 * 57 ST+ X 58 + 59 SQRT 60 STO 00 61 RCL 08 62 RCL 09 |
63 * 64 RCL 07 65 - 66 RCL 02 67 / 68 RCL 07 69 RCL 09 70 * 71 RCL 08 72 - 73 RCL 01 74 / 75 + 76 RCL 03 77 ST* 00 78 / 79 RCL 07 80 RCL 08 81 * 82 RCL 09 83 - 84 RCL 10 85 ST* 00 86 / 87 + 88 ST+ X 89 RCL 07 90 ACOS 91 SIN 92 RCL 01 93 / |
94 STO 07 95 X^2 96 + 97 RCL 08 98 ACOS 99 SIN 100 RCL 02 101 / 102 STO 08 103 X^2 104 + 105 RCL 09 106 ACOS 107 SIN 108 RCL 03 109 / 110 STO 09 111 X^2 112 + 113 SQRT 114 RCL 07 115 + 116 RCL 08 117 + 118 RCL 09 119 + 120 / 121 RCL 01 122 RCL 04 123 * 124 STO 07 |
125 RCL 02 126 RCL 05 127 * 128 STO 08 129 + 130 RCL 03 131 RCL 06 132 * 133 STO 09 134 + 135 2 136 / 137 ENTER 138 STO 10 139 RCL 07 140 - 141 * 142 RCL 10 143 RCL 08 144 - 145 * 146 RCL 10 147 RCL 09 148 - 149 * 150 SQRT 151 RCL 00 152 ST/ Y 153 6 154 / 155 END |
( 172 bytes / SIZE 011
)
STACK | INPUTS | OUTPUTS |
Z | / | r |
Y | / | R |
X | / | Volume |
Example: a = 3 b = 5
c = 7 d = 6 e = 8 f = 4
3 STO 01 6 STO 04
5 STO 02 8 STO 05
7 STO 03 4 STO 06
XEQ "THVR" >>>> V = 8.426149773
Volume
---Execution time = 8s---
RDN R = 4.350408756
Circumsphere
RDN r = 0.591887583
Insphere
2°) Dihedral Angles
a) Dihedral Angles
-Let be A , B , C , D , E , F
the 6 dihedral angles corresponding to the edges SA , SB , SC , BC
, AC , AB.
-With the same notations as above, we have:
W2 + X2 - 2 W.X Cos D = Y2
+ Z2 - 2 Y.Z Cos A = [ 4 a2d2 -
( b2 - c2 + e2 - f2 )2
] / 16
W2 + Y2 - 2 W.Y Cos E = Z2
+ X2 - 2 Z.X Cos B = [ 4 b2e2
- ( c2 - a2 + f2 - d2 )2
] / 16
W2 + Z2 - 2 W.Z Cos F =
X2 + Y2 - 2 X.Y Cos C = [ 4 c2f2
- ( a2 - b2 + d2 - e2 )2
] / 16
Data Registers: R00 = W ( Registers R01 thru R06 are to be initialized before executing "THDA" )
• R01 = a • R04 = d
R07 = A R10 = D
R13 = X
• R02 = b • R05 = e
R08 = B R11 = E
R14 = Y
• R03 = c • R06 = f
R09 = C R12 = F
R15 = Z
Flags: /
Subroutine: "HERON" ( cf "Héron's
Formula and its Generalization for the HP-41" )
01 LBL "THDA" 02 RCL 02 03 RCL 03 04 RCL 04 05 XEQ "HERON" 06 STO 13 07 RCL 01 08 RCL 03 09 RCL 05 10 XEQ "HERON" 11 STO 14 12 RCL 01 13 RCL 02 14 RCL 06 15 XEQ "HERON" 16 STO 15 17 RCL 04 18 RCL 05 19 RCL 06 20 XEQ "HERON" 21 STO 00 22 RCL 03 23 X^2 24 RCL 01 |
25 X^2 26 - 27 RCL 06 28 X^2 29 + 30 RCL 04 31 X^2 32 - 33 X^2 34 RCL 02 35 RCL 05 36 * 37 ST+ X 38 X^2 39 - 40 16 41 / 42 STO 08 43 RCL 13 44 RCL 15 45 XEQ 01 46 X<> 08 47 RCL 00 48 RCL 14 |
49 XEQ 01 50 STO 11 51 RCL 01 52 X^2 53 RCL 02 54 X^2 55 - 56 RCL 04 57 X^2 58 + 59 RCL 05 60 X^2 61 - 62 X^2 63 RCL 03 64 RCL 06 65 * 66 ST+ X 67 X^2 68 - 69 16 70 / 71 STO 09 72 RCL 13 |
73 RCL 14 74 XEQ 01 75 X<> 09 76 RCL 00 77 RCL 15 78 XEQ 01 79 STO 12 80 RCL 02 81 X^2 82 RCL 03 83 X^2 84 - 85 RCL 05 86 X^2 87 + 88 RCL 06 89 X^2 90 - 91 X^2 92 RCL 01 93 RCL 04 94 * 95 ST+ X 96 X^2 |
97 - 98 16 99 / 100 STO 10 101 RCL 00 102 RCL 13 103 XEQ 01 104 X<> 10 105 RCL 14 106 RCL 15 107 LBL 01 108 STO T 109 X^2 110 X<>Y 111 ST* T 112 X^2 113 + 114 + 115 X<>Y 116 ST+ X 117 / 118 ACOS 119 STO 07 120 END |
( 175 bytes / SIZE 016
)
STACK | INPUT | OUTPUT |
X | / | A |
---Execution time = 12 seconds---
Example: a = 3 b = 5 c = 7 d = 6 e = 8 f = 4
3 STO 01 6 STO 04
5 STO 02 8 STO 05
7 STO 03 4 STO 06
XEQ "THDA" >>>> A = 37°45260641 = R07 and
R08 = B = 134°2207078
R09 = C = 35°39909117
R10 = D = 26°36558508
R11 = E = 123°1336864
R12 = F = 46°48611259
Notes:
-You will get these results if your HP-41 is in DEG mode.
-"THDA" works in all angular modes.
b) Volume + Dihedral
Angles
-The program above may be completed to get the volume of the tetrahedron
by the following formula:
V2 = (2/9) X.Y.Z ( 1 - 2 Cos A Cos
B Cos C - Cos2 A - Cos2B
- Cos2 C )
Data Registers: R00 = Volume ( Registers R01 thru R06 are to be initialized before executing "THVDA" )
• R01 = a • R04 = d
R07 = A R10 = D
R13 = X R16 = W R17: temp
• R02 = b • R05 = e
R08 = B R11 = E
R14 = Y
• R03 = c • R06 = f
R09 = C R12 = F
R15 = Z
Flags: /
Subroutine: "HERON" ( cf "Héron's
Formula and its Generalization for the HP-41" )
01 LBL "THVDA" 02 RCL 02 03 RCL 03 04 RCL 04 05 XEQ "HERON" 06 STO 13 07 RCL 01 08 RCL 03 09 RCL 05 10 XEQ "HERON" 11 STO 14 12 RCL 01 13 RCL 02 14 RCL 06 15 XEQ "HERON" 16 STO 15 17 RCL 04 18 RCL 05 19 RCL 06 20 XEQ "HERON" 21 STO 16 22 RCL 03 23 X^2 24 RCL 01 25 X^2 26 - 27 RCL 06 28 X^2 29 + 30 RCL 04 31 X^2 32 - |
33 X^2 34 RCL 02 35 RCL 05 36 * 37 ST+ X 38 X^2 39 - 40 16 41 / 42 STO 12 43 RCL 13 44 RCL 15 45 XEQ 01 46 STO 08 47 LASTX 48 STO 00 49 X^2 50 STO 17 51 RCL 12 52 RCL 14 53 RCL 16 54 XEQ 01 55 STO 11 56 RCL 01 57 X^2 58 RCL 02 59 X^2 60 - 61 RCL 04 62 X^2 63 + 64 RCL 05 |
65 X^2 66 - 67 X^2 68 RCL 03 69 RCL 06 70 * 71 ST+ X 72 X^2 73 - 74 16 75 / 76 STO 12 77 RCL 13 78 RCL 14 79 XEQ 01 80 STO 09 81 LASTX 82 ST* 00 83 X^2 84 ST+ 17 85 RCL 12 86 RCL 15 87 RCL 16 88 XEQ 01 89 STO 12 90 RCL 02 91 X^2 92 RCL 03 93 X^2 94 - 95 RCL 05 96 X^2 |
97 + 98 RCL 06 99 X^2 100 - 101 X^2 102 RCL 01 103 RCL 04 104 * 105 ST+ X 106 X^2 107 - 108 16 109 / 110 STO 10 111 RCL 14 112 RCL 15 113 XEQ 01 114 STO 07 115 LASTX 116 ST* 00 117 X^2 118 ST+ 17 119 RCL 10 120 RCL 13 121 RCL 16 122 XEQ 01 123 STO 10 124 GTO 02 125 LBL 01 126 STO T 127 X^2 128 X<>Y |
129 ST* T 130 X^2 131 + 132 + 133 X<>Y 134 ST+ X 135 / 136 ACOS 137 RTN 138 LBL 02 139 SIGN 140 RCL 00 141 ST+ X 142 - 143 RCL 17 144 - 145 SQRT 146 RCL 13 147 RCL 14 148 RCL 15 149 * 150 * 151 ST+ X 152 * 153 SQRT 154 3 155 / 156 STO 00 157 END |
( 225 bytes / SIZE
018 )
STACK | INPUT | OUTPUT |
X | / | V |
---Execution time = 14 seconds---
Example: a = 3 b = 5 c = 7 d = 6 e = 8 f = 4
3 STO 01 6 STO 04
5 STO 02 8 STO 05
7 STO 03 4 STO 06
XEQ "THVDA" >>>> V = 8.426149767
R07 = A = 37°45260641
R08 = B = 134°2207078
R09 = C = 35°39909117
R10 = D = 26°36558508
R11 = E = 123°1336864
R12 = F = 46°48611259
Note:
-"THVDA" works in all angular modes.
3°) Trihedral Angles
-The solid angle ( or trihedral angle ) S is given by the formula:
Tan (S/2) = 6.V / [ ( a.b ) c + ( b.c ) a + ( c.a ) b + abc ] where . = dot product and a = SA , b = SB , c = SC
-The 3 other trihedral angles A , B , C are computed by similar
formulae but "THTA" changes the order of a , b , c , d , e , f in registers
R01 thru R06.
-The original contents of these registers are restored at the end.
-The volume V of the tetrahedron is also calculated and stored in R00.
Data Registers: R00 = Volume ( Registers R01 thru R06 are to be initialized before executing "THTA" )
• R01 = a • R04 = d
R07 = S R08 = A
R09 = B R10 = C
• R02 = b • R05 = e
• R03 = c • R06 = f
Flags: /
Subroutine: "THV" ( cf "Héron's
Formula and its Generalization for the HP-41" paragraph 2°-a) or this
page paragraph 0 )
01 LBL "THTA" 02 XEQ "THV" 03 STO 00 04 XEQ 01 05 STO 08 06 XEQ 01 07 STO 09 08 XEQ 01 09 STO 10 10 XEQ 01 11 STO 07 12 RCL 10 13 RCL 09 14 RCL 08 |
15 R^ 16 RTN 17 LBL 01 18 RCL 01 19 X<> 03 20 X<> 04 21 X<> 06 22 STO 01 23 RCL 02 24 X<> 05 25 STO 02 26 RCL 06 27 XEQ 02 28 RCL 03 |
29 * 30 RCL 02 31 RCL 03 32 RCL 04 33 XEQ 02 34 RCL 01 35 * 36 + 37 RCL 01 38 RCL 03 39 RCL 05 40 XEQ 02 41 RCL 02 42 * |
43 + 44 RCL 01 45 RCL 02 46 RCL 03 47 * 48 * 49 ST+ X 50 + 51 RCL 00 52 12 53 * 54 X<>Y 55 R-P 56 X<>Y |
57 ST+ X 58 RTN 59 LBL 02 60 X^2 61 CHS 62 X<>Y 63 X^2 64 + 65 X<>Y 66 X^2 67 + 68 END |
( 102 bytes / SIZE
011 )
STACK | INPUTS | OUTPUTS |
T | / | C |
Z | / | B |
Y | / | A |
X | / | S |
---Execution time = 12 seconds---
Example: a = 3 b = 5 c = 7 d = 6 e = 8 f = 4
3 STO 01 6 STO 04
5 STO 02 8 STO 05
7 STO 03 4 STO 06
XEQ "THTA" >>>> S = 27°07240548
= R07
RDN A = 27°07240548 = R08
RDN B = 27°07240548 = R09
RDN C = 4°898362738 = R10
and R00 = V = 8.426149775
Notes:
-"THTA" works in all angular modes.
-It stops at line 16.
-We always have: 2 x SUM ( dihedral angles ) -
SUM ( trihedral angles ) = 720°
4°) Random Tetrahedra
-You specify 2 integers N & M, and your HP-41 returns a tetrahedron
with integer edge lengths a , b , c between N and M
( exclusive )
and integer d , e , f such that the tetrahedron does
exist.
-Place a random seed in R00 before executing "RANT"
Data Registers: • R00 = Random seed ( Register R00 is to be initialized before executing "RANT" )
R01 = a R04 = d
R07 to R09: temp
R02 = b R05 = e
R03 = c R06 = f
Flags: /
Subroutine: "THV" ( cf paragraph
0 above )
01 LBL "RANT" 02 X>Y? 03 X<>Y 04 1 05 + 06 STO 07 07 - 08 STO 08 09 LBL 01 10 6 11 STO 09 12 RCL 07 13 RCL 08 14 XEQ 00 15 STO 01 16 RCL 07 17 RCL 08 |
18 XEQ 00 19 STO 02 20 RCL 07 21 RCL 08 22 XEQ 00 23 STO 03 24 RCL 02 25 ST+ Y 26 RCL 03 27 - 28 ABS 29 1 30 + 31 STO Z 32 - 33 XEQ 00 34 STO 04 |
35 RCL 03 36 RCL 01 37 ST+ Y 38 RCL 03 39 - 40 ABS 41 1 42 + 43 STO Z 44 - 45 XEQ 00 46 STO 05 47 RCL 01 48 RCL 02 49 + 50 RCL 04 51 RCL 05 |
52 + 53 X>Y? 54 X<>Y 55 RCL 01 56 RCL 02 57 - 58 ABS 59 RCL 04 60 RCL 05 61 - 62 ABS 63 X>Y? 64 X<>Y 65 SIGN 66 + 67 STO Z 68 - |
69 LBL 00 70 RCL 00 71 R-D 72 FRC 73 STO 00 74 * 75 INT 76 + 77 DSE 09 78 RTN 79 STO 06 80 XEQ "THV" 81 X<0? 82 GTO 01 83 END |
( 113
bytes / SIZE 010 )
STACK | INPUT | OUTPUT |
Y | N | / |
X | M | V |
With N < M - 1
Example: random seed = 1 N = 10 M = 100
1 STO 00
10 ENTER^
100 XEQ "RANT" >>>> V = 37246.9581
---Execution time = 12s---
and we find in registers R01 to R06 ( a b c
d e f ) = ( 47 60 86 115
88 86 )
Notes:
-The edges lengths d e f are not always between
N & M
-After calculating "random edges lengths" satisfying all the triangle inequalities,
"RANT" calls "THV"
-If the volume is "negative" - in fact imaginary - another tetrahedron is
computed until V > 0
5°) A few Heron Tetrahedra
a) Program#1
-Many formulae may be found in reference [5] to get "Heronian" tetrahedra, i-e whose edges lengths, surface areas and volume are integers
"HERT" employs one of these formulae, where p is a positive integer, p > 2
a = d = ( p2 + 25 ) ( 2 p2 + 1 ) ( 16 p4
+ 9 p2 + 25 )
b = e = 2 ( p2 - 3 ) ( p2 + 4 ) ( 65 p4
+ 58 p2 + 25 )
c = f = 7 ( p2 + 1 ) ( 9 p2 + 1 ) ( 2 p4
+ 2 p2 + 25 )
Data Registers: R00 = unused
R01 = a R04 = d = a
R07 = Volume
R02 = b R05 = e = b
R03 = c R06 = f = c
Flags: /
Subroutine: "THV" ( cf paragraph 0 above
)
01 LBL "HERT" 02 X^2 03 STO 07 04 ST+ X 05 1 06 + 07 RCL 07 08 25 09 + 10 * 11 RCL 07 12 16 13 * 14 9 |
15 + 16 RCL 07 17 * 18 25 19 + 20 * 21 STO 01 22 STO 04 23 RCL 07 24 65 25 * 26 58 27 + 28 RCL 07 |
29 * 30 25 31 + 32 RCL 07 33 4 34 + 35 * 36 RCL 07 37 3 38 - 39 * 40 ST+ X 41 STO 02 42 STO 05 |
43 RCL 07 44 1 45 + 46 ST+ X 47 RCL 07 48 * 49 25 50 + 51 RCL 07 52 9 53 * 54 1 55 + 56 * |
57 RCL 07 58 1 59 + 60 * 61 7 62 * 63 STO 03 64 STO 06 65 XEQ "THV" 66 STO 07 67 RCL 03 68 RCL 02 69 RCL 01 70 END |
( 93 bytes / SIZE 008 )
STACK | INPUT | OUTPUT |
T | / | V |
Z | / | c |
Y | / | b |
X | p | a |
where p > 2 is an integer
Example: p = 7
7 XEQ "HERT" >>>>
a = d = 284849532
---Execution time = 5s---
RDN b = e = 774952432
RDN c = f = 761897500
RDN V = 9.717195725 E24
-Actually, the exact volume = 9717195754820025574502400
Note:
-Unfortunately, the edge-lengths rapidly become > E10 , so we only have
approximate values of a , b , c
b) Program#2 ( Long
Integers )
-Given an integer p > 1 , "LHERT" calculates the 6 edges a , b , c , d , e , f with the formulas hereunder
a = 2p(p^4 + 2p^3 - 2p + 1)(p^12 + 4p^11 + 6p^10 + 4p^9 + 3p^8 + 16p^7
+ 12p^6 - 16p^5 + 3p^4 - 4p^3 + 6p^2 - 4p + 1)
b = (p^2 + 1)(p^2 + 2p - 1)^2 (p^4 + 1) (p^8 + 2p^7 + 2p^6 + 6p^5 + 2p^4
- 6p^3 + 2p^2 - 2p + 1)
c = (p^2 + 1)(p^2 + 2p - 1) (p^4 - 4p^2 + 1) (p^4 + 2p^3 + 2p^2 - 2p + 1)(p^6
+ 2p^5 + 3p^4 - 3p^2 + 2p - 1).
d = 4p(p + 1)(p - 1)(p^2 + 1)(p^2 + 2p - 1)(p^3 + p^2 + p - 1) (p^3 + p^2
- p + 1)(p^4 + 2p^3 - 2p + 1),
e = (p + 1)(p - 1)(p^3 + p^2 + p - 1)(p^3 + p^2 - p + 1) (p^5 + p^4 + 4p^2
- 3p + 1)(p^5 + 3p^4 + 4p^3 + p - 1),
f = (p + 1)^2 (p - 1)^2 (p^3 + p^2 + p - 1)(p^3 + p^2 - p + 1) (p^4 + 4p^2
- 4p + 1)(p^4 + 4p^3 + 4p^2 + 1)
-The results are stored by groups of 4 digits
-When the program stops, R01 thru R06 contain the control numbers of the
6 edges a , b , c , d , e , f
Data Registers: R00 temp
R01 = bbb.eee(a)
R04 = bbb.eee(d)
R07 .....
R02 = bbb.eee(b)
R05 = bbb.eee(e)
R03 = bbb.eee(c)
R06 = bbb.eee(f)
Flags: /
Subroutines: /
01 LBL "LHERT" 02 CLRG 03 STO 01 04 9.008 05 STO 00 06 E4 07 STO 07 08 SIGN 09 XEQ 00 10 6 11 XEQ 00 12 15 13 XEQ 00 14 20 15 XEQ 00 16 CLX 17 XEQ 00 18 56 19 CHS 20 XEQ 00 21 64 22 CHS 23 XEQ 00 24 28 25 XEQ 00 26 78 27 XEQ 00 28 4 29 XEQ 00 30 78 31 CHS 32 XEQ 00 33 28 34 XEQ 00 35 64 36 XEQ 00 37 56 38 CHS 39 XEQ 00 40 CLX 41 XEQ 00 42 20 43 XEQ 00 44 15 45 CHS 46 XEQ 00 47 6 48 XEQ 00 49 1 50 ST- IND 00 51 RCL IND 00 52 X<0? 53 XEQ 02 54 RCL 00 55 STO 06 |
56 XEQ 04 57 1 58 XEQ 00 59 6 60 XEQ 00 61 15 62 XEQ 00 63 20 64 XEQ 00 65 16 66 XEQ 00 67 8 68 XEQ 00 69 16 70 CHS 71 XEQ 00 72 36 73 CHS 74 XEQ 00 75 18 76 CHS 77 XEQ 00 78 4 79 XEQ 00 80 18 81 XEQ 00 82 36 83 CHS 84 XEQ 00 85 16 86 XEQ 00 87 8 88 XEQ 00 89 16 90 CHS 91 XEQ 00 92 20 93 XEQ 00 94 15 95 CHS 96 XEQ 00 97 6 98 XEQ 00 99 1 100 ST- IND 00 101 RCL IND 00 102 X<0? 103 XEQ 02 104 RCL 00 105 STO 05 106 XEQ 04 107 4 108 XEQ 00 109 24 110 XEQ 00 |
111 48 112 XEQ 00 113 24 114 XEQ 00 115 40 116 CHS 117 XEQ 00 118 56 119 CHS 120 XEQ 00 121 16 122 CHS 123 XEQ 00 124 8 125 XEQ 00 126 CLX 127 XEQ 00 128 8 129 XEQ 00 130 16 131 XEQ 00 132 56 133 CHS 134 XEQ 00 135 40 136 XEQ 00 137 24 138 XEQ 00 139 48 140 CHS 141 XEQ 00 142 24 143 XEQ 00 144 4 145 CHS 146 XEQ 00 147 RCL 00 148 STO 04 149 XEQ 04 150 1 151 XEQ 00 152 6 153 XEQ 00 154 13 155 XEQ 00 156 4 157 XEQ 00 158 44 159 CHS 160 XEQ 00 161 E2 162 CHS 163 XEQ 00 164 84 165 CHS |
166 XEQ 00 167 4 168 XEQ 00 169 50 170 XEQ 00 171 CLX 172 XEQ 00 173 50 174 XEQ 00 175 4 176 CHS 177 XEQ 00 178 84 179 CHS 180 XEQ 00 181 E2 182 XEQ 00 183 44 184 CHS 185 XEQ 00 186 4 187 CHS 188 XEQ 00 189 13 190 XEQ 00 191 6 192 CHS 193 XEQ 00 194 1 195 ST+ IND 00 196 RCL IND 00 197 RCL 07 198 X<=Y? 199 XEQ 02 200 RCL 00 201 STO 03 202 XEQ 04 203 1 204 XEQ 00 205 6 206 XEQ 00 207 13 208 XEQ 00 209 20 210 XEQ 00 211 36 212 XEQ 00 213 28 214 XEQ 00 215 4 216 CHS 217 XEQ 00 218 20 219 XEQ 00 220 18 |
221 XEQ 00 222 CLX 223 XEQ 00 224 18 225 XEQ 00 226 20 227 CHS 228 XEQ 00 229 4 230 CHS 231 XEQ 00 232 28 233 CHS 234 XEQ 00 235 36 236 XEQ 00 237 20 238 CHS 239 XEQ 00 240 13 241 XEQ 00 242 6 243 CHS 244 XEQ 00 245 1 246 ST+ IND 00 247 RCL IND 00 248 RCL 07 249 X<=Y? 250 XEQ 02 251 RCL 00 252 STO 02 253 XEQ 04 254 2 255 XEQ 00 256 12 257 XEQ 00 258 28 259 XEQ 00 260 28 261 XEQ 00 262 8 263 XEQ 00 264 28 265 XEQ 00 266 84 267 XEQ 00 268 12 269 XEQ 00 270 116 271 CHS 272 XEQ 00 273 12 274 CHS 275 XEQ 00 |
276 84 277 XEQ 00 278 28 279 CHS 280 XEQ 00 281 8 282 XEQ 00 283 28 284 CHS 285 XEQ 00 286 28 287 XEQ 00 288 12 289 CHS 290 XEQ 00 291 2 292 XEQ 00 293 RCL 00 294 STO 01 295 6 296 STO 07 297 GTO 10 298 LBL 00 299 ST+ IND 00 300 RCL 00 301 RCL 01 302 LBL 01 303 ST* IND Y 304 DSE Y 305 GTO 01 306 RCL 00 307 FRC 308 E3 309 * 310 SIGN 311 CLX 312 STO IND L 313 LBL 02 314 RCL 00 315 ENTER^ 316 DSE X 317 LBL 03 318 RCL IND Y 319 RCL 07 320 MOD 321 ENTER^ 322 X<> IND T 323 X<>Y 324 - 325 RCL 07 326 / 327 ST+ IND Y 328 CLX 329 SIGN 330 - |
331 DSE Y 332 GTO 03 333 X<>Y 334 INT 335 RCL IND X 336 X=0? 337 RTN 338 CLX 339 RCL 00 340 INT 341 1 342 + 343 RCL Y 344 - 345 E6 346 / 347 RCL Y 348 1 349 + 350 E3 351 / 352 + 353 + 354 REGMOVE 355 SIGN 356 ST+ 00 357 RTN 358 LBL 04 359 INT 360 1 361 + 362 STO Y 363 E3 364 / 365 + 366 1 367 + 368 STO 00 369 RTN 370 LBL 10 371 RCL IND 07 372 INT 373 LASTX 374 FRC 375 E3 376 ST/ Z 377 * 378 + 379 1 380 + 381 STO IND 07 382 DSE 07 383 GTO 10 384 END |
( 737 bytes
/ SIZE ??? )
STACK | INPUT | OUTPUT |
X | p | bbb.eee(a) |
Where p is an integer 1 < p < 10000
Example: p = 234
234 XEQ "LHERT" >>>> 69.079 ---Execution time = 9m29s---
R01 = 69.079
R04 = 33.043
R02 = 57.067
R05 = 21.031
R03 = 45.055
R06 = 9.019
-We find
R69 = 3 R70 = 8797 R71 = 4935 R72 = 7367 R73 = 2970 R74 = 6049 R75 = 9176 R76 = 2143 R77 = 798 R78 = 4873 R79 = 3892
Whence a = 38797493573672970604991762143079848733892 ( add zeros on the left if there are less than 4 digits: read R77 = 0798 )
-Likewise:
b = 4539228059547741416707179684330872726594233
R57 thru R67
c = 4539222415350617449572046369482903812700217
R45 thru R55
d = 77592176903527612114094036950894833445560
R33 thru R43
e = 4539389645667656502320511122916828671774015
R21 thru R31
f = 4539389621650236893157740238374801941709375
R09 thru R19
Notes:
-If p < 10000 , SIZE 122 is enough.
-"LHERT" should also work if p is a little > 10000
-I let you check that the faces areas and the volume are integers too...
6°) Generating Integer Tetrahedra
-Here, you specify a , b , c and "ITH" searches for
integers d , e , f that produce a tetrahedron with an integer
volume V
-Then, it returns - if any - the integer volume V corresponding to
the edges lengths ( a , b , c, d , e , f )
Data Registers: R00 = 4 b2 c2
R01 = a R04 = d
R07 = a2 + b2
R10 = max(d) + 1
R13 = min(e)
R02 = b R05 = e
R08 = a2 + c2
R11 = max(e) + 1
R14 = 12
R03 = c R06 = f
R09 = b2 + c2
R12 = max(f) + 1
R15 = 1
Flags: /
Subroutine: /
01 LBL "ITH" 02 STO 03 03 X^2 04 STO 08 05 X<>Y 06 STO 02 07 X^2 08 STO 07 09 + 10 STO 09 11 X<>Y 12 STO 01 13 X^2 14 ST+ 07 15 ST+ 08 16 RCL 02 17 RCL 03 18 * 19 ST+ X 20 X^2 21 STO 00 22 RCL 02 23 RCL 03 24 + 25 STO 10 26 RCL 02 27 RCL 03 28 - 29 ABS |
30 1 31 STO 15 32 + 33 STO 04 34 RCL 01 35 RCL 03 36 - 37 ABS 38 RCL 15 39 + 40 STO 05 41 STO 13 42 RCL 01 43 RCL 03 44 + 45 STO 11 46 12 47 STO 14 48 LBL 01 49 RCL 01 50 RCL 02 51 - 52 ABS 53 RCL 04 54 RCL 05 55 - 56 ABS 57 X<Y? 58 X<>Y |
59 RCL 15 60 + 61 STO 06 62 RCL 01 63 RCL 02 64 + 65 RCL 04 66 RCL 05 67 + 68 X<Y? 69 X<>Y 70 RDN 71 X<Y? 72 GTO 03 73 STO 12 74 LBL 02 75 RCL 00 76 RCL 09 77 RCL 04 78 X^2 79 - 80 STO Z 81 X^2 82 - 83 RCL 01 84 X^2 85 * 86 RCL 08 87 RCL 05 |
88 X^2 89 - 90 ST* Z 91 RCL 02 92 * 93 X^2 94 - 95 RCL 07 96 RCL 06 97 X^2 98 - 99 ST* Z 100 RCL 03 101 * 102 X^2 103 - 104 + 105 X<=0? 106 GTO 00 107 SQRT 108 RCL 14 109 / 110 FRC 111 X#0? 112 GTO 00 113 LASTX 114 TONE 9 115 RTN 116 LBL 00 |
117 RCL 06 118 RCL 15 119 + 120 STO 06 121 RCL 12 122 X>Y? 123 GTO 02 124 LBL 03 125 RCL 05 126 RCL 15 127 + 128 STO 05 129 RCL 11 130 X>Y? 131 GTO 01 132 RCL 13 133 STO 05 134 RCL 04 135 RCL 15 136 + 137 STO 04 138 RCL 10 139 X>Y? 140 GTO 01 141 PI 142 BEEP 143 END |
( 165
bytes / SIZE 016 )
STACK | INPUTS | OUTPUT |
Z | a | / |
Y | b | / |
X | c | V |
When a solution is found, press R/S to search another one.
Example: a = 13 b = 16 c = 18
13 ENTER^
16 ENTER^
18 XEQ "ITH" >>>> ( TONE 9 )
V = 84
---Execution time = 17mn32s---
and we find R04 = 6 , R05 = 30 , R06 = 27
-So, the tetrahedron ( 13 , 16 , 18 , 6 , 30 , 27 ) has a volume = 84
-Then press R/S to find another integer tetrahedron, it yields: ( with a good emulator ) V = 336
corresponding to ( 13 , 16 , 18 , 22 , 19 , 27 )
>>> 4 other integer tetrahedra will be found - all with V = 336
-When there is no other solution, the HP-41 executes a BEEP and returns PI in X-register.
Notes:
-An emulator in turbo mode is almost indispensable, unless a , b , c
are very small.
-Otherwise, the executions times would be prohibitive...
-If one or several calculations involve number > 1010 , roundoff-errors
may produce a wrong solution or miss a true solution
-Another example: ( 4 5 6 2 8 7 ) V = 6 and a last one: ( 41 , 64 , 71 , 29 , 57 , 49 ) gives an integer volume V = 9702
>>> If you want to store 4 a2 b2 c2 in R00, replace lines 81 to 85 by the 4 lines:
RCL 01 and lines
16 to 21 by
RCL 01 *
X^2
*
RCL 02 *
STO 00
X^2
RCL 03 ST+ X
-
the 1st example will be found in 16m53s instead of 17mn32s,
but the example above - with V = 9702 - will not be found because of roundoff-errors
!
References:
[1] Georges Dostor - "Rayon de la sphère circonscrite au
tétraèdre en fonction des arêtes"
[2] E. Catalan - "Note sur les sphères tangentes à 4
plans donnés"
[3] McConnell - "Pseudofaces of Tetrahedra"
[4] http://planetmath.org/SolidAngle.html
[5] C. Chisholm, J.A. MacDougall - Rational and Heron tetrahedra.