Anionic Orthogonal Polynomials for the HP-41
Overview
1°) Legendre Polynomials
2°) Generalized Laguerre's Polynomials
3°) Hermite Polynomials
4°) Chebyshev Polynomials
5°) UltraSpherical Polynomials
6°) Jacobi Polynomials
-The following routines complete the programs listed in "Anionic Special
Functions"
-All require a SIZE = 4n+1 , so they can be used with 64-ons, but not
with 128-ons.
-I've used quaternions in the examples ( n = 4 ).
1°) Legendre Polynomials
Formulae: m.Pm(a)
= (2m-1).a.Pm-1(a) - (m-1).Pm-2(a) ,
P0(a) = 1 , P1(a) = a
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "LEGA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Pm(a)
R2n+1 ........ R4n = Pm-1(a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flags: /
Subroutines: "A*A1" ( cf "Anions
for the HP-41" )
"ST*A" ( cf "Anionic Special Functions" )
01 LBL "LEGA"
02 E3 03 / 04 STO M 05 RCL 00 06 .1 07 % 08 STO Z 09 ST+ Z 10 ST+ Z 11 ISG X 12 STO T 13 + 14 ST+ Y 15 E3 16 / |
17 1
18 + 19 REGMOVE 20 CLX 21 RCL 00 22 + 23 CLRGX 24 SIGN 25 STO IND L 26 X<>Y 27 E3 28 / 29 + 30 RCL 00 31 ST+ X 32 + |
33 STO N
34 LBL 01 35 RCL N 36 REGMOVE 37 ISG M 38 X=0? 39 GTO 00 40 XEQ "A*A1" 41 RCL M 42 INT 4 3 ST+ X 44 DSE X 45 XEQ "ST*A" 46 4 47 RCL 00 48 * |
49 STO O
50 LASTX 51 ST- Y 52 LBL 02 53 1 54 RCL M 55 INT 56 - 57 RCL IND O 58 * 59 RCL IND Y 60 + 61 RCL M 62 INT 63 / 64 X<> IND Z |
65 STO IND O
66 RDN 67 DSE O 68 DSE Y 69 DSE X 70 GTO 02 71 GTO 01 72 LBL 00 73 FRC 74 E3 75 * 76 CLA 77 END |
( 133 bytes / SIZE 4n+1 )
STACK | INPUT | OUTPUT |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: m = 7 a = 1 + i/2 + j/3 + k/4 ( Quaternion -> 4 STO 00 )
1 STO 01
2 1/X STO 02
3 1/X STO 03
4 1/X STO 04
7 XEQ "LEGA" >>>> 1.004 ---Execution time = 28s---
R01 = 36.20819586
R02 = -51.58337291
R03 = -34.38891526
R04 = -25.79168644
P7( 1 + i/2 + j/3 + k/4 ) = 36.20819586 - 51.58337291 i - 34.38891526 j - 25.79168644 k
and in registers R13 thru R16:
P6( 1 + i/2 + j/3 +
k/4 ) = -9.248135373 - 26.20689563 i - 17.47126375
j - 13.10344781 k
2°) Generalized Laguerre's Polynomials
Formulae: L0(b)
(a) = 1 , L1(b) (a) = b+1-a
, m Lm(b) (a) = (2.m+b-1-a) Lm-1(b)
(a) - (m+b-1) Lm-2(b) (a)
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "LAGA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Lm(b) (a)
R2n+1 ........ R4n = Lm-1(b) (a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flags: /
Subroutines: "A*A1" ( cf "Anions
for the HP-41" )
01 LBL "LAGA"
02 E3 03 / 04 STO M 05 X<>Y 06 STO N 07 RCL 00 08 .1 09 % 10 STO Z 11 ST+ Z 12 ST+ Z 13 ISG X 14 STO T 15 + 16 ST+ Y 17 E3 |
18 /
19 1 20 + 21 REGMOVE 22 CLX 23 RCL 00 24 + 25 CLRGX 26 SIGN 27 STO IND L 28 X<>Y 29 E3 30 / 31 + 32 RCL 00 33 ST+ X 34 + |
35 STO O
36 LBL 01 37 RCL O 38 REGMOVE 39 ISG M 40 X=0? 41 GTO 00 42 XEQ "A*A1" 43 4 44 RCL 00 45 * 46 STO P 47 LASTX 48 ST- Y 49 LBL 02 50 RCL N 51 PI |
52 SIGN
53 - 54 RCL M 55 INT 56 + 57 ST* IND P 58 LASTX 59 + 60 RCL IND Z 61 * 62 RCL IND Y 63 - 64 RCL IND Z 65 X<> IND P 66 - 67 RCL M 68 INT |
69 /
70 STO IND Z 71 RDN 72 DSE P 73 DSE Y 74 DSE X 75 GTO 02 76 GTO 01 77 LBL 00 78 FRC 79 E3 80 * 81 CLA 82 END |
( 134 bytes / SIZE 4n+1 )
STACK | INPUTS | OUTPUTS |
Y | b | / |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: b = sqrt(2) m = 7 a = 1 + 2 i + 3 j + 4 k ( Quaternion -> 4 STO 00 )
1 STO 01
2 STO 02
3 STO 03
4 STO 04
2 SQRT
7 XEQ "LAGA" >>>>
1.004
---Execution time = 33s---
R01 = 872.2661283
R02 = 47.12527421
R03 = 70.68791129
R04 = 94.25054843
L7sqrt(2) ( 1 + 2 i + 3 j + 4 k ) = 872.2661283 + 47.12527421 i + 70.68791129 j + 94.25054843 k
and in registers R13 thru R16:
L6sqrt(2) (
1 + 2 i + 3 j + 4 k ) = 335.6848017 + 123.7427960
i + 185.6141940 j + 247.4855920 k
3°) Hermite Polynomials
Formulae: H0(a)
= 1 , H1(a) = 2 a
Hm(a) = 2.a Hm-1(a) - 2 (m-1) Hm-2(a)
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "HMTA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Hm(a)
R2n+1 ........ R4n = Hm-1(a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flags: /
Subroutine: "A*A1"
( cf "Anions for the HP-41" )
01 LBL "HMTA"
02 E3 03 / 04 STO M 05 RCL 00 06 .1 07 % 08 STO Z 09 ST+ Z 10 ST+ Z 11 ISG X 12 STO T 13 + 14 ST+ Y |
15 E3
16 / 17 1 18 + 19 REGMOVE 20 CLX 21 RCL 00 22 + 23 CLRGX 24 SIGN 25 STO IND L 26 X<>Y 27 E3 28 / |
29 +
30 RCL 00 31 ST+ X 32 + 33 STO N 34 LBL 01 35 RCL N 36 REGMOVE 37 ISG M 38 X=0? 39 GTO 00 40 XEQ "A*A1" 41 4 42 RCL 00 |
43 *
44 STO O 45 LASTX 46 ST- Y 47 LBL 02 48 1 49 RCL M 50 INT 51 - 52 RCL IND Z 53 X<> IND O 54 * 55 RCL IND Y 56 + |
57 ST+ X
58 STO IND Z 59 RDN 60 DSE O 61 DSE Y 62 DSE X 63 GTO 02 64 GTO 01 65 LBL 00 66 FRC 67 E3 68 * 69 CLA 70 END |
( 118 bytes / SIZE 4n+1 )
STACK | INPUT | OUTPUT |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: m = 7 a = 1 + 2 i + 3 j + 4 k ( Quaternion -> 4 STO 00 )
1 STO 01
2 STO 02
3 STO 03
4 STO 04
7 XEQ "HMTA" >>>> 1.004 ---Execution time = 25s---
R01 = -23716432
R02 = -3653024
R03 = -5479536
R04 = -7306048
H7( 1 + 2 i + 3 j + 4 k ) = -23716432 - 3653024 i - 5479536 j - 7306048 k
and in registers R13 thru R16:
H6( 1 + 2 i + 3 j +
4 k ) = -1122232 + 682816 i + 1024224 j + 1365632 k
4°) Chebyshev Polynomials
Formulae:
CF 02
Tm(a) = 2a.Tm-1(a) - Tm-2(a)
; T0(a) = 1 ; T1(a) = a
( first kind )
SF 02
Um(a) = 2a.Um-1(a) - Um-2(a) ;
U0(a) = 1 ; U1(a) = 2a
( second kind )
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "CHBA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Tm(a) or Um(a)
R2n+1 ........ R4n = Tm-1(a) or Um-1(a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flag: F02
if F02 is clear, "CHBA" calculates the Chebyshev polynomials of the first
kind: Tm(a)
if F02 is set, "CHBA" calculates the Chebyshev polynomials
of the second kind: Um(a)
Subroutines: "A*A1"
( cf "Anions for the HP-41" )
"ST*A" ( cf "Anionic Special Functions" )
01 LBL "CHBA"
02 E3 03 / 04 STO M 05 RCL 00 06 .1 07 % 08 STO Z 09 ST+ Z 10 ST+ Z 11 ISG X 12 STO T 13 + 14 ST+ Y 15 E3 16 / |
17 1
18 + 19 REGMOVE 20 CLX 21 RCL 00 22 + 23 CLRGX 24 SIGN 25 STO IND L 26 X<>Y 27 E3 28 / 29 + 30 RCL 00 31 ST+ X 32 + |
33 STO N
34 LBL 01 35 RCL N 36 REGMOVE 37 ISG M 38 X=0? 39 GTO 00 40 XEQ "A*A1" 41 SIGN 42 RCL M 43 INT 44 X=Y? 45 FS? 02 46 2 47 XEQ "ST*A" 48 4 |
49 RCL 00
50 * 51 STO O 52 LASTX 53 ST- Y 54 LBL 02 55 RCL IND X 56 RCL IND Z 57 X<> IND O 58 - 59 STO IND Z 60 RDN 61 DSE O 62 DSE Y 63 DSE X 64 GTO 02 |
65 GTO 01
66 LBL 00 67 FRC 68 E3 69 * 70 RCL M 71 INT 72 1 73 - 74 X<>Y 75 CLA 76 END |
( 130 bytes / SIZE 4n+1 )
STACK | INPUTS | OUTPUTS |
Y | / | m |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: m = 7 a = 1 + 2 i + 3 j + 4 k ( Quaternion -> 4 STO 00 )
• CF 02 Chebyshev Polynomials 1st kind
1 STO 01
2 STO 02
3 STO 03
4 STO 04
7 XEQ "CHBA" >>>> 1.004 ---Execution time = 21s---
R01 = -9524759
R02 = -1117678
R03 = -1676517
R04 = -2235356
T7( 1 + 2 i + 3 j + 4 k ) = -9524759 - 1117678 i - 1676517 j - 2235356 k
• SF 02 Chebyshev Polynomials 2nd kind
1 STO 01
2 STO 02
3 STO 03
4 STO 04
7 XEQ "CHBA" >>>> 1.004 ---Execution time = 21s---
R01 = -18921448
R02 = -2198096
R03 = -3297144
R04 = -4396192
U7( 1 + 2 i + 3 j + 4 k ) = -18921448 - 2198096 i - 3297144 j - 4396192 k
Note:
m is saved in Y-register because "USPA" below calls "CHBA" as
a subroutine in one case ( to calculate Cm(0) (a)
).
5°) UltraSpherical Polynomials
Formulae: C0(b) (a) = 1 ; C1(b) (q) = 2.b.a ; (m+1).Cm+1(b) (a) = 2.(m+b).x.Cm(b) (a) - (m+2b-1).Cm-1(b) (a) if b # 0
Cm(0) (a) = (2/m).Tm(a)
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "USPA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Cm(b) (a)
R2n+1 ........ R4n = Cm-1(b) (a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flags: /
Subroutines: "A*A1" ( cf "Anions
for the HP-41" )
"ST*A" ( cf "Anionic Special Functions" ) &
"CHBA" above if b = 0
01 LBL "USPA"
02 X<>Y 03 X#0? 04 GTO 00 05 X<>Y 06 CF 02 07 XEQ "CHBA" 08 2 09 RCL Z 10 / 11 XEQ "ST*A" 12 X<>Y 13 RTN 14 LBL 00 15 STO N 16 X<>Y 17 E3 18 / 19 STO M 20 RCL 00 |
21 .1
22 % 23 STO Z 24 ST+ Z 25 ST+ Z 26 ISG X 27 STO T 28 + 29 ST+ Y 30 E3 31 / 32 1 33 + 34 REGMOVE 35 CLX 36 RCL 00 37 + 38 CLRGX 39 SIGN 40 STO IND L |
41 X<>Y
42 E3 43 / 44 + 45 RCL 00 46 ST+ X 47 + 48 STO O 49 LBL 01 50 RCL O 51 REGMOVE 52 ISG M 53 X=0? 54 GTO 00 55 XEQ "A*A1" 56 RCL M 57 INT 58 1 59 - 60 RCL N |
61 +
62 ST+ X 63 XEQ "ST*A" 64 4 65 RCL 00 66 * 67 STO P 68 LASTX 69 ST- Y 70 LBL 02 71 PI 72 SIGN 73 RCL N 74 - 75 ST+ X 76 RCL M 77 INT 78 - 79 RCL IND Z 80 X<> IND P |
81 *
82 RCL IND Y 83 + 84 RCL M 85 INT 86 / 87 STO IND Z 88 RDN 89 DSE P 90 DSE Y 91 DSE X 92 GTO 02 93 GTO 01 94 LBL 00 95 FRC 96 E3 97 * 98 CLA 99 END |
( 172 bytes / ZIZE 4n+1 )
STACK | INPUTS | OUTPUTS |
Y | b | / |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: b = sqrt(2) m = 7 a = 1 + i/2 + j/3 + k/4 ( Quaternion -> 4 STO 00 )
1 STO 01
2 STO 02
3 STO 03
4 STO 04
2 SQRT
7 XEQ "USPA" >>>>
1.004
---Execution time = 32s---
R01 = 324.5443969
R02 = -689.5883616
R03 = -459.7255740
R04 = -344.7941807
C7sqrt(2) ( 1 + i/2 + j/3 + k/4 ) = 324.5443969 - 689.5883616 i - 459.7255740 j - 344.7941807 k
-Likewise, C7(0)
( 1 + i/2 + j/3 +
k/4 ) = 29.24554797 - 33.27910360 i - 22.18606908
j - 16.63955181 k ( in 22 seconds )
6°) Jacobi Polynomials
Formulae: P0(b;c) (a) = 1 ; P1(b;c) (a) = (b-c)/2 + a (b+c+2)/2
2m(m+b+c)(2m+b+c-2) Pm(b;c)
(a) = [ (2m+b+c-1).(b2-c2) + a (2m+b+c-2)(2m+b+c-1)(2m+b+c)
] Pm-1(b;c) (a)
- 2(m+b-1)(m+c-1)(2m+b+c) Pm-2(b;c) (a)
Data Registers: • R00 = n > 1 ( Registers R00 thru Rnn are to be initialized before executing "JCPA" )
• R01 ...... • Rnn = the n components of the anion a which are saved in registers Rn+1 to R2n
Rn+1 .......... R3n = Pm(b;c) (a)
R2n+1 ........ R4n = Pm-1(b;c) (a)
>>> When the program stops: R01 ...... Rnn = the n components of the result
Flags: /
Subroutines: "A*A1" ( cf "Anions
for the HP-41" )
-> For "A*A1" , use a version that does not alter synthetic register
P
"ST*A" ( cf "Anionic Special Functions" )
-Lines 43 and 158 are 3-byte GTO's
01 LBL "JCPA"
02 E3 03 / 04 STO M 05 RDN 06 STO N 07 X<>Y 08 STO O 09 RCL 00 10 .1 11 % 12 STO Z 13 ST+ Z 14 ST+ Z 15 ISG X 16 STO T 17 + 18 ST+ Y 19 E3 20 / 21 1 22 + 23 REGMOVE 24 CLX 25 RCL 00 26 + 27 CLRGX 28 SIGN |
29 STO IND L
30 X<>Y 31 E3 32 / 33 + 34 RCL 00 35 ST+ X 36 + 37 STO P 38 LBL 01 39 RCL P 40 REGMOVE 41 ISG M 42 X=0? 43 GTO 00 44 XEQ "A*A1" 45 RCL M 46 INT 47 ST+ X 48 RCL N 49 + 50 RCL O 51 + 52 ENTER^ 53 ENTER^ 54 ENTER^ 55 CLX 56 SIGN |
57 ST- T
58 ST+ X 59 - 60 * 61 * 62 XEQ "ST*A" 63 RCL O 64 RCL M 65 INT 66 + 67 RCL X 68 PI 69 SIGN 70 - 71 RCL M 72 INT 73 RCL N 74 + 75 ST+ Z 76 PI 77 SIGN 78 - 79 * 80 * 81 ST+ X 82 RCL 00 83 RCL 00 84 PI |
85 INT
86 * 87 ST+ Y 88 LASTX 89 10^X 90 / 91 + 92 X<>Y 93 LBL 02 94 ST* IND Y 95 DSE Y 96 GTO 02 97 RCL M 98 INT 99 ST+ X 100 DSE X 101 RCL N 102 RCL O 103 + 104 ST+ Y 105 LASTX 106 RCL N 107 - 108 * 109 * 110 SIGN 111 RCL 00 112 ENTER^ |
113 ST+ Y
114 ST+ Y 115 LBL 03 116 RCL IND Y 117 LASTX 118 * 119 ST+ IND Y 120 RDN 121 DSE Y 122 DSE X 123 GTO 03 124 RCL M 125 INT 126 ENTER^ 127 DSE X 128 ST+ X 129 RCL O 130 RCL N 131 + 132 ST+ Z 133 + 134 * 135 * 136 ST+ X 137 RCL 00 138 ST+ X 139 ST+ X 140 STO Q |
141 RCL 00
142 ST- Y 143 RCL Z 144 SIGN 145 LBL 04 146 CLX 147 RCL IND Y 148 RCL IND Q 149 ST- Y 150 X<> L 151 / 152 X<> IND Z 153 STO IND Q 154 DSE Q 155 DSE Z 156 DSE Y 157 GTO 04 158 GTO 01 159 LBL 00 160 FRC 161 E3 162 * 163 CLA 164 END |
( 262 bytes / SIZE 4n+1 )
STACK | INPUTS | OUTPUTS |
Z | b | / |
Y | c | / |
X | m | 1.nnn |
where 1.nnn is the control number of the result and m is an integer ( 0 <= m < 1000 )
Example: b = sqrt(2) c = sqrt(3) m = 7 a = 1 + i/2 + j/3 + k/4 ( Quaternion -> 4 STO 00 )
1 STO 01
2 1/X STO 02
3 1/X STO 03
4 1/X STO 04
2 SQRT
3 SQRT
7 XEQ "JCPA" >>>>
1.004
---Execution time = 52s---
R01 = 143.5304513
R02 = -310.8681605
R03 = -207.2454399
R04 = -155.4340802
-Whence, P7sqrt(2);sqrt(3) ( 1 + i/2 + j/3 + k/4 ) = 143.5304513 - 310.8681605 i - 207.2454399 j - 155.4340802 k
Notes:
-This version is probably not the shortest and fastest one !
-Since registers P & Q are used, don't interrupt this program.