hp41programs

AnionicFunctions

Anionic Functions for the HP-41


Overview
 

-The following routines are variants of the programs listed in "Anions for the HP41" paragraph 2°)
-The whole program is shorter but it sometimes uses more data registers.

-I've also added the "self-power function".
 
 

Program Listing
 
 

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

                                         Rn+1 ..........  R2n  - and even R2n+1 ...... R3n - are sometimes used for temporary data storage

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

Flags:  F05-F06  ( not always )
Subroutines:  /
 

-Lines 25-71-101 are three-byte GTOs
 
 

 01 LBL "1/A"
 02 LBL 18
 03 XEQ 14
 04 LASTX
 05 RCL 01
 06 X^2
 07 +
 08 CHS
 09 RCL 00
 10 X<>Y
 11 1/X
 12 XEQ 03
 13 SIGN
 14 ST* 01
 15 RTN
 16 LBL "ACOS"   
 17 XEQ 04
 18 RCL 00
 19 PI
 20 2
 21 /
 22 ST- 01
 23 SIGN
 24 CHS
 25 GTO 03
 26 LBL "ASIN"
 27 LBL 04
 28 CF 05
 29 GTO 04
 30 LBL "ATAN"
 31 SF 05
 32 LBL 04
 33 XEQ 06
 34 XEQ 14
 35 X#0?
 36 GTO 04
 37 SIGN
 38 STO 02
 39 LBL 04
 40 0
 41 STO 01
 42 SIGN
 43 X<>Y
 44 XEQ 02
 45 RCL 00
 46 .1
 47 %
 48 ISG X
 49 +
 50 RCL 00
 51 +
 52 .1
 53 %
 54 1
 55 +
 56 STO O
 57 REGMOVE     
 58 XEQ 09
 59 FC? 05
 60 XEQ 15
 61 FS? 05
 62 XEQ 16
 63 RCL O
 64 RCL 00
 65 +
 66 REGSWAP
 67 XEQ 09
 68 RCL 00
 69 1
 70 CHS
 71 GTO 03
 72 LBL "A^X"
 73 LBL 12
 74 STO M
 75 XEQ 13
 76 RCL 00
 77 RCL M
 78 XEQ 03
 79 GTO 07
 80 LBL "X^A"
 81 LN
 82 RCL 00
 83 X<>Y
 84 XEQ 03
 85 GTO 07
 86 LBL "A^A"
 87 XEQ 06
 88 XEQ 13
 89 XEQ 09
 90 LBL "E^A"
 91 LBL 07
 92 XEQ 14
 93 R-D
 94 RCL 01
 95 E^X
 96 P-R
 97 STO 01
 98 X<> Z
 99 X=0?
100 SIGN
101 GTO 02
102 LBL "SIN"
103 LBL 19
104 CF 05
105 CF 06
106 GTO 04
107 LBL "COS"    
108 LBL 20
109 SF 05
110 CF 06
111 GTO 04
112 LBL "SH"
113 LBL 11
114 CF 05
115 SF 06
116 GTO 04
117 LBL "CH"
118 LBL 00
119 SF 05
120 SF 06
121 LBL 04
122 XEQ 14
123 X<> 01
124 FC? 06
125 X<>Y
126 ENTER
127 E^X-1
128 LASTX
129 CHS
130 E^X-1
131 -
132 X<>Y
133 E^X
134 ENTER
135 1/X
136 +
137 2
138 ST/ Z
139 /
140 R^
141 R-D
142 1
143 P-R
144 FS? 05
145 X<>Y
146 ST* T
147 RDN
148 *
149 FC? 05
150 FC? 06
151 X<>Y
152 FS? 05
153 FS? 06
154 FS? 30
155 CHS
156 X<>Y
157 X<> 01
158 X=0?
159 SIGN
160 GTO 02
161 LBL "ASH"     
162 LBL 15
163 CF 05
164 GTO 04
165 LBL "ACH"
166 SF 05
167 LBL 04
168 XEQ 06
169 XEQ 09
170 1
171 FS? 05
172 CHS
173 ST+ 01
174 2
175 1/X
176 XEQ 12
177 RCL 00
178 ENTER
179 ST+ Y
180 LBL 08
181 RCL IND Y
182 ST+ IND Y
183 RDN
184 DSE Y
185 DSE X
186 GTO 08
187 LBL "LN"
188 LBL 13
189 XEQ 14
190 LASTX
191 RCL 01
192 X^2
193 +
194 SQRT
195 X=0?
196 GTO 04
197 LN
198 GTO 13
199 LBL 04
200 ACOS
201 TAN
202 CHS
203 LBL 13           
204 X<> 01
205 R-P
206 RDN
207 D-R
208 X<>Y
209 X#0?
210 GTO 02
211 SIGN
212 STO 02
213 LBL 02
214 /
215 RCL 00
216  E-3
217 +
218 X<>Y
219 LBL 03
220 ST* IND Y
221 DSE Y
222 GTO 03
223 RTN
224 LBL "TAN"
225 XEQ 06
226 XEQ 19
227 X<> M
228 REGSWAP
229 XEQ 20
230 GTO 04
231 LBL "TH"
232 XEQ 06
233 XEQ 11
234 X<> M
235 REGSWAP
236 XEQ 00
237 LBL 04
238 XEQ 18
239 LBL 09
240 RCL 00
241  E-3
242 +
243 STO M
244 1
245 +
246 RCL 00
247 ST+ X
248 STO N
249 RCL IND Y    
250 STO Y
251 RCL 01
252 *
253 LBL 01
254 RCL 01
255 RCL IND N
256 *
257 RCL IND M
258 R^
259 ST* Y
260 RDN
261 +
262 X<> IND M
263 RCL IND N
264 *
265 -
266 DSE N
267 DSE M
268 GTO 01
269 STO 01
270 RTN
271 LBL 14
272 RCL 00
273  E-3
274 +
275 0
276 LBL 05
277 RCL IND Y
278 X^2
279 +
280 DSE Y
281 GTO 05
282 SQRT
283 ENTER
284 RTN
285 LBL 06
286 RCL 00
287 .1
288 %
289 ISG X
290 +
291 .1
292 %
293 1
294 +
295 STO M
296 REGMOVE     
297 RTN
298 LBL "ATH"
299 LBL 16
300 XEQ 06
301 SIGN
302 ST- 01
303 RCL 00
304 X<>Y
305 ST+ Y
306 ST+ IND Y
307 RCL 00
308 X<>Y
309 CHS
310 XEQ 03
311 XEQ 13
312 X<> M
313 REGSWAP
314 XEQ 13
315 RCL 00
316 ENTER
317 ST+ Y
318 LBL 10
319 RCL IND X
320 RCL IND Z
321 -
322 2
323 /
324 STO IND Y
325 RDN
326 DSE Y
327 DSE X
328 GTO 10
329 END

 
      ( 620 bytes / SIZE n+1 or 2n+1 or 3n+1 )
 
 

      STACK        INPUT      OUTPUT
           X         /  or  x            /

   X-input x is required for "A^X" & "X^A" only.

Examples:      XEQ  DEG

1°)   Q = 6 + 7 i + 8 j + 9 k     Calculate  Q^Q

-Quaternion so:   4  STO 00

        6  STO 01  7  STO 02  8  STO 03  9  STO 04

        XEQ "A^A"  >>>>   0.710111872 + 0.426305198 i + 0.487205940 j + 0.548106683 k     in R01 thru R04
 

2°)   O = 0 + 0.1 e1 + 0.2 e2 + 0.3 e3 + 0.3 e4 + 0.4 e5 + 0.5 e6 + 0.6 e7    Calculate Arc Sinh O

-Octonion so:    8  STO 00

     0  STO 01  0.1  STO 02  0.2  STO 03  0.3  STO 04  0.3  STO 05  0.4  STO 06  0.5  STO 07  0.6  STO 08  ( an octonion such that O^2 = -1 )

     XEQ "ASH"  >>>>   0 + 0.157079633 e1 + 0.314159265 e2 + 0.471238898 e3 + 0.471238898 e4       in R01-R02-R03-R04-R05
                                   + 0.628318531 e5 + 0.785398164 e6 + 0.942477796 e7                                              R06-R07-R08
 

3°)    S = 1 + 0.95 e1 + 0.9 e2 + 0.85 e3 + 0.8 e4 + 0.75 e5 + 0.7 e6 + 0.65 e7 + 0.6 e8      Calculate  Tanh S
                  + 0.55 e9 + 0.5 e10 + 0.45 e11 + 0.4 e12 + 0.35 e13 + 0.3 e14 + 0.25 e15

-Sedenion so:  16  STO 00

    1     STO 01         0.8    STO 05         0.6    STO 09       0.4    STO 13
  0.95  STO 02        0.75   STO 06        0.55   STO 10      0.35   STO 14
   0.9   STO 03         0.7    STO 07         0.5    STO 11       0.3    STO 15
  0.85  STO 04        0.65   STO 08        0.45   STO 12      0.25   STO 16

    XEQ "TH"   >>>>   0.909559410 - 0.093982576  e1 - 0.089036125 e2 - 0.084089673 e3                  in  R01 thru R16
                                 - 0.079143222 e4 - 0.074196771 e5 - 0.069250319 e6 - 0.064303868 e7
                                 - 0.059357417 e8 - 0.054410965 e9 - 0.049464514 e10 - 0.044518062 e11
                                 - 0.039571611 e12 - 0.034625160 e13 - 0.029678708 e14 - 0.024732257 e15

    ... and so on ...
 

Notes:        The HP-41 must be in DEG mode

-The X-output is usually meaningless
-Lines 196 to 203 give Ln(0) = -9.999999999 E99  ( "almost" minus infinity )
-Thus, Arc Sinh & Arc Cosh work well when  a^2 +/- 1 = 0

-LBL 09 ( lines 239 to 270 ) calculates the product of 2 anions when the imaginary parts are proportional.

-Arc Sin , Arc Cos & Arc Tan use 3n+1 data registers
-Synthetic registers M & N are sometimes used and the alpha "register" is not cleared in this case.