Quaternionic Catalan Numbers for the HP-41
Overview
-The Catalan numbers may be defined by C(n) = 4n Gam(n+1/2)
/ [ sqrt(PI) Gam(n+2) ]
-This formula is used hereunder after replacing n by a quaternion q
Program Listing
Data Registers: R00 unused
R01 to R24: temp
Flags: /
Subroutines: "Q*Q" "1/Q"
"Q^Q" ( cf "Quaternions for the HP-41" )
"GAMQ" or "1/GMQ" ( cf "Quaternionic Special Functions" )
-Line 49 XEQ "Q^Q" both definitions give the same result.
-Lines 57 to 64 may be replaced by 17.005004
REGMOVE
-Lines 73 to 80 may be replaced by 21.001004
REGMOVE
01 LBL "CATQ"
02 STO 17 03 RDN 04 STO 18 05 RDN 06 STO 19 07 RDN 08 STO 20 09 RDN 10 SIGN 11 CLX 12 2 13 ST+ L 14 X<> L 15 XEQ "GAMQ" 16 XEQ "1/Q" 17 STO 21 18 RDN |
19 STO 22
20 RDN 21 STO 23 22 X<>Y 23 STO 24 24 .5 25 RCL 17 26 + 27 RCL 20 28 RCL 19 29 RCL 18 30 R^ 31 XEQ "GAMQ" 32 X<> 17 33 STO 05 34 RDN 35 X<> 18 36 STO 06 |
37 RDN
38 X<> 19 39 STO 07 40 X<>Y 41 X<> 20 42 STO 08 43 4 44 STO 01 45 CLX 46 STO 02 47 STO 03 48 STO 04 49 XEQ "Q^Q" 50 STO 01 51 RDN 52 STO 02 53 RDN 54 STO 03 |
55 X<>Y
56 STO 04 57 RCL 17 58 STO 05 59 RCL 18 60 STO 06 61 RCL 19 62 STO 07 63 RCL 20 64 STO 08 65 XEQ "Q*Q" 66 STO 05 67 RDN 68 STO 06 69 RDN 70 STO 07 71 X<>Y 72 STO 08 |
73 RCL 21
74 STO 01 75 RCL 22 76 STO 02 77 RCL 23 78 STO 03 79 RCL 24 80 STO 04 81 PI 82 SQRT 83 ST/ 01 84 ST/ 02 85 ST/ 03 86 ST/ 04 87 XEQ "Q*Q" 88 END |
( 154 bytes / SIZE 025 )
STACK | INPUTS | OUTPUTS |
T | t | t' |
Z | z | z' |
Y | y | y' |
X | x | x' |
where C (x+y.i+z.j+t.k) = x'+y'.i+z'.j+t'.k
Example: q = 1 + i/2 + j/3 + k/4
4 1/X
3 1/X
2 1/X
1 XEQ "CATQ" >>>>
0.844036224
---Execution time = 66s---
RDN 0.239299402
RDN 0.159532935
RDN 0.119649701
-Thus, C ( 1 + i/2 + j/3 + k/4 ) = 0.844036224
+ 0.239299402 i + 0.159532935 j + 0.119649701 k