Quaternionic Carlson Elliptic Integral for the HP-41
Overview
"RFQ" calculates the Carlson Elliptic Integral of the first kind RF(q,q',q") where q , q' , q" are 3 quaternions.
• The duplication theorem RF(x,y,z) = RF[ (x+µ)/4 , (y+µ)/4 , (z+µ)/4 ]
with µ = (1/2) [ x1/2(y1/2+z1/2)
+ (y1/2+z1/2)x1/2+y1/2z1/2+z1/2y1/2
] is applied until
x+y+z is approximately constant.
• Then, RF(q,q',q") = [ (q+q'+q")/3
] -1/2
Program Listing
Data Registers: R00 & R13 to R37: temp ( Registers R01 thru R12 are to be initialized before executing "RFQ" )
• R01 thru R04 = q
• R05 thru R08 = q'
• R09 thru R12 = q"
Flag: F10
Subroutines: "Q*Q" "Q^R"
( cf "Quaternions for the HP-41" )
-Line 171 may be replaced by another "small" number.
-Lines 173 and 175 are three-byte GTO 01
01 LBL "RFQ"
02 1.017012 03 REGMOVE 04 SF 10 05 .5 06 STO 00 07 CLX 08 STO 09 09 STO 10 10 STO 11 11 STO 12 12 1.005004 13 STO 37 14 GTO 01 15 LBL 00 16 REGSWAP 17 XEQ "Q*Q" 18 ST+ 13 19 RDN 20 ST+ 14 21 RDN 22 ST+ 15 23 X<>Y 24 ST+ 16 25 RTN 26 LBL 01 27 RCL 20 28 RCL 19 29 RCL 18 30 RCL 17 31 XEQ "Q^R" 32 STO 01 33 RDN 34 STO 02 35 RDN 36 STO 03 37 X<>Y 38 STO 04 |
39 RCL 24
40 RCL 23 41 RCL 22 42 RCL 21 43 XEQ "Q^R" 44 STO 05 45 STO 29 46 RDN 47 STO 06 48 STO 30 49 RDN 50 STO 07 51 STO 31 52 X<>Y 53 STO 08 54 STO 32 55 RCL 28 56 RCL 27 57 RCL 26 58 RCL 25 59 XEQ "Q^R" 60 ST+ 05 61 STO 33 62 RDN 63 ST+ 06 64 STO 34 65 RDN 66 ST+ 07 67 STO 35 68 X<>Y 69 ST+ 08 70 STO 36 71 XEQ "Q*Q" 72 STO 13 73 RDN 74 STO 14 75 RDN 76 STO 15 |
77 X<>Y
78 STO 16 79 RCL 37 80 XEQ 00 81 1.029008 82 XEQ 00 83 RCL 37 84 XEQ 00 85 2 86 ST/ 13 87 ST/ 14 88 ST/ 15 89 ST/ 16 90 RCL 13 91 ST+ 17 92 ST+ 21 93 ST+ 25 94 RCL 14 95 ST+ 18 96 ST+ 22 97 ST+ 26 98 RCL 15 99 ST+ 19 100 ST+ 23 101 ST+ 27 102 RCL 16 103 ST+ 20 104 ST+ 24 105 ST+ 28 106 4 107 ST/ 17 108 ST/ 18 109 ST/ 19 110 ST/ 20 111 ST/ 21 112 ST/ 22 113 ST/ 23 114 ST/ 24 |
115 ST/ 25
116 ST/ 26 117 ST/ 27 118 ST/ 28 119 RCL 09 120 RCL 17 121 RCL 21 122 RCL 25 123 + 124 + 125 STO 09 126 - 127 ABS 128 RCL 10 129 RCL 18 130 RCL 22 131 + 132 RCL 26 133 + 134 STO 10 135 - 136 ABS 137 + 138 RCL 11 139 RCL 19 140 RCL 23 141 + 142 RCL 27 143 + 144 STO 11 145 - 146 ABS 147 + 148 RCL 12 149 RCL 20 150 RCL 24 151 + 152 RCL 28 |
153 +
154 STO 12 155 - 156 ABS 157 + 158 RCL 09 159 ABS 160 RCL 10 161 ABS 162 + 163 RCL 11 164 ABS 165 + 166 RCL 12 167 ABS 168 + 169 / 170 VIEW X 171 E-8 172 X<Y? 173 GTO 01 174 FS?C 10 175 GTO 01 176 3 177 ST/ 09 178 ST/ 10 179 ST/ 11 180 ST/ 12 181 RCL 00 182 CHS 183 STO 00 184 RCL 12 185 RCL 11 186 RCL 10 187 RCL 09 188 XEQ "Q^R" 189 END |
( 338 bytes / SIZE 038 )
STACK | INPUTS | OUTPUTS |
T | / | t |
Z | / | z |
Y | / | y |
X | / | x |
where RF(q,q',q") = x + y i + z j + t k after storing q , q' , q" in R01 thru R12
Example: RF( 1 + 2 i + 3 j + 4 k , 2 - 3 i + j - k , 1 + 3 i - 4 j + 7 k ) = ?
1 STO 01
2 STO 05 1
STO 09
2 STO 02
-3 STO 06 3 STO 10
3 STO 03
1 STO 07 -4 STO 11
4 STO 04
-1 STO 08 7 STO 12
XEQ "RFQ" >>>> 0.439828693
---Execution time = 4m11s---
RDN -0.023612662
RDN -0.018360493
RDN -0.170450600
-So, RF(q,q',q") = 0.439828693 - 0.023612662 i - 0.018360493 j - 0.170450600 k
Notes:
-Flag F10 is used to avoid a premature stop.
-This program may also be employed with complex arguments ( all
z = t = 0 ), though it's not the fastest way to get the result !