Quaternionic Jacobian Elliptic Functions for the HP-41
Overview
1°) Ascending Landen Transformation
2°) Gauss' Transformation
1°) Ascending Landen Transformation
"JEFQ" computes sn ( q | m ) , cn ( q | m ) , dn ( q | m ) where m is a real number
-The ascending Landen transformation is used if 0 < m < 1
-If m > 1, the program also uses the relations:
sn ( q | m ) = sn ( q m1/2
| 1/m ) / m1/2
cn ( q | m ) = dn ( q m1/2
| 1/m )
dn ( q | m ) = cn ( q m1/2
| 1/m )
-If m = 1: sn ( q | m ) = tanh q ; cn ( q | m ) = dn ( q | m ) = sech q
-If m < 0:
sn ( q | m ) = sd ( q (1-m)1/2
| -m/(1-m) ) / (1-m)1/2
cn ( q | m ) = cd ( q (1-m)1/2
| -m/(1-m) )
dn ( q | m ) = nd ( q (1-m)1/2
| -m/(1-m) )
-If m = 0 , sn ( q | 0 ) = Sin q ; cn
( q | 0 ) = Cos q ; dn ( q | 0 ) = 1 are obtained directly.
Data Registers: • R00 = m ( Register R00 is to be initialized before executing "JEFQ" )
R01 to R04 = sn ( q | m )
R13 thru R26...... : temp
R05 to R08 = cn ( q | m )
R09 to R12 = dn ( q | m )
Flags: F06-F07
Subroutines: "SINQ" "COSQ" "CHQ"
"THQ" "Q*Q" "1/Q" ( cf "Quaternions for the HP-41" )
>>> The number of data registers may reach 40 or more
-Lines 41-152-226 are three-byte GTOs
01 LBL "JEFQ"
02 STO 22 03 RDN 04 STO 23 05 RDN 06 STO 24 07 X<>Y 08 STO 25 09 RCL 00 10 X#0? 11 GTO 00 12 STO 10 13 STO 11 14 STO 12 15 SIGN 16 STO 09 17 RCL 25 18 RCL 24 19 RCL 23 20 RCL 22 21 XEQ "COSQ" 22 STO 05 23 RDN 24 STO 06 25 RDN 26 STO 07 27 X<>Y 28 STO 08 29 RCL 25 30 RCL 24 31 RCL 23 32 RCL 22 33 XEQ "SINQ" 34 STO 01 35 RDN 36 STO 02 37 RDN 38 STO 03 39 X<>Y 40 STO 04 41 GTO 14 42 LBL 00 43 1 44 X<>Y 45 CF 06 46 CF 07 47 X<=Y? 48 GTO 00 49 SF 06 50 SQRT 51 ST* 22 52 ST* 23 53 ST* 24 54 ST* 25 |
55 LASTX
56 1/X 57 GTO 13 58 LBL 00 59 X>0? 60 GTO 13 61 SF 07 62 1 63 RCL 00 64 - 65 SQRT 66 ST* 22 67 ST* 23 68 ST* 24 69 ST* 25 70 X<> L 71 / 72 CHS 73 LBL 13 74 STO 13 75 25 76 STO 26 77 SIGN 78 STO 02 79 RCL 13 80 - 81 SQRT 82 LBL 01 83 X=0? 84 GTO 00 85 X<>Y 86 SQRT 87 STO 01 88 4 89 * 90 RCL 01 91 3 92 ST+ 26 93 SIGN 94 ST- 01 95 + 96 ST/ 01 97 X^2 98 / 99 RCL 01 100 CHS 101 STO IND 26 102 1 103 ST- 26 104 + 105 ST* 02 106 X<>Y 107 STO IND 26 108 RCL 01 |
109 GTO 01
110 LBL 00 111 14.001008 112 STO 13 113 .026 114 ST+ 26 115 RCL 02 116 ST/ 22 117 ST/ 23 118 ST/ 24 119 ST/ 25 120 RCL 25 121 RCL 24 122 RCL 23 123 RCL 22 124 XEQ "THQ" 125 STO 14 126 RDN 127 STO 15 128 RDN 129 STO 16 130 X<>Y 131 STO 17 132 RCL 25 133 RCL 24 134 RCL 23 135 RCL 22 136 XEQ "CHQ" 137 XEQ "1/Q" 138 STO 09 139 STO 18 140 RDN 141 STO 10 142 STO 19 143 RDN 144 STO 11 145 STO 20 146 X<>Y 147 STO 12 148 STO 21 149 LBL 02 150 DSE 26 151 FS? 30 152 GTO 00 153 RCL 13 154 REGMOVE 155 XEQ "Q*Q" 156 STO 05 157 RDN 158 STO 06 159 RDN 160 STO 07 161 X<>Y 162 STO 08 |
163 RCL 12
164 STO 21 165 RCL 11 166 STO 20 167 RCL 10 168 STO 19 169 RCL 09 170 STO 18 171 XEQ "1/Q" 172 STO 01 173 RDN 174 STO 02 175 RDN 176 STO 03 177 X<>Y 178 STO 04 179 XEQ "Q*Q" 180 STO 14 181 RDN 182 STO 15 183 RDN 184 STO 16 185 X<>Y 186 STO 17 187 RCL IND 26 188 ST* 01 189 ST* 02 190 ST* 03 191 ST* 04 192 RCL 01 193 ST+ 09 194 ST- 18 195 RCL 02 196 ST+ 10 197 ST- 19 198 RCL 03 199 ST+ 11 200 ST- 20 201 RCL 04 202 ST+ 12 203 ST- 21 204 1 205 STO Y 206 RCL IND 26 207 ST- Z 208 + 209 ST* 14 210 ST* 15 211 ST* 16 212 ST* 17 213 DSE 26 214 RCL IND 26 215 / 216 ST* 18 |
217 ST* 19
218 ST* 20 219 ST* 21 220 X<> L 221 / 222 ST* 09 223 ST* 10 224 ST* 11 225 ST* 12 226 GTO 02 227 LBL 00 228 RCL 13 229 REGMOVE 230 FC?C 06 231 GTO 00 232 RCL 00 233 SQRT 234 ST/ 01 235 ST/ 02 236 ST/ 03 237 ST/ 04 238 RCL 09 239 STO 05 240 RCL 10 241 STO 06 242 RCL 11 243 STO 07 244 RCL 12 245 STO 08 246 RCL 18 247 STO 09 248 RCL 19 249 STO 10 250 RCL 20 251 STO 11 252 RCL 21 253 STO 12 254 GTO 14 255 LBL 00 256 FC?C 07 257 GTO 14 258 1 259 RCL 00 260 - 261 SQRT 262 ST/ 14 263 ST/ 15 264 ST/ 16 265 ST/ 17 266 RCL 14 267 STO 01 268 RCL 15 269 STO 02 270 RCL 16 |
271 STO 03
272 RCL 17 273 STO 04 274 RCL 12 275 RCL 11 276 RCL 10 277 RCL 09 278 XEQ "1/Q" 279 STO 05 280 STO 09 281 RDN 282 STO 06 283 STO 10 284 RDN 285 STO 07 286 STO 11 287 X<>Y 288 STO 08 289 STO 12 290 XEQ "Q*Q" 291 STO 14 292 RDN 293 STO 15 294 RDN 295 STO 16 296 X<>Y 297 STO 17 298 RCL 18 299 STO 01 300 RCL 19 301 STO 02 302 RCL 20 303 STO 03 304 RCL 21 305 STO 04 306 XEQ "Q*Q" 307 STO 18 308 RDN 309 STO 19 310 RDN 311 STO 20 312 X<>Y 313 STO 21 314 RCL 13 315 REGMOVE 316 LBL 14 317 RCL 04 318 RCL 03 319 RCL 02 320 RCL 01 321 END |
( 523 bytes /SIZE 027+??? )
STACK | INPUTS | OUTPUTS |
T | t | t' |
Z | z | z' |
Y | y | y' |
X | x | x' |
where x'+y'.i+z'.j+t'.k = sn ( x+y.i+z.j+t.k | m ) provided R00 = m
Example1: m = 1/PI q = 1 + 2 i + 3 j + 4 k
PI 1/X STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> 1.498262250
---Execution time = 52s---
RDN 0.205407205
RDN 0.308110808
RDN 0.410814411
sn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = 1.498262250 + 0.205407205 i + 0.308110808 j + 0.410814411 k and
cn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = -0.694940084 + 0.442849489 i + 0.664274234 j + 0.885698978 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = -0.719248903
+ 0.136199160 i + 0.204298740 j + 0.272398320 k
in R09 to R12
Example2: m = PI q = 1 + 2 i + 3 j + 4 k
PI STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> 0.860242323
---Execution time = 53s---
RDN -0.005873620
RDN -0.008810430
RDN -0.011747240
sn ( 1 + 2 i + 3 j + 4 k | PI ) = 0.860242323 - 0.005873620 i - 0.008810430 j - 0.011747240 k and
cn ( 1 + 2 i + 3 j + 4 k | PI ) = 0.510825408 + 0.009891315 i + 0.014836972 j + 0.019782630 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | PI ) = -0.037125130
- 0.427571167 i - 0.645356751 j - 0.855142335 k
in R09 to R12
Example3: m = -PI q = 1 + 2 i + 3 j + 4 k
PI CHS STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> -1.473447254
---Execution time = 38s---
RDN -0.079007897
RDN -0.118511846
RDN -0.158015795
sn ( 1 + 2 i + 3 j + 4 k | -PI ) = -1.473447254 - 0.079007897 i - 0.118511846 j - 0.158015795 k and
cn ( 1 + 2 i + 3 j + 4 k | -PI ) = 0.285290841 - 0.408053646 i - 0.612080469 j - 0.816107292 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | -PI ) = -2.793322256
- 0.130928419 i - 0.196392628 j - 0.261856838 k
in R09 to R12
2°) Gauss' Transformation
-This method is described in "Jacobian Elliptic Functions for the HP-41"
-Moreover, Gauss' transformation is also applied directly if
m < 0
Data Registers: • R00 = m ( Register R00 is to be initialized before executing "JEFQ" )
R01 to R04 = sn ( q | m )
R13 thru R26...... : temp
R05 to R08 = cn ( q | m )
R09 to R12 = dn ( q | m )
Flag: F10
Subroutines: "SINQ" "COSQ" "CHQ"
"THQ" "Q*Q" "1/Q" ( cf "Quaternions for the HP-41" )
-Line 233 is a three-byte GTO 03
01 LBL "JEFQ"
02 CF 10 03 STO 22 04 RDN 05 STO 23 06 RDN 07 STO 24 08 X<>Y 09 STO 25 10 RCL 00 11 STO 21 12 1 13 X>Y? 14 GTO 01 15 X#Y? 16 GTO 00 17 RCL 25 18 RCL 24 19 RCL 23 20 RCL 22 21 XEQ "CHQ" 22 XEQ "1/Q" 23 STO 05 24 STO 09 25 RDN 26 STO 06 27 STO 10 28 RDN 29 STO 07 30 STO 11 31 X<>Y 32 STO 08 33 STO 12 34 RCL 25 35 RCL 24 36 RCL 23 37 RCL 22 38 XEQ "THQ" 39 STO 01 40 RDN 41 STO 02 42 RDN |
43 STO 03
44 X<>Y 45 STO 04 46 X<>Y 47 R^ 48 R^ 49 RTN 50 LBL 00 51 SF 10 52 X<>Y 53 SQRT 54 ST* 22 55 ST* 23 56 ST* 24 57 ST* 25 58 LASTX 59 1/X 60 STO 21 61 LBL 01 62 26.026 63 STO 26 64 SIGN 65 STO 01 66 RCL 21 67 LBL 02 68 ENTER 69 CHS 70 1 71 + 72 SQRT 73 1 74 ST+ 26 75 + 76 ENTER 77 ENTER 78 2 79 / 80 ST* 01 81 RDN 82 X^2 83 / 84 STO IND 26 |
85 X^2
86 X#0? 87 GTO 02 88 RCL 01 89 ST* 22 90 ST* 23 91 ST* 24 92 ST* 25 93 13.001008 94 STO 21 95 SIGN 96 STO 17 97 CLX 98 STO 18 99 STO 19 100 STO 20 101 RCL 25 102 RCL 24 103 RCL 23 104 RCL 22 105 XEQ "SINQ" 106 STO 09 107 RDN 108 STO 10 109 RDN 110 STO 11 111 X<>Y 112 STO 12 113 RCL 25 114 RCL 24 115 RCL 23 116 RCL 22 117 XEQ "COSQ" 118 STO 13 119 RDN 120 STO 14 121 RDN 122 STO 15 123 X<>Y 124 STO 16 125 LBL 03 126 RCL 21 |
127 REGMOVE
128 XEQ "Q*Q" 129 STO 13 130 RDN 131 STO 14 132 RDN 133 STO 15 134 X<>Y 135 STO 16 136 RCL 09 137 STO 01 138 STO 05 139 RCL 10 140 STO 02 141 STO 06 142 RCL 11 143 STO 03 144 STO 07 145 RCL 12 146 STO 04 147 STO 08 148 XEQ "Q*Q" 149 STO 05 150 STO 17 151 RDN 152 STO 06 153 STO 18 154 RDN 155 STO 07 156 STO 19 157 X<>Y 158 STO 08 159 STO 20 160 1 161 RCL IND 26 162 + 163 ST* 01 164 ST* 02 165 ST* 03 166 ST* 04 167 LASTX 168 ST* 05 |
169 ST* 06
170 ST* 07 171 ST* 08 172 CHS 173 ST* 17 174 ST* 18 175 ST* 19 176 ST* 20 177 1 178 ST+ 05 179 ST+ 17 180 RCL 08 181 RCL 07 182 RCL 06 183 RCL 05 184 XEQ "1/Q" 185 STO 05 186 RDN 187 STO 06 188 RDN 189 STO 07 190 X<>Y 191 STO 08 192 XEQ "Q*Q" 193 STO 09 194 RDN 195 STO 10 196 RDN 197 STO 11 198 X<>Y 199 STO 12 200 RCL 13 201 STO 01 202 RCL 14 203 STO 02 204 RCL 15 205 STO 03 206 RCL 16 207 STO 04 208 XEQ "Q*Q" 209 STO 13 210 RDN |
211 STO 14
212 RDN 213 STO 15 214 X<>Y 215 STO 16 216 RCL 17 217 STO 01 218 RCL 18 219 STO 02 220 RCL 19 221 STO 03 222 RCL 20 223 STO 04 224 XEQ "Q*Q" 225 STO 17 226 RDN 227 STO 18 228 RDN 229 STO 19 230 X<>Y 231 STO 20 232 DSE 26 233 GTO 03 234 FC?C 10 235 GTO 00 236 13.017004 237 REGSWAP 238 RCL 00 239 SQRT 240 ST/ 09 241 ST/ 10 242 ST/ 11 243 ST/ 12 244 LBL 00 245 9.001012 246 REGMOVE 247 RCL 04 248 RCL 03 249 RCL 02 250 RCL 01 251 END |
( 423 bytes /SIZE 027+??? )
STACK | INPUTS | OUTPUTS |
T | t | t' |
Z | z | z' |
Y | y | y' |
X | x | x' |
where x'+y'.i+z'.j+t'.k = sn ( x+y.i+z.j+t.k | m ) provided R00 = m
Example1: m = 1/PI q = 1 + 2 i + 3 j + 4 k
PI 1/X STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> 1.498262250
---Execution time = 58s---
RDN 0.205407205
RDN 0.308110807
RDN 0.410814409
sn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = 1.498262250 + 0.205407205 i + 0.308110807 j + 0.410814409 k and
cn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = -0.694940081 + 0.442849491 i + 0.664274237 j + 0.885698982 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | 1/PI ) = -0.719248900
+ 0.136199160 i + 0.204298741 j + 0.272398321 k
in R09 to R12
Example2: m = PI q = 1 + 2 i + 3 j + 4 k
PI STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> 0.860242322
---Execution time = 60s---
RDN -0.005873618
RDN -0.008810427
RDN -0.011747237
sn ( 1 + 2 i + 3 j + 4 k | PI ) = 0.860242322 - 0.005873618 i - 0.008810427 j - 0.011747237 k and
cn ( 1 + 2 i + 3 j + 4 k | PI ) = 0.510825404 + 0.009891315 i + 0.014836973 j + 0.019782630 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | PI ) = -0.037125130
- 0.427571169 i - 0.645356753 j - 0.855142339 k
in R09 to R12
Example3: m = -PI q = 1 + 2 i + 3 j + 4 k
PI CHS STO 00
4 ENTER^
3 ENTER^
2 ENTER^
1 XEQ "JEFQ"
>>>> -1.473447238
---Execution time = 68s---
RDN -0.079007894
RDN -0.118511841
RDN -0.158015788
sn ( 1 + 2 i + 3 j + 4 k | -PI ) = -1.473447238 - 0.079007894 i - 0.118511841 j - 0.158015788 k and
cn ( 1 + 2 i + 3 j + 4 k | -PI ) = 0.285290836 - 0.408053637 i - 0.612080456 j - 0.816107275 k in R05 to 508
dn ( 1 + 2 i + 3 j + 4 k | -PI ) = -2.793322223
- 0.130928415 i - 0.196392622 j - 0.261856830 k
in R09 to R12
Notes:
-Here, the "LBL 03 loop" stops when the parameter m = 0
-So, this variant is often slower than the first one, but it's also shorter...
References:
[1] Abramowitz and Stegun - "Handbook of Mathematical Functions"
- Dover Publications - ISBN 0-486-61272-4
[2] http://functions.wolfram.com/