QuatSphFunc

# Quaternionic Spheroidal Wave Functions for the HP-41

Overview

-The following program generalizes a routine that is listed in "Spheroidal Harmonics for the HP-41" to quaternionic variables.
-However, the parameters  m , n , c2 , Lmn remain real.

•   m & n must be non-negative integers, n = m , m+1 , m+2 , ... ,  c2 may be positive or negative or equal to zero,
and the eigenvalues Lmn must be calculated first  ( see for example the 1st routine listed in "Spheroidal Harmonics for the HP-41" )
•   If c = 0 , the eigenvalues are simply  n(n+1)

Program Listing

-We assume that  | q | <= 1  and  Smn(q) is computed by      Smn(q) = ( 1 - q2 )m/2   Sumk=0,1,.... ak qk

with     (k+1)(k+2) ak+2 - [ k ( k + 2m + 1 ) - Lmn + m ( m + 1 ) ] ak  - c2  ak-2 = 0

Data Registers:            R00 thru R08 & R13 thru R18: temp                ( Registers R09 thru R12 are to be initialized before executing "SWFQ" )

•  R09 = m      •  R11 = c2
•  R10 = n       •  R12 = Lmn
Flag:  F00

CF 00        Flammer's Scheme      Smn(0) = Pmn(0)  &  S'mn(0) = P' mn(0)   where  Pmn(x)  =  Associated Legendre Functions of the first kind

a0 = [ (-1)(n+m)/2 (n+m)! ] / [ 2n ((n-m)/2)! ((n+m)/2)! ]                   a1 = 0                if  n - m is even
a1 = [ (-1)(n+m-1)/2 (n+m+1)! ] / [ 2n ((n-m-1)/2)! ((n+m+1)/2)! ]    a0 = 0                 if  n - m is odd

SF 00         Non-Normalized Functions

a0 = 1          a1 = 0         if  n - m is even
a0 = 0          a1 = 1         if  n - m is odd

Subroutines:  "Q*Q"  "Q^R"  ( cf "Quaternions for the HP-41" )

 01  LBL "SWFQ"   02  STO 01            03  STO 05   04  RDN   05  STO 02   06  STO 06   07  RDN   08  STO 03   09  STO 07   10  X<>Y   11  STO 04   12  STO 08   13  XEQ "Q*Q"   14  STO 01   15  RDN   16  STO 02   17  RDN   18  STO 03   19  X<>Y   20  STO 04   21  RCL 10   22  RCL 09   23  -   24  STO 13   25  2   26  MOD   27  STO 00   28  X#0?   29  GTO 00   30  STO 06   31  STO 07   32  STO 08 33  SIGN   34  STO 05            35  LBL 00   36  CLX   37  STO 17   38  SIGN   39  FS? 00   40  GTO 00   41  CHS   42  RCL 09   43  RCL 10   44  +   45  STO 14   46  RCL 00   47  ST- 13   48  ST+ 14   49  -   50  2   51  /   52  Y^X   53  RCL 14   54  FACT   55  *   56  2   57  ST/ 13   58  ST/ 14   59  RCL 10   60  Y^X   61  /   62  RCL 13   63  FACT   64  RCL 14 65  FACT   66  *   67  /   68  LBL 00            69  STO 18    70  RCL 05   71  X<>Y   72  *   73  STO 13   74  RCL 06   75  LASTX   76  *   77  STO 14   78  RCL 07   79  LASTX   80  *   81  STO 15   82  RCL 08   83  LASTX   84  *   85  STO 16   86  LBL 01   87  RCL 11   88  RCL 17   89  *   90  RCL 09   91  ST+ X   92  RCL 00   93  ST+ Y   94  ST* Y   95  +   96  RCL 09 97  ST+ Y   98  X^2   99  + 100  RCL 12          101  - 102  RCL 18 103  STO 17 104  * 105  + 106  RCL 00 107  1 108  + 109  ST/ Y 110  LASTX 111  + 112  STO 00 113  / 114  STO 18 115  XEQ "Q*Q" 116  STO 05 117  RDN 118  STO 06 119  RCL 18 120  * 121  RCL 14 122  + 123  STO 14 124  LASTX 125  - 126  ABS 127  X<>Y 128  STO 07 129  RCL 18 130  * 131  RCL 15          132  + 133  STO 15  134  LASTX 135  - 136  ABS 137  + 138  X<>Y 139  STO 08 140  RCL 18 141  * 142  RCL 16 143  + 144  STO 16 145  LASTX 146  - 147  ABS 148  + 149  RCL 05 150  RCL 18 151  * 152  RCL 13 153  + 154  STO 13 155  LASTX 156  - 157  ABS 158  + 159  X#0? 160  GTO 01 161  RCL 09 162  2 163  / 164  STO 00          165  1 166  RCL 01 167  - 168  RCL 04 169  CHS 170  RCL 03 171  CHS 172  RCL 02 173  CHS 174  R^ 175  XEQ "Q^R" 176  STO 01 177  RDN 178  STO 02 179  RDN 180  STO 03 181  X<>Y 182  STO 04 183  RCL 13 184  STO 05 185  RCL 14 186  STO 06 187  RCL 15 188  STO 07 189  RCL 16 190  STO 08 191  XEQ "Q*Q" 192  END

( 244 bytes / SIZE 019 )

 STACK INPUTS OUTPUTS T t t' Z z z' Y y y' X x x'

with   Smn( x + y i + z j + t k ) = x' + y' i + z' j + t' k  ,   |  x + y i + z j + t k | <= 1

Example1:     m = 0 ,  n = 1 ,  c2 = 2 ,   Lmn = 3.172127920       These 4 numbers are to be stored in  R09 thru R12

CF 00

0.4   ENTER^
0.3   ENTER^
0.2   ENTER^
0.1   XEQ "SWFQ"  >>>>    0.117347028                   ---Execution time = 34s---
RDN     0.210312365
RDN     0.315468547
RDN     0.420624729

S( 0.1 + 0.2 i + 0.3 j + 0.4 k ) = 0.117347028 + 0.210312365 i + 0.315468547 j + 0.420624729 k

Example2:     m = n = 2  ,  c2 = 3  ,  Lmn =  6.412006610           These 4 numbers are to be stored in  R09 thru R12

CF 00

0.4   ENTER^
0.3   ENTER^
0.2   ENTER^
0.1   XEQ "SWFQ"  >>>>    4.058321831                   ---Execution time = 39s---
RDN   -0.160164520
RDN   -0.240246780
RDN   -0.320329040

S( 0.1 + 0.2 i + 0.3 j + 0.4 k ) = 4.058321831 - 0.160164520 i - 0.240246780 j - 0.320329040 k

Notes:

-If you set F00 you get the same result in the 1st example, and the same result divided by 3 in the 2nd example.
-If it is possible, use an M-Code routine that returns 0^0 = 1 to compute "Q^R"
-If m > 0   Smn(1) = Smn(-1) = 0  so you could add

RCL 09  X=0?  GTO 00  RCL 04   ABS  RCL 03  ABS  +  RCL 02  ABS +  X#0?  GTO 00  RCL 01  ABS  1  X#Y?  GTO 00  CLST  RTN  LBL 00

after line 12

-"SWFQ" may also be used to compute Legendre Functions provided | q |  does not exceed 1:
-Store 0 in R11 and  n(n+1) in R12

Reference:

[1]   Abramowitz & Stegun , "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4