Anions

# Anions for the HP-41

Overview

0°)  Addition & Multiplication ( Special Case )

a)  Focal Program#1
b)  Focal Program#2
c)  M-Code Routines

c1- Initialization
c2- Multiplication & Addition Routines

1°)  Multiplication ( General Case )

a)  Program#1
b)  Program#2
c)  Program#3

2°)  Miscellaneous Functions
3°)  Anionic Polynomials - Real Coefficients
4°)  Anionic Equations

-The Cayley-Dickinson formula           ( a , b ) ( c , d ) = ( a c - d* b , d a + b c* )       where   * = conjugate

may be used to construct the complexes from the real numbers, regarding a complex as a pair of real numbers.

-Likewise, the quaternions from the complexes, the octonions from the quaternions, the sedenions from the octonions,
the 32-ons from the sedenions, the 64-ons from the 32-ons ... and so on ... for the 2^n-ons

-I've used the word "anion" though it's perhaps not "official".

0°)  Addition & Multiplication ( Special Case )

a)  Focal Program#1

-The Cayley-Dickinson formula is not very easy to handle with an HP-41 and it employs many registers.
-But fortunately, there is a much easier case when the anions have the same imaginary direction,
it's often the case to compute elementary or special functions of an anion:

Data Registers:           •  R00 = n ( 2 , 4 , 8 , 16 , 32 , 64 or 128 )    ( Registers R00 thru R2n are to be initialized before executing "A*A1" )

•  R01   ......  •  Rnn = the n components of the 1st anion
•  Rn+1 ......  •  R2n = the n components of the 2nd anion

>>>  When the program stops:     R01   ......  Rnn = the n components of the product

Flags: /
Subroutines:  /

 01  LBL "A*A1"  02  RCL 00  03   E-3  04  +  05  STO P  06  ISG X  07  ABS  08  RCL 00 09  ST+ X  10  STO Q  11  RCL IND Y  12  STO Y  13  RCL 01  14  *  15  LBL 01  16  RCL 01 17  RCL IND Q  18  *  19  RCL IND P  20  R^  21  ST* Y  22  RDN  23  +  24  X<> IND P 25  RCL IND Q  26  *  27  -  28  DSE Q  29  DSE P  30  GTO 01  31  STO 01  32  CLX 33  STO P  34  RCL 00        35   E3  36  /  37  ISG X  38  END

( 66 bytes / SIZE 2n+1 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    a = 8 + 3 i + 4 j + 7 k   ;   a' = 5 - 6 i - 8 j - 14 k

-These are quaternions so    4  STO 00

8  STO 01          5  STO 05
3  STO 02         -6  STO 06
4  STO 03         -8  STO 07
7  STO 04        -14 STO 08

XEQ "A*A1"  >>>>  1.004    and we get in registers R01 thru R04

R01 = 188  ,   R02 = -33  ,  R03 = -44  ,  R04 = -77

-Therefore,   a.a' = 188 - 33 i - 44 j - 77 k

Notes:

-"A*A1" does not check that the imaginary parts are proportional.
-This routine uses synthetic registers P & Q but registers  M , N , O  are undisturbed.
-This is useful to compute special functions.
-Otherwise, P & Q could be replaced by M & N.

b)  Focal Program#2

-There are special functions - like the hypergeometric functions - that use synthetic register P.
-The variant hereunder leaves registers  M , N , O , P  undisturbed.

Data Registers:           •  R00 = n ( 2 , 4 , 8 , 16 , 32 , 64 or 128 )    ( Registers R00 thru R2n are to be initialized before executing "A*A1" )

•  R01   ......  •  Rnn = the n components of the 1st anion
•  Rn+1 ......  •  R2n = the n components of the 2nd anion

>>>  When the program stops:     R01   ......  Rnn = the n components of the product

Flags: /
Subroutines:  /

 01  LBL "A*A1"  02  CLX  03  SIGN  04  RCL 00  05  +  06  STO Y  07  PI  08  INT  09  10^X  10  / 11  RCL 00  12  ST+ X  13  +  14  STO Q  15  RCL IND Y  16  STO Y  17  RCL 01  18  *  19  LBL 01  20  RCL 01 21  RCL IND Q  22  *  23  RCL Q  24  SIGN  25  CLX  26  RCL 00  27  ST- L  28  CLX  29  RCL IND L  30  R^ 31  ST* Y  32  RDN  33  ST+ Y  34  RDN  35  X<> IND L  36  RCL IND Q  37  *  38  -  39  DSE Q  40  GTO 01 41  STO 01  42  RCL 00        43  PI  44  INT  45  10^X  46  /  47  ISG X  48  END

( 73 bytes / SIZE 2n+1 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    The same one:   a = 8 + 3 i + 4 j + 7 k   ;   a' = 5 - 6 i - 8 j - 14 k

-These are quaternions so    4  STO 00

8  STO 01          5  STO 05
3  STO 02         -6  STO 06
4  STO 03         -8  STO 07
7  STO 04        -14 STO 08

XEQ "A*A1"  >>>>  1.004    and we get in registers R01 thru R04

R01 = 188  ,   R02 = -33  ,  R03 = -44  ,  R04 = -77

-Therefore,   a.a' = 188 - 33 i - 44 j - 77 k

Notes:

-"A*A1" does not check that the imaginary parts are proportional.
-This second version is of course slightly slower.
-The M-code routine below does not disturb the alpha "register"  but it's also much faster:

c)  M-Code Routines

c1)  Initialization

-These codes take a positive integer n in register R00 and place

1.nnn    in CPU register            N[5;3] N[2;0]   if CPU flag 9 is set
or    1.nnn.2n  in CPU register N[8;6] N[5;3] N[2;0]  if CPU flag 9 is clear

where  1 , nnn & 2n  mean the absolute addresses ( in hexadecimal ) of registers  R01 , Rnn & R2n

-There is no check for alpha data in these registers but if R00 contains an alpha string, you'll get the message "ALPHA DATA"
-You will also get "DATA ERROR"  if R00 = 0

-Of course, the existence of R00 and Rnn ( or R2n if CPU flag 9 is clear ) is tested
and "NONEXISTENT"  is displayed if these registers don't exist.

260  SETHEX                @EFC8  in my ROM
378  C=c
03C  RCR 3
106  A=C S&X
130  LDI S&X
200  200h                           correct value for an HP-41CV/CX or an HP-41C with a QUAD memory module
306  ?A<C S&X
381  ?NCGO
00A  NEXIST
0A6  A<>C S&X
270   RAMSELECT
038   READATA
38D  ?NCXQ
008   N->S&X
2E6  ?C#0 S&X
0B5  ?NCGO
0A2  ERROR
05A  C=0 M
23A  C=C+1 M
106  A=C S&X
1BC  RCR 11
0A6  A<>C S&X
1E6  C=C+C S&X
10E  A=C ALL
378  C=c
03C  RCR 3
0E6  B<>C S&X
378  C=c
0C6  C=B S&X
1BC  RCR 11
0C6  C=B S&X
20E  C=A+C ALL
24C  ?FSET 9
013  JNC+02
03C  RCR 3
070  N=C ALL
10E  A=C ALL
130  LDI S&X
200  200h
306  ?A<C S&X
381  ?NCGO
00A  NEXIST
3E0  RTN                     @EFF2  in my ROM

( 43 words )

-To call this subroutine:    ?NCXQ  EFC8  =  321   3BC    in my ROM
-Change these 2 words if you have loaded this routine at another address...

c2)  Multiplication & Addition Routines

-This routine "A*A1" does the same calculations as the 2 focal programs above

0B1  "1"
001   "A"
02A  "*"
001   "A"
244   CLRF 9
321   ?NCXQ                   executes the initialization
3BC  EFC8                       routine above
0B0  C=N ALL
17C  RCR 6
270   RAMSLCT
038   READATA
10E  A=C ALL
0B0  C=N ALL
03C  RCR 3
226   C=C+1 S&X
270   RAMSLCT
038   READATA
0EE  B<>C ALL
04E  C=0 ALL
270   RAMSLCT
0AE  A<>C ALL
068   Z=C
10E  A=C ALL
0EE  B<>C ALL
0A8  Y=C
2A0   SETDEC
135   C=
060   A*C
0E8   X=C
0B0   C=N ALL           LOOP
270   RAMSLCT
038   READATA
10E   A=C ALL
0B0  C=N ALL
03C  RCR 3
270   RAMSLCT
038   READATA
0EE  B<>C ALL
046   C=0 S&X
270   RAMSLCT
0EE  B<>C ALL
028   T=C
2BE  C=-C
0AE  A<>C ALL
128   L=C
135   C=
060   A*C
0F8   C=X
025   C=
060  AB+C
0E8  X=C
078  C=Z
10E  A=C ALL
138  C=L
135  C=
060  A*C
10E  A=C ALL
046  C
270  =
038  T
0AE  A<>C ALL
128  L=C
0B8  C=Y
135  C=
060  A*C
138  C=L
025   C=
060  AB+C
10E  A=C ALL
0B0  C=N ALL
03C  RCR 3
270  RAMSLCT
0AE  A<>C ALL
2F0  WRITDATA
260  SETHEX
0B0  C=N ALL
266  C=C-1 S&X
27A  C=C-1 M
070  N=C ALL
2A0  SETDEC
17C  RCR 6
106  A=C S&X
1BC  RCR 11
306  ?A<C S&X
24F  JC-55d                                  GOTO  LOOP
046  C=0 S&X
270  RAMSLCT
0F8  C=X
10E  A=C ALL
0B0  C=N ALL
17C  RCR 6
270   RAMSLCT
0AE  A<>C ALL
2F0  WRITDATA
0B0  C=N ALL
17C  RCR 6
260  SETHEX
266  C=C-1 S&X
270  RAMSLCT
038  READATA
2A0  SETDEC
266   C=C-1 S&X
266   C=C-1 S&X
266   C=C-1 S&X
10E  A=C ALL
046  C=0 S&X
270  RAMSLCT
04E  C
35C  =
050   1
01D  C=
060  A+C
0E8  X=C
3E0  RTN

( 114 words / SIZE 2n+1 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    Again the same one:   a = 8 + 3 i + 4 j + 7 k   ;   a' = 5 - 6 i - 8 j - 14 k

-These are quaternions so    4  STO 00

8  STO 01          5  STO 05
3  STO 02         -6  STO 06
4  STO 03         -8  STO 07
7  STO 04        -14 STO 08

XEQ "A*A1"  >>>>  1.004    and we get in registers R01 thru R04

R01 = 188  ,   R02 = -33  ,  R03 = -44  ,  R04 = -77

-Therefore,   a.a' = 188 - 33 i - 44 j - 77 k

Notes:

-"A*A1" does not check that the imaginary parts are proportional.
-Synthetic register Q is not used.

-If n = 64 the execution time = 10.7 seconds.

-The addition & subtraction routines are similar but much simpler:

081   "A"
02B  "+"
001   "A"
287   CLRF 7
02B   JNC+05
081   "A"
02D  "-"
001   "A"
288   SETF 7
244   CLRF 9
321   ?NCXQ                   executes the initialization
3BC  EFC8                       routine above
2A0   SETDEC                 LOOP
0B0   C=N ALL
270   RAMSLCT
038   READATA
28C  ?FSET 7
013   JNC+02
2BE   C=-C
10E   A=C ALL
0B0   C=N ALL
03C   RCR 3
270    RAMSLCT
038   READATA
01D  C=
060   A+C
10E   A=C ALL
0B0  C=N ALL
03C  RCR 3
270   RAMSLCT
0AE  A<>C ALL
2F0   WRITDATA
260   SETHEX
0B0  C=N ALL
266   C=C-1 S&X
27A  C=C-1 M
070   N=C ALL
03C  RCR 3
106   A=C S&X
03C  RCR 3
306  ?A<C S&X
31B  JNC-29d                 GOTO LOOP
266  C=C-1 S&X
270  RAMSLCT
038  READATA
2A0  SETDEC
266   C
266   =
266   C/1000
10E  A=C ALL
046  C=0 S&X
270  RAMSLCT
04E  C
35C  =
050  1
01D  C
060  A+C
028  T=C
3B5  ?NCGO
052   R^

( 60 words / SIZE 2n+1 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the sum or the difference

-The following focal program does the same job:

 01  LBL "A+A"  02  CF 05  03  GTO 00  04  LBL "A-A"  05  SF 05  06  LBL 00  07  RCL 00  08  ENTER^  09  ST+ Y  10  LBL 01  11  RCL IND Y  12  FS? 05  13  CHS  14  ST+ IND Y  15  RDN  16  DSE Y  17  DSE X  18  GTO 01  19  RCL 00   20   E3  21  /  22  ISG X  23  END

-The sum - or the difference - is stored in registers R01 thru Rnn

1°)  Multiplication ( General Case )

a)  Program#1

-All these programs employ the Cayley-Dickinson formula recursively.
-The 1st version starts with complexes and may be used to compute the product of two  64-ons:
-Unfortunately, there are not enough registers for 128-ons.

Data Registers:           •  R00 = n ( 2 , 4 , 8 , 16 , 32 or 64 )     ( Registers R00 thru R2n are to be initialized before executing "A*A" )

•  R01   ......  •  Rnn = the n components of the 1st anion
•  Rn+1 ......  •  R2n = the n components of the 2nd anion

>>>  When the program stops:     R01   ......  Rnn = the n components of the product

-During the calculations,

R01-R02 = complex1   R05 to R08 = quaternion1  R13 to R20 = octonion1  R29 to R44 = sedenion1  R61 to R92 = 32-on1     R125 to R188 = 64-on1
R03-R04 = complex2   R09 to R12 = quaternion2  R21 to R28 = octonion2  R45 to R60 = sedenion2  R93 to R124 = 32-on2   R189 to R252 = 64-on2

Flags: /
Subroutines:  /

 01  LBL "A*A"   02  RCL 00   03  ST+ X   04  .1   05  %   06  +    07  3   08  -   09   E3   10  /   11  1   12  +   13  REGMOVE   14  XEQ 01   15  RCL 00   16   E3   17  /   18  ISG X   19  STO Y   20   E3    21  /   22  RCL 00   23  ST+ X   24  +   25  3   26  -   27  REGMOVE   28  X<>Y   29  RTN   30  LBL 01   31  2   32  ST/ 00   33  SIGN   34  RCL 00   35  X#Y?    36  GTO 02   37  RCL 01   38  RCL 03   39  * 40  RCL 02    41  RCL 04   42  *   43  -   44  X<> 01   45  RCL 04   46  *   47  RCL 02   48  RCL 03   49  *   50  +   51  STO 02   52  RCL 00   53  ST+ 00   54  RTN   55  LBL 02   56  RCL 00   57   E3   58  /   59  RCL 00   60  ST+ X   61  +   62  STO Y   63  3   64  -   65   E3    66  /   67  RCL 00   68  4   69  *    70  +   71  3   72  -   73  REGMOVE   74  +   75  REGMOVE   76  XEQ 01   77  RCL 00   78   E3 79  /   80  RCL 00   81  4   82  *   83  +   84  3   85  -   86   E3   87  /   88  RCL 00   89  ST+ X   90  +   91  3   92  -   93  REGSWAP   94  RCL 00   95   E3   96  /   97  -   98  REGMOVE   99  LASTX 100  - 101  RCL 00 102  5 103  * 104  + 105  REGMOVE 106  XEQ 01 107  RCL 00 108   E3 109  / 110  RCL 00 111  7 112  * 113  + 114  3 115  - 116   E3 117  / 118  RCL 00 119  ST+ X 120  + 121  3 122  - 123  REGSWAP 124  SIGN 125  CHS 126  ST* IND L 127  LASTX 128  RCL 00 129  2.996 130  * 131  + 132  REGMOVE 133  XEQ 01 134  RCL 00 135  3 136  * 137  4 138  - 139  RCL 00 140  ST+ X 141  LASTX 142  - 143  E3 144  / 145  + 146  RCL 00 147  5 148  * 149  4 150  - 151  STO Z 152  ISG Z 153  LBL 03 154  RCL IND Y 155  ST+ IND Y 156  RDN 157  DSE X 158  DSE Y 159  GTO 03 160  X<> Z 161  RCL 00 162   E3 163 / 164  RCL 00 165  ST+ X 166  + 167  3 168  - 169   E3 170  / 171  + 172  REGMOVE 173  RCL 00 174  .1 175  % 176  + 177  + 178  REGMOVE 179  FRC 180   E3 181  * 182  SIGN 183  CHS 184  ST* IND L 185  XEQ 01 186  RCL 00 187  3 188  * 189  4 190  - 191  RCL 00 192  ST+ X 193  LASTX 194  - 195   E3 196  / 197  + 198  RCL 00 199  8 200  * 201  4 202  - 203  LBL 04 204  RCL IND Y 205  ST- IND Y 206  RDN 207  DSE X 208  DSE Y 209  GTO 04 210  RCL 00 211   E3 212  / 213  RCL 00 214  5 215  * 216  + 217  3 218  - 219   E3 220  / 221  RCL 00 222  7 223  * 224  + 225  3 226  - 227  REGMOVE 228  RCL 00 229  ST+ 00 230  RTN 231  END

( 315 bytes / SIZE 4n-3 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    Product of 2 octonions.    8  STO 00

w = 2 + 4 e1 + 5 e2 + 10 e3 + 3 e4 + 7 e5 + 6 e6 + 9 e7
w' =  3 + 5 e1 + 6 e2 + 2 e3 + 7 e4 + 4 e5 + 9 e6 + 8 e7

2   STO 01         3   STO 05                     3   STO 09        7   STO 13
4   STO 02         7   STO 06                    5   STO 10        4   STO 14
5   STO 03        6   STO 07                     6   STO 11        9   STO 15
10  STO 04        9   STO 08                     2   STO 12        8   STO 16

XEQ "A*A"  >>>>   1.008                                                            ---Execution time = 52s---

-The result is in registers R01 thru R08

R01 = -239  ,  R02 = -32  ,  R03 = 74  ,  R04 = -45  ,   R05 = -29  ,  R06 = 134  ,  R07 = 14  ,  R08 = 79

whence     w.w' = - 239 - 32 e1 + 74 e2 - 45 e3 - 29 e4 + 134 e5 + 14 e6 + 79 e7

Notes:

-To save execution time, add the synthetic instruction  STO M after line 09  and replace all the other  E3  by  RCL M
-This version may also be used to compute the product of 2 complexes, but "A*A" will run faster
if we use "Q*Q" ( focal program or M-Code routine ) to calculate the product of 2 quaternions:

b)  Program#2

Data Registers:           •  R00 = n ( 4 , 8 , 16 , 32 or 64 )     ( Registers R00 thru R2n are to be initialized before executing "A*A" )

•  R01   ......  •  Rnn = the n components of the 1st anion
•  Rn+1 ......  •  R2n = the n components of the 2nd anion

>>>  When the program stops:     R01   ......  Rnn = the n components of the product

-During the calculations,

R01 to R04 = quaternion1    R09 to R16 = octonion1  R25 to R40 = sedenion1  R57 to R88 = 32-on1     R121 to R184 = 64-on1
R05 to R08 = quaternion2    R17 to R24 = octonion2  R41 to R56 = sedenion2  R89 to R120 = 32-on2   R185 to R248 = 64-on2

Flags: /
Subroutine:  The M-Code routine  Q*Q  ( cf "M-Code routines for quaternions )  line 36,
or the focal program  "Q*Q" ( cf "Quaternions for the HP-41 )

 01  LBL "A*A"   02  RCL 00   03  ST+ X   04  .1   05  %   06  +   07  7    08  -   09   E3   10  /   11  1   12  +   13  REGMOVE   14  XEQ 01   15  RCL 00   16   E3   17  /    18  ISG X   19  STO Y   20   E3   21  /    22  RCL 00   23  ST+ X   24  +   25  7    26  -   27  REGMOVE   28  X<>Y   29  RTN   30  LBL 01   31  2   32  ST/ 00   33  RCL 00   34  X#Y?    35  GTO 02   36  Q*Q   37  STO 01 38  RDN   39  STO 02   40  RDN   41  STO 03   42  X<>Y    43  STO 04   44  RCL 00   45  ST+ 00   46  RTN   47  LBL 02    48  RCL 00   49   E3   50  /   51  RCL 00    52  ST+ X   53  +   54  STO Y   55  7   56  -    57   E3   58  /   59  RCL 00   60  4    61  *   62  +   63  7    64  -   65  REGMOVE   66  +   67  REGMOVE   68  XEQ 01    69  RCL 00   70   E3   71  /   72  RCL 00   73  4    74  * 75  +   76  7    77  -   78   E3   79  /   80  RCL 00   81  ST+ X   82  +    83  7   84  -    85  REGSWAP   86  RCL 00    87   E3   88  /    89  -   90  REGMOVE   91  LASTX   92  -   93  RCL 00   94  5   95  *   96  +    97  REGMOVE   98  XEQ 01   99  RCL 00 100   E3 101  / 102  RCL 00 103  7 104  * 105  + 106  7 107  - 108   E3 109  / 110  RCL 00 111  ST+ X 112  + 113  7 114  - 115  REGSWAP 116  SIGN 117  CHS 118  ST* IND L 119  LASTX 120  RCL 00 121  2.996 122  * 123  + 124  REGMOVE 125  XEQ 01 126  RCL 00 127  3 128  * 129  8 130  - 131  RCL 00 132  ST+ X 133  LASTX 134  - 135   E3 136  / 137  + 138  RCL 00 139  5 140  * 141  8 142  - 143  STO Z 144  ISG Z 145  LBL 03 146  RCL IND Y 147  ST+ IND Y 148  RDN 149  DSE X 150  DSE Y 151  GTO 03 152  X<> Z 153  RCL 00 154   E3 155  / 156  RCL 00 157  ST+ X 158  + 159  7 160  - 161   E3 162  / 163  + 164  REGMOVE 165  RCL 00 166  .1 167  % 168  + 169  + 170  REGMOVE 171  FRC 172   E3 173  * 174  SIGN 175  CHS 176  ST* IND L 177  XEQ 01 178  RCL 00 179  3 180  * 181  8 182  - 183  RCL 00 184  ST+ X 185  LASTX 186  - 187   E3 188  / 189  + 190  RCL 00 191  8 192  ST* Y 193  - 194  LBL 04 195  RCL IND Y 196  ST- IND Y 197  RDN 198  DSE X 199  DSE Y 200  GTO 04 201  RCL 00 202   E3 203  / 204  RCL 00 205  5 206  * 207  + 208  7 209  - 210   E3 211  / 212  RCL 00 213  7 214  * 215  + 216  7 217  - 218  REGMOVE 219  RCL 00 220  ST+ 00 221  RTN 222  END

( 307 bytes / SIZE 4n-7 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    Same product of 2 octonions.    8  STO 00

w = 2 + 4 e1 + 5 e2 + 10 e3 + 3 e4 + 7 e5 + 6 e6 + 9 e7
w' =  3 + 5 e1 + 6 e2 + 2 e3 + 7 e4 + 4 e5 + 9 e6 + 8 e7

2   STO 01         3   STO 05                     3   STO 09        7   STO 13
4   STO 02         7   STO 06                     5   STO 10        4   STO 14
5   STO 03         6   STO 07                     6   STO 11        9   STO 15
10  STO 04         9   STO 08                     2   STO 12        8   STO 16

XEQ "A*A"  >>>>   1.008                                                            ---Execution time = 16s---

-The result is in registers R01 thru R08

R01 = -239  ,  R02 = -32  ,  R03 = 74  ,  R04 = -45  ,   R05 = -29  ,  R06 = 134  ,  R07 = 14  ,  R08 = 79

whence     w.w' = - 239 - 32 e1 + 74 e2 - 45 e3 - 29 e4 + 134 e5 + 14 e6 + 79 e7

Note:

-The M-Code routine Q*Q clears the alpha register.
-But if you use the focal program "Q*Q", add the synthetic instruction  STO O after line 09
and replace all the other  E3  by  RCL O: the routine will run faster.

c)  Program#3

-This 3rd version runs faster:
-The control numbers ( for REGMOVE and REGSWAP ) appears directly in the listing.

Data Registers:           •  R00 = n ( 8 , 16 , 32 or 64 )      ( Registers R00 thru R2n are to be initialized before executing "A*A" )

•  R01   ......  •  Rnn = the n components of the 1st anion
•  Rn+1 ......  •  R2n = the n components of the 2nd anion

>>>  When the program stops:     R01   ......  Rnn = the n components of the product

-During the calculations,

R01 to R04 = quaternion1    R09 to R16 = octonion1  R25 to R40 = sedenion1  R57 to R88 = 32-on1     R121 to R184 = 64-on1
R05 to R08 = quaternion2    R17 to R24 = octonion2  R41 to R56 = sedenion2  R89 to R120 = 32-on2   R185 to R248 = 64-on2

Flags: /
Subroutine:  The M-Code routine  Q*Q  ( cf "M-Code routines for quaternions" )
or the focal program  "Q*Q" ( cf "Quaternions for the HP-41" )

 01  LBL "A*A"   02  RCL 00   03  ST+ X   04  .1   05  %   06  +   07  7   08  -   09   E3   10  /   11  1   12  +   13  REGMOVE    14  XEQ IND 00   15  RCL 00   16   E3   17  /   18  ISG X   19  STO Y   20   E3   21  /   22  RCL 00   23  ST+ X   24  +   25  7   26  -   27  REGMOVE   28  X<>Y   29  RTN   30  LBL 08   31  9.001004   32  REGMOVE   33  17.005004   34  REGMOVE   35  Q*Q   36  X<> 09   37  STO 05 38  RDN   39  X<> 10   40  STO 06   41  RDN   42  X<> 11   43  STO 07   44  X<>Y   45  X<> 12   46  STO 08   47  21.001004   48  REGMOVE    49  Q*Q   50  STO 21   51  RDN   52  STO 22   53  RDN   54  STO 23   55  X<>Y   56  STO 24   57  RCL 01   58  CHS   59  STO 01   60  13.005004   61  REGMOVE   62  Q*Q   63  ST+ 09   64  RDN   65  ST+ 10   66  RDN   67  ST+ 11   68  X<>Y   69  ST+ 12   70  13.001004   71  REGMOVE   72  17.005004   73  REGMOVE   74  RCL 05 75  CHS   76  STO 05   77  Q*Q   78  ST- 21   79  RDN   80  ST- 22   81  RDN   82  ST- 23   83  X<>Y   84  ST- 24   85  21.013004   86  REGMOVE    87  RTN   88  LBL 16   89  25.009008   90  REGMOVE   91  41.017008   92  REGMOVE   93  XEQ 08   94  9.025008   95  REGSWAP   96  9.017008   97  REGMOVE   98  49.009008   99  REGMOVE 100  XEQ 08 101  9.049008 102  REGSWAP 103  RCL 09 104  CHS 105  STO 09 106  33.017008 107  REGMOVE 108  XEQ 08 109  16.008 110  32 111  XEQ 00 112  33.009008 113  REGMOVE 114  41.017008 115  REGMOVE 116  SIGN 117  CHS 118  ST* 17 119  XEQ 08 120  16.008 121  56 122  XEQ 01 123  49.033008 124  REGMOVE  125  RTN 126  LBL 32 127  57.025016 128  REGMOVE 129  89.041016 130  REGMOVE 131  XEQ 16 132  25.057016 133  REGSWAP 134  25.041016 135  REGMOVE 136  105.025016 137  REGMOVE 138  XEQ 16 139  25.105016 140  REGSWAP 141  SIGN 142  CHS 143  ST* 25 144  73.041016 145  REGMOVE 146  XEQ 16 147  40.024 148  72 149  XEQ 00 150  73.025016 151  REGMOVE 152  89.041016 153  REGMOVE 154  SIGN 155  CHS 156  ST* 41 157  XEQ 16 158  40.024 159  120 160  XEQ 01 161  105.073016 162  REGMOVE  163  RTN 164  LBL 64 165  121.057032 166  REGMOVE 167  185.089032 168  REGMOVE 169  XEQ 32 170  57.121032 171  REGSWAP 172  57.089032 173  REGMOVE 174  217.057032 175  REGMOVE 176  XEQ 32 177  57.217032 178  REGSWAP 179  SIGN 180  CHS 181  ST* 57 182  153.089032 183  REGMOVE 184  XEQ 32 185  88.056 186  152 187  XEQ 00 188  153.057032 189  REGMOVE 190  185.089032 191  REGMOVE 192  SIGN 193  CHS 194  ST* 89 195  XEQ 32 196  88.056 197  248 198  XEQ 01 199  217.153032 200  REGMOVE  201  RTN 202  LBL 00 203  RCL IND Y 204  ST+ IND Y 205  RDN 206  DSE X 207  DSE Y 208  GTO 00 209  RTN 210  LBL 01 211  RCL IND Y 212  ST- IND Y 213  RDN 214  DSE X 215  DSE Y 216  GTO 01 217  RTN 218  END

( 694 bytes / SIZE 4n-7 )

 STACK INPUT OUTPUT X / 1.nnn

where   1.nnn   is the control number of the product.

Example:    Again the same product of 2 octonions.    8  STO 00

w = 2 + 4 e1 + 5 e2 + 10 e3 + 3 e4 + 7 e5 + 6 e6 + 9 e7
w' =  3 + 5 e1 + 6 e2 + 2 e3 + 7 e4 + 4 e5 + 9 e6 + 8 e7

2   STO 01         3   STO 05                     3   STO 09        7   STO 13
4   STO 02         7   STO 06                     5   STO 10        4   STO 14
5   STO 03         6   STO 07                     6   STO 11        9   STO 15
10  STO 04         9   STO 08                     2   STO 12        8   STO 16

XEQ "A*A"  >>>>   1.008                                                            ---Execution time = 9s---

-The result is in registers R01 thru R08

R01 = -239  ,  R02 = -32  ,  R03 = 74  ,  R04 = -45  ,   R05 = -29  ,  R06 = 134  ,  R07 = 14  ,  R08 = 79

whence     w.w' = - 239 - 32 e1 + 74 e2 - 45 e3 - 29 e4 + 134 e5 + 14 e6 + 79 e7

Note:

-Several bytes may be saved, for instance,  line 96 may be replaced by  .008  -
-But the control numbers listed above are easier to understand.

2°)  Miscellaneous Functions

-These programs compute elementary functions of an "anion":

•  "1/A"    inverse of an anion a # 0

A-1 = A* / | A |2    where A* is the conjugate of  A   and   | A |2 = x02 + x12 + ................. + xN-12

•  "E^A"   exponential

exp( x0 + x1 e1 + .... + xN-1 eN-1 ) = ex0 [ cos µ + ( sin µ ). I ]

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•   "LNA"  natural logarithm

Ln( x0 + x1 e1 + .................+ xN-1 eN-1 )   = Ln ( x02 + x12 + .................. + xN-12 )1/2 + Atan2(µ,x0). I

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

-If  µ = 0  ,    I  is replaced by  e1

•  "A^X"  raising an anion to a real power         A^X = exp ( X Ln A )

•  "X^A"  raising a real to an anionic power       X^A = exp ( A Ln X )

•  "SHA"  hyperbolic sine

Sinh ( x0 + x1 e1 + .... + xN-1 eN-1 )  =  Sinh x0 Cos µ  + I ( Cosh x0 ) ( Sin µ )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•  "CHA"  hyperbolic cosine

Cosh ( x0 + x1 e1 + .... + xN-1 eN-1 )  =  Cosh x0 Cos µ  + I ( Sinh x0 ) ( Sin µ )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•  "THA"  hyperbolic tangent

Tanh a = ( Sinh a ) ( Cosh a ) -1

•  "ASHA"  arc sinh a = Ln [ a + ( a2 + 1 )1/2 ]

•  "ACHA"  arc cosh a = Ln [ a + ( a2 - 1 )1/2 ]

•  "ATHA"   arc tanh a = 1/2) [ Ln ( 1 + a ) - Ln ( 1 - a ) ]

•  "SINA"   sine

Sin ( x0 + x1 e1 + .... + xN-1 eN-1 )  =  Sin x0 Cosh µ  + I ( Cos x0 ) ( Sinh µ )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•  "COSA"  cosine

Cos ( x0 + x1 e1 + .... + xN-1 eN-1 )  =  Cos x0 Cosh µ  - I ( Sin x0 ) ( Sinh µ )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•  "TANA"    Tan a = ( Sin a ) ( Cos a ) -1

•  "ASINA"    arc sin a

If   a  =  x0 + x1 e1 + .... + xN-1 eN-1       ,       Arc Sin a     = - I  Arc Sinh ( a  I )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

•  "ACOSA"  arc cos a  = PI/2 - ArcSin a

•  "ATANA"  arc tan a

If   a  =  x0 + x1 e1 + .... + xN-1 eN-1        ,           Arc Tan a     = - I  Arc Tanh ( a  I )

where  µ = ( x12 + ............... + xN-12 )1/2    and    I = ( x1 e1 + ............. + xN-1 eN-1 ) / µ

Remark:

-I've used     arc cosh a = Ln [ a + ( a2 - 1 )1/2 ]

instead of the standard definition    Arc Cosh a  = Ln [ a + ( a + 1 )1/2 ( a - 1 )1/2 ]

-So, "ACHA" may give a result that requires a sign change to get the principal value of  Arc Cosh a.
-See the notes below if you prefer the standard definition.

Data Registers:           •  R00 = n ( 2 , 4 , 8 , .... , 128 or 256 )    ( Registers R00 thru Rnn are to be initialized before executing these programs )

•  R01   ......  •  Rnn = the n components of the anion

( In some cases,             Rn+1 ..........  R2n  are used for temporary data storage )

>>>  When the program stops:     R01   ......  Rnn = the n components of the result

Flags:  F01 & F02  ( not always )
Subroutines:  /

-Lines 16-26-159-199-216-256-400 are three-byte GTO's
-However, these instructions are executed only once, so they could be replaced by two-byte GTO's to save a few bytes.

 01  LBL "1/A"   02  XEQ 14   03  LASTX   04  RCL 01   05  X^2    06   +   07  CHS   08  RCL 00   09  X<>Y   10  LBL 07   11  ST/ IND Y   12  DSE Y   13  GTO 07   14  SIGN   15  ST* 01   16  GTO 01   17  LBL "ACOSA"   18  XEQ 04   19  RCL 00   20  PI   21  2   22  /   23  ST- 01   24  SIGN   25  CHS   26  GTO 03   27  LBL 04   28  LBL "ASINA"   29  CF 01   30  GTO 04   31  LBL "ATANA"   32  SF 01   33  LBL 04   34  RCL 01   35  X#0?   36  GTO 04   37  XEQ 14   38  FC? 01   39  GTO 17   40  1   41  X<>Y   42  CF 02   43  X>Y?   44  SF 02   45  STO Z   46  X>Y?   47  1/X   48  ENTER   49  ST+ X   50  X<> Z   51  -   52  CHS   53  /   54  LN1+X   55  2   56  /   57  R^   58  X=0?   59  SIGN   60  /   61  XEQ 18   62  PI   63  2   64  /   65  FC?C 02   66  CLX   67  STO 01   68  GTO 01   69  LBL 17   70  ENTER   71  ENTER   72  X^2   73  1   74  +   75  SQRT   76   +   77  LN   78  X<>Y   79  X=0? 80  SIGN   81  /   82  XEQ 18   83  GTO 01    84  LBL 04   85  XEQ 14   86  CHS    87  X#0?   88  GTO 04   89  SIGN   90  STO 02    91  CLX   92  LBL 04   93  X<> 01   94  RCL 00    95   E-3   96  +   97  CLA   98  LBL 00   99  RCL N 100  ABS 101  RCL IND Y     102  ABS 103  X Z 106  STO O 107  X<> Z 108  CLX 109  LASTX 110  STO N 111  LBL 00 112  RDN 113  X<> L 114  RCL Z 115  * 116  RCL 01 117  CHS 118  X=0? 119  SIGN 120  / 121  STO IND Y  122  RDN 123  DSE X 124  GTO 00 125  FC? 01 126  XEQ 15 127  FS? 01 128  XEQ 16 129  XEQ 14 130  X#0? 131  GTO 04 132  SIGN 133  STO 02 134  CLX 135  LBL 04 136  RCL IND O 137  RCL N 138  * 139  SIGN 140  * 141  X<> 01 142  CHS 143  RCL 00 144   E-3 145  + 146  LBL 11 147  RCL IND X 148  RCL Z 149  * 150  RCL 01 151  X=0? 152  SIGN 153  / 154  STO IND Y 155  RDN 156  DSE X 157  GTO 11 158  CLA 159  GTO 01 160  LBL 12 161  LBL "A^X" 162  XEQ 14 163  R^ 164  X<>Y 165  LASTX 166  RCL 01 167  X^2 168  + 169  X<>Y 170  PI 171  INT 172  CHS 173  10^X 174  SIGN 175  CLX 176  RCL 00 177  ST+ L 178  RDN 179  LBL 09 180  X#0? 181  ST/ IND L       182  DSE L 183  GTO 09 184  X#0? 185  GTO 04 186  SIGN 187  STO 02 188  CLX 189  LBL 04 190  RCL 01 191  R-P 192  R^ 193  ST* Z 194  Y^X 195  P-R 196  STO 01 197  CLX 198  SIGN 199  GTO 02 200  LBL "X^A"  201  LN 202  RCL 00 203  X<>Y 204  XEQ 03 205  LBL "E^A" 206  XEQ 14 207  ENTER 208  R-D 209  RCL 01 210  E^X 211  P-R 212  STO 01 213  X<> Z 214  X=0? 215  SIGN 216  GTO 02 217  LBL "SINA" 218  CF 01 219  GTO 04 220  LBL "COSA" 221  SF 01 222  LBL 04 223  XEQ 14 224  ENTER 225  E^X 226  LASTX 227  CHS 228  E^X 229  + 230  2 231  / 232  RCL 01 233  R-D 234  1 235  P-R 236  FS? 01 237  X<>Y 238  RDN 239  * 240  STO 01 241  RDN 242  STO Z 243  E^X-1 244  LASTX 245  CHS 246  E^X-1 247  - 248  2 249  / 250  * 251  FS? 01 252  CHS 253  X<>Y 254  X=0? 255  SIGN 256  GTO 02 257  LBL "SHA" 258  CF 01 259  GTO 04 260  LBL "CHA"     261  SF 01 262  LBL 04 263  XEQ 14 264  X<> 01 265  ENTER 266  E^X 267  LASTX 268  CHS 269  E^X 270  + 271  X<>Y 272  E^X-1 273  LASTX 274  CHS 275  E^X-1 276  - 277  2 278  ST/ Z 279  / 280  FS? 01 281  X<>Y 282  RCL 01 283  R-D 284  1 285  P-R 286  X<>Y 287  ST* T 288  RDN 289  * 290  X<> 01 291  X=0? 292  SIGN 293  GTO 02 294  LBL 15 295  LBL "ASHA" 296  CF 01 297  GTO 04 298  LBL "ACHA" 299  SF 01 300  LBL 04 301  CF 02 302  RCL 01 303  X=0? 304  SF 02 305  XEQ 14 306  FS? 02 307  STO M 308  XEQ 06 309  2 310  XEQ 12 311  1 312  FS? 01 313  CHS 314  ST+ 01 315  .5 316  XEQ 12 317  RCL 01 318  FS?C 02 319  X#0? 320  GTO 04 321  RCL 02 322  RCL 00 323   E3 324  / 325  ISG X 326  STO Z 327  LASTX 328  / 329  1 330  + 331  RCL 00 332  + 333  REGMOVE 334  CLX 335  X<> M 336  R^ 337  SIGN 338  ST+ L 339  LBL 20 340  CLX 341  RCL IND L     342  X#0? 343  GTO 21 344  ISG L 345  GTO 20 346  LBL 21 347  SIGN 348  FC? 01 349  ST* Z 350   RDN 351  ST+ Y 352  X=0? 353  SIGN 354  / 355  XEQ 18 356  GTO 13 357  LBL 04 358  RCL 00 359  ENTER 360  ST+ Y 361  LBL 08 362  RCL IND Y 363  ST+ IND Y 364  RDN 365  DSE Y 366  DSE X 367  GTO 08 368  LBL 13 369  LBL "LNA" 370  XEQ 14 371  STO Y 372  LASTX 373  RCL 01 374  X^2 375  + 376  SQRT 377  LN 378  X<> 01 379  R-P 380  RDN 381  D-R 382  X<>Y 383  X#0? 384  GTO 02 385  SIGN 386  STO 02 387  LBL 02 388  / 389  RCL 00 390  PI 391  INT 392  CHS 393  10^X 394  + 395  X<>Y 396  LBL 03 397  ST* IND Y 398  DSE Y 399  GTO 03 400  GTO 01 401  LBL "TANA" 402  XEQ 14 403  X<> 01 404  R-D 405  1 406  P-R 407  ST* Y 408  X^2 409  RCL 01 410  E^X-1 411  LASTX 412  CHS 413  E^X-1 414  - 415  2 416  / 417  STO T 418  X^2 419  + 420  ST/ Z 421  / 422  X<> 01           423  STO Z 424  E^X 425  LASTX 426  CHS 427  E^X 428  + 429  2 430  / 431  * 432  X<>Y 433  X=0? 434  SIGN 435  GTO 02 436  LBL "THA"  437  XEQ 14 438  RCL 01 439  E^X 440  LASTX 441  CHS 442  E^X 443  + 444  RCL 01 445  E^X-1 446  LASTX 447  CHS 448  E^X-1 449  - 450  2 451  ST/ Z 452  / 453  ST* Y 454  X^2 455  RCL Z 456  R-D 457  COS 458  STO 01 459  X^2 460  + 461  STO T 462  / 463  X<> 01 464  RCL Y 465  R-D 466  SIN 467  * 468  X<>Y 469  X=0? 470  SIGN 471  / 472  X<>Y 473  GTO 02 474  LBL 14 475  DEG 476  RCL 00 477  PI 478  INT 479  CHS 480  10^X 481  ST+ Y 482  CLX 483  LBL 05 484  RCL IND Y 485  X^2 486  + 487  DSE Y 488  GTO 05 489  SQRT 490  RTN 491  LBL 06 492  RCL 00 493  .1 494  % 495  ISG X 496  + 497   E3 498  / 499  1 500  + 501  REGMOVE     502  RTN 503  LBL 18 504  RCL 00 505  X<>Y 506  LBL 19 507  ST* IND Y 508  DSE Y 509  GTO 19 510  RTN 511  LBL 16 512  LBL "ATHA"  513  XEQ 06 514  STO M 515  SIGN 516  ST- 01 517  RCL 00 518  X<>Y 519  ST+ Y 520  ST+ IND Y 521  RCL 00 522  X<>Y 523  CHS 524  XEQ 03 525  XEQ 13 526  CLX 527  X<> M 528  REGSWAP 529  XEQ 13 530  RCL 00 531  ENTER 532  ST+ Y 533  LBL 10 534  RCL IND X 535  RCL IND Z 536  - 537  2 538  / 539  STO IND Y 540  RDN 541  DSE Y 542  DSE X 543  GTO 10 544  LBL 01 545  RCL 00 546  PI 547  INT 548  10^X 549  / 550  ISG X 551  END

( 893 bytes / SIZE n+1 or 2n+1 )

 STACK INPUT OUTPUT X /  or  x 1.nnn

X-input x is required for "A^X" & "X^A" only   and   1.nnn   is the control number of the result.

Example:   You can use the examples given in "Octonions for the HP-41" or "Sedenions for the HP-41"

-The instructions are identical except that here,  R00 = n.

-So, for raising an anion to a real power x, x must be in X-register instead of R00:

w = 1 + 0.9 e1 + 0.8 e2 + 0.7 e3 + 0.6 e4 + 0.5 e5 + 0.4 e6 + 0.3 e7   and    x = PI

8    STO 00    ( octonion )

1    STO 01         0.6   STO 05
0.9  STO 02         0.5   STO 06
0.8  STO 03         0.4   STO 07
0.7  STO 04         0.3   STO 08

PI  XEQ "A^X"   >>>>    1.008                                         ---Execution time = 7s---

-The components of  wx  are stored in  R01 thru R08

R01 = -8.100378663     R02 = -0.441313112     R03 = -0.392278322    R04 = -0.343243532
R05 = -0.294208741     R06 = -0.245173951     R07 = -0.196139161    R08 = -0.147104371

-So,  wPI =  -8.100378663 - 0.441313112  e1 - 0.392278322 e2 - 0.343243532 e3
- 0.294208741 e4 - 0.245173951 e5 - 0.196139161 e6 - 0.147104371 e7

Notes:

-These programs may be used with complexes, quaternions, octonions, sedenions, 32-ons, 64-ons, 128-ons,
and even 256-ons for "1/A" , "A^X" ,  "X^A" , "E^A" , "LNA" , "SHA" , "CHA" , "THA" , "SINA" , "COSA" , "TANA"
-I've sometimes used   PI  INT  CHS  10^X  instead of  E-3  to keep the content of synthetic register P
-This is useful when "A^X" is called as a subroutine by special functions like the hypergeometric functions.

-If possible, line 143 should be an M-Code routine  Y^X  to get  0^0 = 1

-The routines do not check that n is an integer power of 2.

-The standard definition of  Arc Cosh a = = Ln [ a + ( a + 1 )1/2 ( a - 1 )1/2 ]  is applied by the following routine:

 01  LBL "ACHA"  02  RCL 00  03  .1  04  %  05  STO Z  06  +  07  1  08  +  09  STO Z 10   E3  11  /  12  1  13  +  14  STO M  15  REGMOVE   16  +  17  REGMOVE  18  SIGN 19  ST+ 01  20  ST- IND Y  21  .5  22  XEQ "A^X"  23  0  24  X<> M  25  REGSWAP   26  .5  27  XEQ "A^X" 28  XEQ "A*A1"  29  RCL 00  30  3  31  *  32  RCL 00  33  LBL 01  34  RCL IND Y   35  ST+ IND Y  36  RDN 37  DSE Y  38  DSE X  39  GTO 01  40  XEQ "LNA"   41  END

( 85 bytes / SIZE 3n+1 )

-However, since the SIZE = 3n+1,  this variant cannot compute the Arc Cosh  of a 128-on !
-This routine may of course be inserted in the programs above to save bytes ( replace LBL 01 by another unused LBL )

Other elementary functions

-The "self-power function" is defined unambiguously by   a^a = exp ( ( Ln a ) a )

 01  LBL "A^A0"  02  RCL 00  03  .1  04  %  05  ISG X  06  +  07   E3  08  /  09  1  10  +  11  REGMOVE  12  XEQ "LNA"  13  XEQ "A*A1"  14  XEQ "E^A"  15  END

( 41 bytes / SIZE 2n+1 )

-The more general function  a^b  may be defined in several ways.
-If you define it by  a^b = exp ( ( Ln a ) b ) ,

>>>  simply replace line 13 above by  XEQ "A*A" - where  "A*A" is listed in §1°)a) above - and delete lines 02 to 11

-The square of an anion may be computed with "A*A1"
-The short routine "A^2" hereunder will be faster and, since it uses only n+1 registers, it can compute the square of a 256-on !

 01  LBL "A^2"  02  RCL 00  03   E-3  04  +  05  RCL 01  06  X^2  07  LBL 01  08  RCL IND Y   09  X^2  10  -  11  RCL 01  12  ST+ X  13  ST* IND Z  14  RDN  15  DSE Y  16  GTO 01  17  STO 01  18  RCL 00  19   E3  20  /  21  ISG X  22  END

( 39 bytes / SIZE n+1 )

 STACK INPUT OUTPUT X / 1.nnn

Example:           a = 4 + 5 i + 6 j + 7 k         ( quaternion  ->  4  STO 00 )

4  STO 01
5  STO 02
6  STO 03
7  STO 04      XEQ "A^2"   >>>>   1.004                 ---Execution time = 1.5s---

R01 = -94
R02 =  40
R03 =  48
R04 =  56

-Thus,     ( 4 + 5 i + 6 j + 7 k )2 = - 94 + 40 i + 48 j + 56 k

Notes:

-If n = 64 , execution time = 24 seconds
-"A^X"  may also be used with X = 2,  but with slightly less accurate results.

Gudermannian Function

Formulae:    Gd(a) = 2 ArcTan [ Tanh (a/2) ]  and its inverse:   Agd(a) = 2 ArcTanh [ Tan(a/2) ]

( "ST*A" & "ST/A" are listed in "Anionic Special Functions(I) for the HP-41" )

 01  LBL "GDA"  02  2  03  XEQ "ST/A"  04  XEQ "THA"  05  XEQ "ATANA"  06  2   07  XEQ "ST*A"  08  X<>Y  09  RTN  10  LBL "AGDA"  11  2  12  XEQ "ST/A"  13  XEQ "TANA"  14  XEQ "ATHA"  15  2  16  XEQ "ST*A"  17  X<>Y  18  END

( 73 bytes / SIZE 2n+1 )

 STACK INPUT OUTPUT X / 1.nnn

Example:           a = 1 + 2 i + 3 j + 4 k         ( quaternion  ->  4  STO 00 )

1  STO 01
2  STO 02
3  STO 03
4  STO 04      XEQ "GDA"   >>>>   1.004                 ---Execution time = 15s---

R01 =  1.083236673
R02 = -0.207409846
R03 = -0.311114768
R04 = -0.414819691

-So,  Gd( 1 + 2 i + 3 j + 4 k ) = 1.083236673 - 0.207409846 i - 0.311114768 j - 0.414819691 k

-Likewise, you'll find:  Agd( 1 + 2 i + 3 j + 4 k ) = 0.007714740 + 0.581539372 i + 0.872309058 j + 1.163078744 k    ( in 10 seconds )

Note:

-Of course, this list of functions is not exhaustive...

3°)  Anionic Polynomials - Real Coefficients

APVAL  evaluates  p(a) = cm am + cm-1 am-1 + ................ + c1 a + c0    for  a given anion a  and  (m+1) real numbers  cm , .............. , c1 , c0

-Store the anion a in registers  R01 trhu Rnn  as usual, and the coefficients of the polynomial in Rbb thru Ree  with  bb > 2n

Data Registers:           •  R00 = n > 1                     ( Registers R00 thru Rnn & Rbb thru Ree are to be initialized before executing "APVAL" )

•  R01   ......  •  Rnn = a
Rn+1 ........   R2n = a   ( a is saved in Rn+1 thru R2n )

•  Rbb = cm ,  •  Rb+1 = cm-1 , ................. , •  Ree = c0

>>>  When the program stops:     R01   ......  Rnn = the n components of p(a)

Flags: /
Subroutine:    "ST*A"   ( cf paragraph 0 above )
"A*A1"   ( cf "Anionic Functions(I) for the HP-41" )

 01  LBL "APVAL"  02  STO M  03  RCL 00  04  .1  05  %  06  ISG X  07  +  08   E3  09  /  10  1  11  +  12  REGMOVE  13  CLX  14  XEQ "ST*A"  15  LBL 01  16  XEQ "A*A1"  17  RCL IND M  18  ST+ 01  19  ISG M  20  GTO 01  21  CLX  22  X<> M  23  RCL 00  24   E3  25  /  26  ISG X  27  END

( 59 bytes )

 STACK INPUT OUTPUT X bbb.eee 1.nnn

where  bbb.eee  is the control number of the polynomial    ( bbb > 2n )

Example:           a = 1 + 2 i + 3 j + 4 k         ( quaternion  ->  4  STO 00 )          p(a) = 6 a5 + 2 a4 + 3 a3 + 7 a2 + 4 a + 1

1  STO 01       and if you choose  bb = 9       6  STO 09          7  STO 12        control number   9.014
2  STO 02                                                     2  STO 10          4  STO 13
3  STO 03                                                     3  STO 11          1  STO 14
4  STO 04

9.014   XEQ "APVAL"  >>>>   1.004      ( in 4 seconds with the M-Code routine  A*A1 )

R01 = 24383
R02 = 6104
R03 = 9156
R04 = 12208

-Whence,              p(a) = 24383 + 8104 i + 9156 j + 12208 k

4°)  Anionic Equations

-The following program uses the iterative method also used for quaternionic ( or octonionic or sedenionic ) equations:

-The equation must be rewritten in the form:    f ( a ) = a
and if  f  satisfies a Lipschitz condition   | f(a) - f(a') | < h | a - a' |   with  h < 1  ,   provided a and a' are close to a solution,
then the sequence  an+1 = f ( an )  converges to a root.

Data Registers:           •  R00 =  n  ( 2 , 4 , 8 , .... )    ( Registers R00 thru Rnn are to be initialized before executing "AEQ" )

•  R01 to Rnn = the n components of the anion  a          R2n+1 to R3n: temp  ,  R3n+1 = fname

Rnn+1 to R2n  may be used by the subroutine.

>>>>     When the program stops,        R01 to Rnn = the n components of  a solution  a

Flags: /
Subroutine:  A program that takes the anion a   in R01 thru Rnn , calculates and stores  f ( a )  in R01 thru Rnn
without disturbing R2n+1 to R3n+1

 01  LBL "AEQ"  02  RCL 00  03  3  04  *  05  1  06  +  07  ASTO IND X  08  LBL 01  09  VIEW 01  10  RCL 00  11   E3 12  /  13  ISG X  14  RCL 00  15  ST+ X  16  +  17   E3  18  /  19  1  20  +  21  REGMOVE    22  SIGN 23  RCL 00  24  3  25  *  26  +  27  RCL IND X   28  XEQ IND X   29  3  30  RCL 00  31  ST* Y  32  0  33  LBL 02 34  RCL IND Y    35  ST- IND T  36  CLX  37  RCL IND T   38  ABS  39  +  40  DSE Z  41  DSE Y  42  GTO 02  43  X#0?  44  GTO 01 45  RCL 00  46  3  47  *  48  1  49  +  50  ARCL IND X  51  RCL 00  52   E3  53  /  54  ISG X  55  END

( 83 bytes / SIZE 3n+2 )

 STACK INPUTS OUTPUTS Alpha f name f name X / 1.nnn

where  1.nnn  = control number of the solution

Example:     Find a solution of the octonionic equation    w2  - Ln w  + 1 + 0.9 e1 + 0.8 e2 + 0.7 e3 + 0.6 e4 + 0.5 e5 + 0.4 e6 + 0.3 e7 = 0

near   1 + e1 + e2 + e3 + e4 + e5 + e6 + e7

-First, we re-write this equation:    w  =  ( Ln w  - 1 - 0.9 e1 - 0.8 e2 - 0.7 e3 - 0.6 e4 - 0.5 e5 - 0.4 e6 - 0.3 e7 ) 1/2  =  f ( w )

-The short routine "T" hereunder computes  f ( w )
-Note that here, the exponent 1/2 must be in X-register before calling "A^X"

 01  LBL "T"  02  XEQ "LNA"  03  1  04  ST- 01  05  .9  06  ST- 02  07  .8  08  ST- 03  09  .7  10  ST- 04  11  .6  12  ST- 05  13  .4  14  ST- 07  15  .3  16  ST- 08  17  .5  18  ST- 06  19  XEQ "A^X"  20  RTN  21  END

-Then,  n = 8  ASTO 00

-Initial approximation:     1  STO 01  STO 02  STO 03  STO 04  STO 05  STO 06  STO 07  STO 08

-Place the subroutine name in the alpha register:  alpha  "T"  alpha

XEQ "AEQ"   >>>>    the successive approximations of the real part of the solution are displayed, and eventually, we get:

X =  1.008 = control number of the solution.

R01 = 1.022547760  ,  R02 = -0.673000418 ,  R03 =  -0.598222594  ,   R04 =  -0.523444770
R05 = -0.448666946  ,  R06 = -0.373889122  ,  R07 = -0.299111297  ,  R08 = -0.224333473

-Whence:

w  =  1.022547760 - 0.673000418  e1 - 0.598222594 e2 - 0.523444770 e3
- 0.448666946 e4 - 0.373889122 e5 - 0.299111297 e6 - 0.224333473 e7      is a solution of this equation.

Notes:

-The convergence is very slow.
-If  f doesn't satisfy the required Lipschitz condition or if we choose a bad initial guess, the algorithm may be divergent.
-Rewriting the equation in a proper form is often very difficult.

-Instead of displaying the real parts of the successive approximations, you could display the difference between 2 successive approximations:
-Add  VIEW X  after line 42  and delete line 09 VIEW 01
-If the algorithm converges, these differences tend to 0.

-The termination criterion  X#0? ( line 43 ) may lead to an infinite loop.
-Line 43 may be replaced by

E-8        ( or another "small" number )
X<Y?

Remark:

-In this example, registers  Rn+1 to R2n are actually unused.
-In similar cases, the "AEQ'" listing may be modified as follows:

Replace lines 03-24-29-46 by 2 ( instead of 3 )
And delete line 15 ( ST+ X )

-SIZE 2n+2 becomes sufficient.