Associated Legendre Functions for the HP-41
Overview
1°) Pnm(x)
with 0 <= m <= n (integer order & degree)
2°) Pnm(x) & Qnm(x)
with 0 <= m <= n (integer order & degree)
3°) Associated Legendre Functions Pnm(x)
& Qnm(x) (fractional order & degree)
| x | < 1
4°) Associated Legendre Functions of the
first kind ( fractional order & degree ) with | x | <
1
5°) Associated Legendre Functions of the
first kind ( fractional order & degree ) with -1 < x
< 3
6°) Associated Legendre Functions of the
first kind ( fractional order & degree ) with x >
1
7°) Associated Legendre Functions of the
second kind ( fractional order & degree ) with | x | < 1
8°) Associated Legendre Functions of the
second kind ( fractional order & degree ) with -1 < x
< 3
9°) Associated Legendre Functions of the
second kind ( fractional order & degree ) with | x | > 1
1°) Pnm(x) with
0 <= m <= n (integer order & degree)
Formulae: (n-m) Pnm(x) = x (2n-1) Pn-1m(x) - (n+m-1) Pn-2m(x)
Pmm(x) = (-1)m (2m-1)!! ( 1-x2
)m/2 if | x | < 1
where (2m-1)!! = (2m-1)(2m-3)(2m-5).......5.3.1
Pmm(x) = (2m-1)!! ( x2-1
)m/2 if | x | > 1
-If m = 0 , we have Legendre polynomials ( see also "Orthogonal Polynomials for the HP-41" )
Data Registers: /
Flags: /
Subroutines: /
-Synthetic registers M N O may be replaced by any data registers.
-Line 43 = TEXT0 or another NOP like STO X .....
01 LBL "PMN"
02 STO O 03 CLX 04 E3 05 / 06 STO N 07 X<>Y 08 STO M 09 ST+ N 10 ST+ X 11 1 12 ST- Y 13 X<>Y 14 LBL 00 15 2 16 - |
17 X>0?
18 ST* Y 19 X>0? 20 GTO 00 21 SIGN 22 RCL M 23 Y^X 24 * 25 1 26 RCL O 27 X^2 28 - 29 X>0? 30 GTO 01 31 X<>Y 32 ABS |
33 X<>Y
34 ABS 35 LBL 01 36 RCL M 37 2 38 / 39 X=Y? 40 X#0? 41 X<0? 42 ISG Y 43 "" 44 Y^X 45 * 46 CHS 47 0 48 LBL 02 |
49 RCL M
50 RCL N 51 INT 52 + 53 1 54 - 55 ABS 56 CHS 57 R^ 58 * 59 RCL N 60 INT 61 ST+ X 62 1 63 - 64 RCL O |
65 *
66 R^ 67 * 68 + 69 RCL N 70 INT 71 RCL M 72 - 73 X=0? 74 SIGN 75 / 76 ISG N 77 GTO 02 78 CLA 79 END |
( 110 bytes / SIZE 000 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | Pnm-1(x) |
X | x | Pnm(x) |
Examples:
4 ENTER^
7 ENTER^
3 XEQ "PMN" >>>> P74(3)
= 37920960 X<>Y P64(3)
= 2963520 ( execution time = 6 seconds )
3 ENTER^
100 ENTER^
0.7 XEQ "PMN" >>>> P1003(0.7)
= -58239.28386 X<>Y P993(0.7)
= 13003.91702 ( in 1mn31s )
2°) Pnm(x) & Qnm(x)
with
0 <= m <= n (integer order & degree)
Formulae:
Pnm(x) = ( x2-1
)m/2 dmPn(x)/dxm if
| x | > 1 Pnm(x)
= (-1)m ( 1- x2 )m/2 dmPn(x)/dxm
if | x | < 1
Qnm(x) = ( x2-1
)m/2 dmQn(x)/dxm if
| x | > 1 Qnm(x)
= (-1)m ( 1- x2 )m/2 dmQn(x)/dxm
if | x | < 1
-if m = 0 Pnm(x) = Pn(x)
= Legendre polynomials ( cf "Orthogonal Polynomials for the HP-41"
)
and Qnm(x)
= Qn(x) with Q0(x) = 0.5 Ln |
(1+x)/(1-x) | ; Q1(x) = x/2 Ln | (1+x)/(1-x) | -
1 and n.Qn(x) = (2n-1).x.Qn-1(x)
- (n-1).Qn-2(x)
-We have employed the recurrence relations: Pnm+1(x) = | x2-1 |-1/2 [ (n-m).x. Pnm(x) - (n+m). Pn-1m(x) ] ( the same relation holds for Qnm(x) )
Important note:
-If | x | is significantly greater than 1 , Qnm(x)
is obtained ( very ) inaccurately and "ALF2C" is preferable ( see
9°) below )
( the recurrende relation is unstable in this case )
Data Registers: R00
to Rnn: temp
Flags: F02 if flag
F02 is clear "PQMN" calculates Pnm(x)
F05 if flag F02 is set , "PQMN" calculates
Qnm(x)
Subroutines: /
-This program uses 4 synthetic registers M N O P
-Don't interrupt "PQMN": the content of register P could be altered
-These 4 registers may of course be replaced by any unused data registers
( Rpp with p > n )
-Line 83 = line 100 = TEXT0 or another NOP instruction like STO
X , LBL 00 , ....
01 LBL "PQMN"
02 X<> Z 03 STO O 04 RDN 05 CF 05 06 X=0? 07 SF 05 08 E3 09 / 10 1 11 + 12 STO M 13 X<>Y 14 STO Y 15 LASTX 16 STO 00 17 FC? 02 18 GTO 01 19 ST+ Y 20 RCL Z 21 - 22 / 23 ABS 24 SQRT 25 LN |
26 STO 00
27 LBL 01 28 STO N 29 RCL Z 30 * 31 STO P 32 - 33 RCL M 34 INT 35 1/X 36 ENTER^ 37 SIGN 38 - 39 FS? 02 40 X#0? 41 GTO 02 42 SIGN 43 STO Y 44 CHS 45 LBL 02 46 * 47 RCL P 48 + 49 RCL N 50 X<>Y |
51 STO IND M
52 ISG M 53 GTO 01 54 RCL Z 55 1 56 ST- M 57 X<> O 58 X=0? 59 GTO 04 60 1 61 - 62 E3 63 / 64 STO O 65 X<> M 66 INT 67 STO N 68 STO P 69 X<>Y 70 LBL 03 71 RCL IND N 72 RCL Y 73 * 74 RCL N 75 RCL M |
76 INT
77 - 78 ST* Y 79 LASTX 80 ST+ X 81 + 82 DSE N 83 "" 84 RCL IND N 85 * 86 - 87 X<>Y 88 X^2 89 ENTER^ 90 SIGN 91 ST+ N 92 - 93 ABS 94 SQRT 95 X=0? 96 SIGN 97 / 98 STO IND N 99 DSE N 100 "" |
101 X<>Y
102 ISG O 103 GTO 03 104 RCL P 105 STO N 106 SIGN 107 RCL O 108 FRC 109 + 110 RCL M 111 INT 112 + 113 STO O 114 X<>Y 115 ISG M 116 GTO 03 117 X<>Y 118 LBL 04 119 RDN 120 SIGN 121 RDN 122 FS?C 05 123 RCL 00 124 CLA 125 END |
( 187 bytes / SIZE nnn+1 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | / |
X | x | F(x) |
L | / | x |
with F(x) = Pnm(x) if flag F02 is clear and F(x) = Qnm(x) if flag F02 is set.
Example: Calculate P74(0.6) & Q74(0.6)
CF 02
4 ENTER^
7 ENTER^
0.6 XEQ "PQMN" yields
P74(0.6) = 715.3090560
( in 17 seconds )
SF 02
4 ENTER^
7 ENTER^
0.6 R/S
gives Q74(0.6) = -1011.171802
( in 17 seconds )
-Similarly: P74(1.2) = 6327.212011 & Q74(1.2) = 82.12107441
-For x = 1.2 Q74(x) is
still acceptable ( "ALF2B" produces 82.12107808 )
but for x = 3 , the errors are too great and "ALF2B" is much
better ( cf 7°) below )
3°) Associated Legendre Functions Pnm(x)
& Qnm(x) (fractional
order & degree) | x | < 1
-Actually, these functions are solutions of the differential equation:
( 1- x2 ) d2y/dx2 - 2.x.dy/dx + [ n(n+1)
- m2/( 1- x2 ) ] y = 0
-Thus, we can seek these solutions by substituting the series
y = a0 + a1.x + a2.x2 + ......
+ ak.xk + ...... in this differential equation.
-This approach leads to the recurrence relation: (k+1)(k+2) ak+2
= [ m2+2k2-n(n+1) ] ak + [ (k-2)(1-k)
+ n(n+1) ] ak-2 (
a-1= a-2 = 0 )
a0 = 2m/pi1/2
cos pi(n+m)/2 . Gam((n+m+1)/2) / Gam((n-m+2)/2)
a1 = 2m+1/pi1/2
sin pi(n+m)/2 . Gam((n+m+2)/2) / Gam((n-m+1)/2) for
Pnm(x)
a0 = -2m-1pi1/2
sin pi(n+m)/2 Gam((n+m+1)/2) / Gam((n-m+2)/2)
a1 = 2m
pi1/2 cos pi(n+m)/2 Gam((n+m+2)/2) / Gam((n-m+1)/2)
for Qnm(x)
Data Registers: R00
to R09: temp ( when the program stops, R00 = x & R01 = Pnm(x)
or Qnm(x) )
Flags: F02
if flag F02 is clear "ALF" calculates Pnm(x)
if flag F02 is set "ALF" calculates Qnm(x)
Subroutine: "1/G" ( Reciprocal of
the Gamma Function ) or "1/G+" for a better accuracy.
01 LBL "ALF"
02 STO 00 03 RDN 04 STO 03 05 X<>Y 06 STO 02 07 - 08 2 09 ST+ Y 10 / 11 STO 05 12 XEQ "1/G" 13 STO 06 14 RCL 02 15 RCL 03 16 + 17 STO 08 18 1 19 + 20 2 21 / 22 STO 04 23 XEQ "1/G" 24 ST/ 06 25 RCL 05 26 .5 |
27 ST+ 04
28 - 29 XEQ "1/G" 30 STO 07 31 RCL 04 32 XEQ "1/G" 33 ST/ 07 34 RCL 08 35 1 36 ASIN 37 * 38 1 39 P-R 40 FS? 02 41 X<>Y 42 FS? 02 43 CHS 44 ST* 06 45 X<>Y 46 ST* 07 47 2 48 RCL 02 49 ST* 02 50 Y^X 51 FC? 02 52 ST+ X |
53 PI
54 SQRT 55 FC? 02 56 1/X 57 * 58 ST* 07 59 2 60 / 61 ST* 06 62 RCL 00 63 RCL 07 64 * 65 STO 07 66 RCL 06 67 + 68 STO 01 69 CLX 70 STO 04 71 STO 05 72 STO 08 73 RCL 03 74 1 75 + 76 ST* 03 77 LBL 01 78 3 |
79 STO 09
80 LBL 02 81 RCL 08 82 2 83 - 84 1 85 RCL 08 86 - 87 * 88 RCL 03 89 + 90 RCL 04 91 * 92 RCL 00 93 X^2 94 * 95 RCL 02 96 RCL 08 97 X^2 98 ST+ X 99 + 100 RCL 03 101 - 102 RCL 06 103 * 104 + |
105 RCL 00
106 X^2 107 * 108 RCL 08 109 1 110 + 111 STO 08 112 RCL 08 113 LAST X 114 + 115 * 116 / 117 X<> 07 118 X<> 06 119 X<> 05 120 STO 04 121 RCL 07 122 RCL 01 123 + 124 STO 01 125 LASTX 126 X#Y? 127 GTO 01 128 DSE 09 129 GTO 02 130 END |
( 177 bytes / SIZE 010 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | F(x) |
X | x | F(x) |
with F(x) = Pnm(x) if flag F02 is clear and F(x) = Qnm(x) if flag F02 is set.
Examples:
CF 02
0.4 ENTER^
1.3 ENTER^
0.7 XEQ "ALF" >>>>
P1.30.4(0.7) = 0.274932821
( in 1mn59s )
SF 02
0.4 ENTER^
1.3 ENTER^
0.7 R/S
>>>> Q1.30.4(0.7)
= -1.317935684 ( in 1mn45s )
SF 02
3 ENTER^
1 ENTER^
0.2 R/S
>>>> Q13(0.2) = -1.701034548
( in 51s )
4°) Associated Legendre Functions of the first kind
( fractional order & degree ) with | x | < 1
Formula: Pnm(x)
= 2m pi1/2 (x2-1)-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 ) ]
Data Registers:
R00 to R07: temp
Flags: /
Subroutines: "GAM" or "GAM+" ( Gamma
function ) , "HGF" ( Hypergeometric functions )
01 LBL "ALF1"
02 STO 04 03 RDN 04 STO 01 05 STO 06 06 X<>Y 07 ST+ 01 08 STO 05 09 - 10 1 11 + 12 .5 |
13 STO 03
14 * 15 STO 02 16 LASTX 17 CHS 18 ST* 01 19 RCL 04 20 X^2 21 XEQ "HGF" 22 STO 07 23 RCL 01 24 XEQ "GAM+" |
25 ST/ 04
26 RCL 02 27 XEQ "GAM+" 28 ST/ 04 29 RCL 03 30 ST+ 01 31 ST+ 02 32 ISG 03 33 RCL 00 34 XEQ "HGF" 35 ST* 04 36 RCL 01 |
37 XEQ "GAM+"
38 ST/ 07 39 RCL 02 40 XEQ "GAM+" 41 ST/ 07 42 RCL 07 43 RCL 04 44 ST+ X 45 - 46 4 47 ENTER^ 48 SIGN |
49 RCL 00
50 - 51 / 52 RCL 05 53 Y^X 54 PI 55 * 56 SQRT 57 * 58 END |
( 107 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | / |
X | x | Pnm(x) |
Example:
0.4 ENTER^
1.3 ENTER^
0.7 XEQ "ALF1" >>>>
P1.30.4(0.7) = 0.274932822
( in 58s )
5°) Associated Legendre Functions of the first kind
( fractional order & degree ) with -1 < x < 3
Formula: Pnm(x)
= |(x+1)/(x-1)|m/2 F(-n ; n+1 ; 1-m ; (1-x)/2 ) / Gamma(1-m)
( x # 1 )
Data Registers:
R00 to R06: temp
Flags: /
Subroutines: "GAM" ( Gamma function
) , "HGF" ( Hypergeometric functions )
01 LBL "ALF1B"
02 STO 04 03 RDN 04 STO 02 05 CHS 06 STO 01 07 1 08 ENTER^ |
09 ST+ 02
10 R^ 11 STO 05 12 - 13 STO 03 14 CLX 15 RCL 04 16 - |
17 2
18 ST/ 05 19 / 20 XEQ "HGF" 21 X<> 03 22 XEQ "GAM" 23 ST/ 03 24 RCL 03 |
25 RCL 04
26 1 27 + 28 RCL 04 29 LASTX 30 - 31 / 32 ABS |
33 RCL 05
34 Y^X 35 * 36 END |
( 58 bytes / SIZE 006 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | / |
X | x | Pnm(x) |
Example: Calculate P1.30.4(1.9)
0.4 ENTER^
1.3 ENTER^
1.9 XEQ "ALF1B" gives
2.980130385 ( in 26 seconds )
-This program will not work if m = 1,2,3,4, ..... unless you replace line 20 by XEQ "HGF2" and line 22 by FC? 00 XEQ "GAM" FC?C 00
-With this modification, you'll find, for example: P73(1.7)
= 102985.1588 ( in 9 seconds )
6°) Associated Legendre Functions of the first kind
( fractional order & degree ) with x > 1
Formula: Pnm(x)
= 2-n-1pi-1/2Gam(-1/2-n) x-n+m-1/ ((x2-1)m/2Gam(-n-m))
F(1/2+n/2-m/2;1+n/2-m/2;n+3/2;1/x2)
+2npi-1/2Gam(1/2+n) xn+m/ ((x2-1)m/2Gam(1+n-m))
F(-n/2-m/2;1/2-n/2-m/2;1/2-n;1/x2)
( The factor pi-1/2 in the second term is omitted by mistake
in the "Handbook of Mathematical Functions" page 332 )
Data Registers:
R00 to R08: temp
Flags: /
Subroutines: "GAM" ( Gamma function
) , "HGF" ( Hypergeometric functions )
01 LBL "ALF1C"
02 STO 04 03 RDN 04 STO 05 05 X<>Y 06 STO 06 07 - 08 .5 09 ST* Y 10 + 11 STO 01 12 LASTX 13 + 14 STO 02 15 1.5 16 RCL 05 17 + 18 STO 03 19 RCL 04 |
20 X^2
21 1/X 22 XEQ "HGF" 23 STO 07 24 1 25 RCL 03 26 - 27 XEQ "GAM" 28 ST* 07 29 RCL 05 30 RCL 06 31 + 32 CHS 33 STO 01 34 XEQ "GAM" 35 ST/ 07 36 .5 37 ST* 01 38 RCL 01 |
39 X<>Y
40 + 41 STO 02 42 LASTX 43 RCL 05 44 - 45 STO 03 46 RCL 00 47 XEQ "HGF" 48 2 49 ST/ 07 50 RCL 05 51 Y^X 52 ST/ 07 53 * 54 RCL 04 55 ST/ 07 56 RCL 05 57 Y^X |
58 ST/ 07
59 * 60 STO 02 61 RCL 05 62 RCL 06 63 - 64 1 65 + 66 XEQ "GAM" 67 ST/ 02 68 1 69 RCL 03 70 - 71 XEQ "GAM" 72 RCL 02 73 * 74 RCL 07 75 + 76 RCL 04 |
77 X^2
78 ENTER^ 79 ENTER^ 80 SIGN 81 - 82 / 83 RCL 06 84 2 85 / 86 Y^X 87 * 88 PI 89 SQRT 90 / 91 END |
( 138 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | / |
X | x | Pnm(x) |
Example: Calculate P1.7-0.6(4.8)
-0.6 ENTER^
1.7 ENTER^
4.8 XEQ "ALF1C" >>>>> 10.67810283
( in 38 seconds )
-Many other relations between the Legendre Functions and the hypergeometric
Functions may be found in the "Handbook of Mathematical Functions".
7°) Associated Legendre Functions of the second kind
( fractional order & degree ) with | x | < 1
Formula: 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 to R07: temp
Flags: /
Subroutines: "1/G" ( 1/Gamma
function ) , "HGF" ( Hypergeometric functions )
01 LBL "ALF2"
02 STO 04 03 RDN 04 STO 05 05 X<>Y 06 STO 06 07 + 08 .5 09 STO 03 10 * 11 CHS 12 STO 01 13 1 14 RCL 05 15 + 16 RCL 06 17 - |
18 RCL 03
19 * 20 STO 02 21 RCL 04 22 X^2 23 XEQ "HGF" 24 STO 07 25 RCL 02 26 RCL 03 27 + 28 XEQ "1/G" 29 2 30 / 31 ST* 07 32 RCL 02 33 RCL 06 34 + |
35 XEQ "1/G"
36 ST/ 07 37 RCL 03 38 ST+ 01 39 ST+ 02 40 ISG 03 41 RCL 00 42 XEQ "HGF" 43 ST* 04 44 RCL 01 45 RCL 05 46 + 47 XEQ "1/G" 48 ST* 04 49 RCL 02 50 RCL 06 51 + |
52 XEQ "1/G"
53 ST/ 04 54 RCL 05 55 RCL 06 56 + 57 1 58 ASIN 59 * 60 SIN 61 ST* 07 62 LASTX 63 COS 64 RCL 04 65 * 66 RCL 07 67 - 68 PI |
69 SQRT
70 * 71 4 72 1 73 RCL 00 74 - 75 / 76 RCL 06 77 2 78 / 79 Y^X 80 * 81 END |
( 125 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | / |
X | x | Qnm(x) |
Examples:
0.4 ENTER^ 1.3
ENTER^ 0.7 XEQ "ALF2" >>>>
Q1.30.4(0.7) = -1.317935680
( in 66 seconds )
2.4 ENTER^ 0.4
ENTER^ 0.1
R/S >>>>
Q0.42.4(0.1) = 0.102528105
( in 30 seconds )
8°) Associated Legendre Functions of the second kind
( fractional order & degree ) with -1 < x < 3
Formula: Qnm(x)
= A (1/2) [ Gam(1+m+n) Gam(-m) / Gam(1+n-m)
|(x-1)/(x+1)|m/2 F(-n ; n+1 ; 1+m ; (1-x)/2 )
+ Gam(m) |(x+1)/(x-1)|m/2 B F(-n ; n+1 ; 1-m ; (1-x)/2
) ]
where A = ei.m.pi &
B = 1
if x > 1 ( the result is a complex
number in this case )
and A = 1
& B = cos(m.pi) if x < 1
-Since Gam(m) and Gam(-m) appear in this formula, it cannot be used
if m is an integer.
Data Registers:
R00 to R07: temp
Flag: F07
Subroutines: "GAM+" or "GAM"
( Gamma function ) , "HGF"
( Hypergeometric functions )
01 LBL "ALF2B"
02 STO 04 03 CLX 04 SIGN 05 STO 03 06 X<>Y 07 CHS 08 STO 01 09 - 10 STO 02 11 X<>Y 12 STO 05 13 ST+ 03 14 1 15 RCL 04 16 - |
17 2
18 / 19 XEQ "HGF" 20 STO 06 21 RCL 03 22 RCL 01 23 - 24 XEQ "GAM+" 25 ST* 06 26 RCL 05 27 CHS 28 XEQ "GAM+" 29 ST* 06 30 RCL 02 31 RCL 05 32 - |
33 XEQ "GAM+"
34 ST/ 06 35 1 36 RCL 05 37 - 38 STO 03 39 RCL 00 40 XEQ "HGF" 41 STO 03 42 RCL 05 43 XEQ "GAM+" 44 ST* 03 45 RCL 04 46 RCL 04 47 1 48 ST- Z |
49 +
50 / 51 SF 07 52 X>0? 53 CF 07 54 ABS 55 RCL 05 56 Y^X 57 SQRT 58 ST/ 03 59 RCL 06 60 * 61 RCL 03 62 FC? 07 63 + 64 1 |
65 CHS
66 ACOS 67 RCL 05 68 * 69 X<>Y 70 P-R 71 0 72 FS? 07 73 STO Z 74 FS?C 07 75 X<> T 76 + 77 2 78 ST/ Z 79 / 80 END |
( 133 bytes / SIZE 007 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | B |
X | x | A |
with Qnm(x) = A + i.B
Examples:
0.7 ENTER^
1.2 ENTER^
1.9 XEQ "ALF2B" >>>>
-0.081513574
X<>Y 0.112193809 thus,
Q1.20.7(1.9) = -0.081513574
+ 0.112193809 . i ( in 53 seconds
)
0.4 ENTER^
1.3 ENTER^
0.7 R/S
>>>> Q1.30.4(0.7)
= -1.317935682 ( in 37 seconds )
( B is always equal to zero if | x | < 1 )
9°) Associated Legendre Functions of the second kind
( fractional order & degree ) with | x | > 1
Formula: Qnm(x) = ei.mpi 2-n-1 pi1/2 x-n-m-1 (x2-1)m/2 F(1+n/2+m/2 ; 1/2+n/2+m/2 ; n+3/2 ; 1/x2 ) Gamma(1+n+m) / Gamma(n+3/2)
( the result is a complex number )
-If x < -1 and -n-m-1 is not an integer, there will be
a "DATA ERROR" message.
Data Registers:
R00 to R07: temp
Flags: /
Subroutines: "GAM" ( Gamma function
) , "HGF" ( Hypergeometric functions )
01 LBL "ALF2C"
02 STO 04 03 CLX 04 SIGN 05 + 06 STO 03 07 STO 05 08 X<>Y 09 STO 06 10 + 11 .5 |
12 ST+ 03
13 * 14 STO 02 15 LASTX 16 + 17 STO 01 18 RCL 04 19 X^2 20 1/X 21 XEQ "HGF" 22 STO 01 |
23 RCL 05
24 RCL 06 25 + 26 XEQ "GAM" 27 ST* 01 28 RCL 03 29 XEQ "GAM" 30 ST/ 01 31 RCL 01 32 1 33 RCL 00 |
34 -
35 RCL 06 36 Y^X 37 PI 38 * 39 SQRT 40 * 41 RCL 04 42 ST+ X 43 RCL 05 44 Y^X |
45 /
46 1 47 CHS 48 ACOS 49 RCL 06 50 * 51 X<>Y 52 P-R 53 END |
( 80 bytes / SIZE 007 )
STACK | INPUTS | OUTPUTS |
Z | m | / |
Y | n | B |
X | x | A |
with Qnm(x) = A + i.B
Examples: Compute Q1.20.7(1.9)
0.7 ENTER^
1.2 ENTER^
1.9 XEQ "ALF2C" yields
-0.081513570
X<>Y 0.112193804 thus,
Q1.20.7(1.9) = -0.081513570
+ 0.112193804 . i ( in 29 seconds
)
-Similarly, we find Q74(3) = 0.004063232 ( in 18 seconds ) ( "PQMN" would give a wrong result! )
-This program will not work if n+3/2 = 0,-1,-2,-3,-4, ..... unless
you replace line 21 by XEQ "HGF2" ( cf "Hypergeometric Function
for the HP-41" )
and line 29 by FC? 00 XEQ "GAM" FC?C 00
-With this modification, you'll find, for example: Q -1.52(7) = 0.114719166 ( in 16 seconds )
-If you need | Qnm(x) | only, delete lines
54 to 60 and for instance: | Q1.20.7(1.9)
| = 0.138679169 ( this real result is in L-register
otherwise )
References:
[1] Abramowitz and Stegun , "Handbook of Mathematical Functions"
- Dover Publications - ISBN 0-486-61272-4
[2] Press , Vetterling , Teukolsky , Flannery , "Numerical Recipes
in C++" - Cambridge University Press - ISBN 0-521-75033-4