# hp41programs

AnionEllipticInteg

# Anionic Legendre Elliptic Integrals for the HP-41

Overview

"KEA" calculates the complete elliptic integrals K(a) & E(a) where a is an anion ( complex, quaternion, octonion, sedenion, .... )
with the method of arithmetic-geometric mean. ( cf "Elliptic Integrals for the HP41" )

Several M-Code routines are used ( cf "Anions" & "Anionic Functions" for the HP41 )

Though I'm not sure it's really useful for quaternions, octonions, and so on, the complex case is important.

Program Listing

Data Registers:           •  R00 = n                ( Registers R00 thru Rnn are to be initialized before executing "KEA" )

•  R01 .................. •  Rnn = a               and when the program stops:

R01 ....................   Rnn = K(a)          Rn+1 ..................  R2n = E(a)       ( R2n+1 to R4n: temp )

Flags: /
Subroutines:  AMOVE  ASWAP  ST*A  ST/ A  A+A  A-A  A^X  DSA  A*A1  1/A

 01  LBL "KEA"  02  13  03  AMOVE  04  SIGN  05  CHS  06  ST*A  07  ST- 01  08  .5  09  XEQ "A^X"  10  12  11  AMOVE  12  CLX  13  ST*A  14  SIGN 15  STO 01  16  STO M  17  LBL 01  18  14  19  AMOVE  20  A-A  21  2  22  ST/A  23  XEQ "A^X"  24  2  25  RCL M  26  Y^X  27  ST*A  28  DSA 29  STO N  30  41  31  AMOVE  32  A+A  33  2  34  ST/A  35  14  36  ASWAP  37  A*A1  38  .5  39  XEQ "A^X"  40  12  41  AMOVE  42  41 43  AMOVE  44  SIGN  45  ST+ M  46  RCL N  47  X#0?  48  GTO 01  49  XEQ "1/A"   50  PI  51  2  52  /  53  ST*A  54  12  55  AMOVE  56  31 57  AMOVE  58  2  59  CHS  60  ST/A  61  SIGN  62  ST- 01  63  A*A1  64  12  65  ASWAP      66  X<>Y  67  CLA  68  END

( 80 bytes / SIZE 4n+1 )

 STACK INPUT OUTPUT X / 1.nnn

Example:   With n = 4 ( quaternion ) and a = q = 2 + 3 i + 4 j + 5 k

4  STO 00

2  STO 01
3  STO 02
4  STO 03
5  STO 04    XEQ "KEA"   >>>>   1.004                       ---Execution time = 55s---

And we find

K( 2 + 3 i + 4 j + 5 k ) = 0.812905129 + 0.202673663 i + 0.270231550 j + 0.337789437 k    in   R01-R02-R03-R04
E( 2 + 3 i + 4 j + 5 k ) = 2.095504925  - 0.782893388 i  - 1.043857851 j  - 1.304822313 k    in   R05-R06-R07-R08

-Likewise, with n = 2 , you will find

K( 3 + 2 i ) = 1.017043564 + 0.806253179 i
E( 3 + 2 i ) =  1.082406601 - 1.280730221 i

Notes:

-If | a | < 1 , you can also use the formulae:

K(a) = (PI/2)  2F1 ( 1/2 , 1/2 ; 1 ; a )
E(a) = (PI/2)  2F1 ( -1/2 , 1/2 ; 1 ; a )

-But the results are often both slower and less accurate...