Conical Functions for the HP-41
Overview
0°) Gamma Function
a) Real Arguments: Gam(x)
b) Complex Arguments: 1/Gam(z)
1°) Conical Functions of the First Kind
2°) Conical Functions of the First &
Second Kind
-The programs listed in paragraph 1 & 2 calculate the conical functions
of the 1st and 2nd kind
-They are defined via associated Legendre functions:
Pµ-1/2+i.L (x)
is the conical function of the 1st kind where
Pnm is the associated function of the 1st kind
Qµ-1/2+i.L (x) is the
conical function of the 2nd kind and
Qnm is the associated function of the 2nd kind
( the result is usually a complex number )
-Here, we assume -1 < x < +1
-We need to compute the Gamma function which is involved in the definition
of the Legendre functions
0°) Gamma Function
a) Real Arguments:
Gam(x)
Formula:
Gam(x) = [ x^(x-1/2) ] sqrt(2.Pi) exp
[ -x + ( 1/12 )/( x + ( 1/30 )/( x + ( 53/210)/( x + (195/371)/( x + ...
)))) ]
Data Registers: /
Flags: /
Subroutines: /
01 LBL "GAM"
02 1 03 X<>Y 04 5 05 X<>Y 06 LBL 01 07 ST* Z 08 1 09 + 10 X<Y? 11 GTO 01 12 STO Y |
13 371
14 * 15 195 16 X<>Y 17 / 18 RCL Y 19 + 20 210 21 * 22 53 23 X<>Y 24 / |
25 RCL Y
26 + 27 30 28 * 29 1/X 30 RCL Y 31 + 32 12 33 * 34 1/X 35 RCL Y 36 - |
37 E^X
38 PI 39 ST+ X 40 SQRT 41 R^ 42 X#0? 43 / 44 * 45 X<>Y 46 R^ 47 .5 |
48 ST- Y
49 * 50 Y^X 51 ST* Y 52 * 53 X#0? 54 RTN 55 DEG 56 90 57 TAN 58 END |
( 87 bytes / SIZE 000 )
STACK | INPUT | OUTPUT |
X | x | Gam(x) |
Examples:
PI XEQ "GAM3"
>>>> Gam(PI) = 2.288037794
( in 3.5 seconds )
-7.28 RTN R/S
>>>> Gam(-7.28) = 0.0004577130755
( in 5.6 seconds )
-4 RTN
R/S >>>>
Gam(-4) = infinity = 9.999999999 E99
b) Complex Arguments:
1/Gam(z)
-The same formula is used to calculate 1/Gam(x+i.y)
Data Registers: /
Flags: /
Subroutines: "1/Z" , "Z*Z" ,
"Z/Z"
( cf "Complex Functions for the HP-41" )
01 LBL "1/GAMZ"
02 RAD 03 X<>Y 04 STO O 05 X<>Y 06 0 07 STO N 08 SIGN 09 STO M 10 LBL 01 11 RDN 12 RCL X 13 RCL M 14 * 15 STO P 16 CLX 17 RCL N 18 R^ 19 * 20 ST- P 21 X<> P 22 X<> M 23 LASTX |
24 *
25 X<> N 26 RCL Y 27 * 28 ST+ N 29 CLX 30 SIGN 31 + 32 5 33 X>Y? 34 GTO 01 35 RDN 36 STO Z 37 371 38 ST* Z 39 * 40 XEQ "1/Z" 41 195 42 ST* Z 43 * 44 X<>Y 45 RCL O 46 + |
47 X<>Y
48 R^ 49 + 50 210 51 ST* Z 52 * 53 XEQ "1/Z" 54 53 55 ST* Z 56 * 57 X<>Y 58 RCL O 59 + 60 X<>Y 61 R^ 62 + 63 30 64 ST* Z 65 * 66 XEQ "1/Z" 67 X<>Y 68 RCL O 69 + |
70 X<>Y
71 R^ 72 + 73 12 74 ST* Z 75 * 76 XEQ "1/Z" 77 X<>Y 78 RCL O 79 - 80 X<>Y 81 R^ 82 - 83 E^X 84 P-R 85 PI 86 ST+ X 87 SQRT 88 ST* Z 89 * 90 STO P 91 X<> T 92 X<>Y 93 X<> O |
94 RCL Y
95 PI 96 SIGN 97 ST+ X 98 1/X 99 - 100 RCL Y 101 R^ 102 R-P 103 LN 104 XEQ "Z*Z" 105 E^X 106 P-R 107 RCL O 108 RCL P 109 XEQ "Z*Z" 110 RCL N 111 RCL M 112 R^ 113 R^ 114 XEQ "Z/Z" 115 DEG 116 CLA 117 END |
( 202 bytes / SIZE 000 )
STACK | INPUTS | OUTPUTS |
Y | y | B |
X | x | A |
where 1 / Gam(x+iy) = A + iB
Example:
-1.6 ENTER^
2.4 XEQ "1/GAMZ"
>>>> 0.537740405
---Execution time = 8s---
X<>Y 1.367824860
Whence, 1 / Gam ( 2.4 - 1.6 i
) = 0.537740405 + 1.367824860 i
Note:
-Synthetic register P is used, so don't interrupt "1/GAMZ"
1°) Conical Functions of the First Kind
Formula:
Pµ-1/2+i.L (x) = [ 1/Gam(1-µ) ] (1+x)µ/2 (1-x)µ/2 ] F(-1/2+i.L , -1/2-i.L , 1-µ ; (1-x)/2 )
where F = "the" hypergeometric function
Data Registers: R00 thru R06: temp
Flags: /
Subroutine: "GAM" ( cf paragraph
0°a) )
01 LBL "COF0"
02 STO 01 03 ACOS 04 2 05 STO 06 06 / 07 SIN 08 X^2 09 STO 02 10 RDN 11 STO 03 12 X<>Y 13 STO 04 |
14 CLX
15 STO 00 16 SIGN 17 STO 05 18 LBL 01 19 RCL 05 20 RCL 00 21 ISG X 22 CLX 23 STO 00 24 ST+ X 25 DSE X |
26 RCL 06
27 / 28 X^2 29 RCL 03 30 X^2 31 + 32 * 33 RCL 02 34 * 35 RCL 00 36 ST/ Y 37 RCL 04 38 - |
39 /
40 STO 05 41 + 42 X#Y? 43 GTO 01 44 1 45 RCL X 46 RCL 01 47 ST+ Z 48 - 49 / 50 RCL 04 |
51 RCL 06
52 / 53 Y^X 54 * 55 STO 06 56 1 57 RCL 04 58 - 59 XEQ "GAM" 60 RCL 06 61 X<>Y 62 / 63 END |
( 83 bytes / SIZE 007 )
STACK | INPUTS | OUTPUTS |
Z | µ | / |
Y | L | / |
X | -1 < x < +1 | Pµ-1/2+i.L (x) |
Example: µ = 0.4
L = 0.7 x = 0.2
0.4 ENTER^
0.7 ENTER^
0.2 XEQ "COF0" >>>>
P0.4-1/2+0.7.i (0.2) = 1.276705572
---Execution time = 23s---
Note:
-This program doesn't work if µ = 1 , 2 , 3 , ......
2°) Conical Functions of the First & Second Kind
-The associated Legendre functions are computed by the formulas:
Pnm(x) = 2m pi1/2 (1-x2)-m/2
[ 1/Gam((1-m-n)/2) / Gam((2-m+n)/2) . F(-n/2-m/2 ; 1/2+n/2-m/2 ;
1/2 ; x2 )
- 2x/Gam((1+n-m)/2) / Gam((-n-m)/2) . F((1-m-n)/2 ; (2+n-m)/2 ; 3/2
; x2 ) ]
Qnm(x) = 2m pi1/2 (1-x2)-m/2
[ -Gam((1+m+n)/2)/(2.Gam((2-m+n)/2)) . sin pi(m+n)/2 . F(-n/2-m/2
; 1/2+n/2-m/2 ; 1/2 ; x2 )
+ x.Gam((2+n+m)/2) / Gam((1+n-m)/2) . cos pi(m+n)/2 . F((1-m-n)/2 ; (2+n-m)/2
; 3/2 ; x2 ) ]
Data Registers: R00 thru R13: temp
Flags: F10 is cleared by this program
CF 02 <-> Conical function of the 1s kind
SF 02 <-> Conivcal Function of the 2nd kind
Subroutines: "1/GAMZ" ( cf §0°)b)
) "Z*Z" "1/Z" "Z/Z" ( cf
"Complex Functions for the HP-41" )
01 LBL "COF"
02 STO 01 03 X^2 04 STO 04 05 RDN 06 STO 02 07 X<>Y 08 STO 03 09 2 10 1/X 11 STO 07 12 SIGN 13 STO 09 14 SF 10 15 LBL 00 16 CLX 17 STO 00 18 SIGN 19 STO 05 20 LBL 01 21 RCL 04 22 RCL 05 23 * 24 RCL 00 25 ISG X 26 CLX 27 STO 00 28 ST+ X 29 STO 06 30 RCL 03 |
31 -
32 RCL 07 33 - 34 X^2 35 RCL 02 36 X^2 37 + 38 * 39 RCL 06 40 ST/ Y 41 RCL 09 42 + 43 / 44 STO 05 45 + 46 X#Y? 47 GTO 01 48 FC?C 10 49 RTN 50 RCL 01 51 FC? 02 52 ST+ X 53 * 54 STO 08 55 RCL 02 56 RCL 07 57 ST* Y 58 RCL 03 59 - |
60 RCL 07
61 * 62 XEQ "1/GAMZ" 63 FS? 02 64 GTO 02 65 X^2 66 X<>Y 67 X^2 68 + 69 ST* 08 70 GTO 03 71 LBL 02 72 STO 10 73 X<>Y 74 STO 11 75 RCL 02 76 RCL 07 77 ST* Y 78 3 79 * 80 RCL 03 81 + 82 RCL 07 83 * 84 XEQ "1/GAMZ" 85 RCL 11 86 RCL 10 87 R^ 88 R^ 89 XEQ "Z/Z" |
90 STO 10
91 X<>Y 92 STO 11 93 RCL 02 94 RCL 03 95 RCL 07 96 - 97 PI 98 RCL 07 99 * 100 ST* Z 101 * 102 XEQ "COSZ" 103 RCL 11 104 RCL 10 105 XEQ "Z*Z" 106 RCL 08 107 ST* Z 108 * 109 STO 10 110 X<>Y 111 STO 11 112 LBL 03 113 3 114 ST* 07 115 RCL 09 116 CHS 117 STO 09 118 XEQ 00 |
119 STO 06
120 RCL 02 121 RCL 07 122 RCL 03 123 - 124 2 125 ST/ Z 126 / 127 XEQ "1/GAMZ" 128 FS? 02 129 GTO 04 130 X^2 131 X<>Y 132 X^2 133 + 134 ST* 06 135 RCL 06 136 RCL 08 137 - 138 GTO 05 139 LBL 04 140 STO 12 141 X<>Y 142 STO 13 143 RCL 02 144 2 145 1/X 146 ST* Y 147 RCL 03 148 + |
149 2
150 / 151 XEQ "1/GAMZ" 152 RCL 13 153 RCL 12 154 R^ 155 R^ 156 XEQ "Z/Z" 157 2 158 CHS 159 ST/ Z 160 / 161 STO 12 162 X<>Y 163 STO 13 164 RCL 02 165 RCL 03 166 .5 167 - 168 PI 169 2 170 / 171 ST* Z 172 * 173 XEQ "SINZ" 174 RCL 13 175 RCL 12 176 XEQ "Z*Z" 177 RCL 06 |
178 ST* Z
179 * 180 ST+ 10 181 X<>Y 182 ST+ 11 183 RCL 11 184 RCL 10 185 LBL 05 186 2 187 RCL 03 188 Y^X 189 PI 190 SQRT 191 * 192 ST* Z 193 * 194 1 195 RCL 04 196 - 197 STO 07 198 CLX 199 RCL 03 200 2 201 / 202 RCL 07 203 X<>Y 204 Y^X 205 ST/ Z 206 / 207 END |
( 302 bytes / SIZE 014 )
STACK | INPUTS | CF02OUTPUT | SF02OUTPUT |
Z | µ | / | / |
Y | L | / | B |
X | -1 < x < +1 | Pµ-1/2+i.L (x) | A |
Where Pµ-1/2+i.L (x) is the conical funtion of the first kind and A + i.B = Qµ-1/2+i.L (x) is the conocal function of the second kind
Example: µ = 0.4 L = 0.7 x = 0.2
CF
02
0.4 ENTER^
0.7 ENTER^
0.2 XEQ "COF" >>>>
P0.4-1/2+0.7.i (0.2) = 1.276705582
---Execution time = 31s---
SF
02
0.4 ENTER^
0.7 ENTER^
0.2 XEQ "COF" >>>>
0.145917573
---Execution time = 57s---
X<>Y -1.518537903
-Whence Q0.4-1/2+0.7.i (0.2) = 0.145917573
- 1.518537903 i
Note:
-Unlike "COF0", "COF" also works if µ = 1 , 2 , 3 , ....
-For example, with µ = 3, we get: P3-1/2+0.7.i
(0.2) = 1.343462151
Remark:
-The accuracy will be better if you have M-Code routines to compute
Z*Z 1/Z Z/Z and so on ...
Reference:
[1] Abramowitz and Stegun - "Handbook of Mathematical Functions"
- Dover Publications - ISBN 0-486-61272-4