HP Forums
Hypergeometric function - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP-41C Software Library (/forum-11.html)
+--- Thread: Hypergeometric function (/thread-20742.html)



Hypergeometric function - Namir - 10-30-2023 05:14 PM

Hypergeometric function for HP-41C
=================================

Code calculates values for the hypergeometric function F(alpha, beta, gamma, x). The code uses the gamma function to help calculate the value of the hypergeometric function. The code uses two programs to calculate the hypergeometric function. The programs are HGFX and GAM4 and must be loaded separately (i.e. after you load one, press the [GTO][.][.] buttons).

Memory Map
=========

Code:
R00 = x
R01 = alpha
R02 = beta
R03 = gamma_var
R04 = toler
R05 = k (loop control variable)
R06 = sum - > fx value
R07 = x in GAM4
R08 = used in GAM 4
R10 = used 
R11 = gamma(alpha)
R12 = gamma(beta)
R123 = gamma(gamma_var)


HP-41C Listing
==============

Code:
01 LBL "HGFX"
02 A^B^C^X?
03 PROMPT
04 STO 00
05 RDN
06 STO 03
07 RDN
08 STO 02
09 RDN
10 STO 01
11 TOLER?
12 PROMPT
13 x=0?
14 1.00E-15
15 STO 04
16 1
17 STO 06
18 0
19 STO 05
20 RCL 01
21 XEQ "GAM4"
22 STO 11
23 RCL 02
24 XEQ "GAM4"
25 STO 12
26 RCL 03
27 XEQ "GAM4"
28 STO 13
29 LBL 00
30 1
31 STO+ 05
32 RCL 01
33 RCL 05
34 +
35 XEQ "GAM4"
36 RCL 11
37 /
38 STO 10
39 RCL 03
40 RCL 05
41 +
42 XEQ "GAM4"
43 RCL 13
44 /
45 STO/ 10
46 RCL 02
47 RCL 05
48 +
49 XEQ "GAM4"
50 RCL 12
51 /
52 STO* 10
53 RCL 10
54 RCL 05
55 N!
56 /
57 RCL 00
58 RCL 05
59 Y?X
60 *
61 STO+ 06
62 ABS
63 RCL 04
64 X=Y?
65 GTO 00
66 RCL 06
67 RTN
68 .END.



Code:
01 LBL "GAM4"
02 1
03 X<>Y
04 LBL 02
05 X>0?
06 GTO 01
07 ENTER
08 RDN
09 ×
10 RDN
11 1
12 +
13 GTO 02
14 LBL 01
15 STO 08
16 X<>Y
17 STO 07
18 76.18009173
19 RCL 08
20 1
21 +
22 /
23 86.50532033
24 RCL 08
25 2
26 +
27 /
28 -
29 24.01409824
30 RCL 08
31 3
32 +
33 /
34 +
35 1.231739572
36 RCL 08
37 4
38 +
39 /
40 -
41 1.208650974?-3
42 RCL 08
43 5
44 +
45 /
46 +
47 5.395239385?-6
48 RCL 08
49 6
50 +
51 /
52 -
53 1
54 +
55 PI
56 2
57 *
58 SQRT
59 *
60 RCL 08
61 /
62 LN
63 RCL 08
64 5.5
65 +
66 LN
67 RCL 08
68 0.5
69 +
70 *
71 +
72 RCL 08
73 -
74 5.5
75 -
76 EXP
77 RCL 07
78 /
79 RTN
80 .END.

Usage
=====

1) Press [XEQ] [ALPHA]HGFX[ALPHA]. The program displays the prompt "A^B^C^X?"
2) Enter the value for parameter alpha and press ENTER.
3) Enter the value for parameter beta and press ENTER.
4) Enter the value for parameter gamma and press ENTER.
5) Enter the value for x and press R/S. The program displays the prompt "TOLER?"
6) Enter a small value for the tolerance and press R/S.
7) The program displays the value of the hypergeometric function.

Example
=======

To calculate F(1.5, 1.5, 2.5, 0.3), perform the following steps:

1) Press [XEQ] [ALPHA]HGFX[ALPHA]. The program displays the prompt "A^B^C^X?"
2) Enter the value 1.5 for parameter alpha and press ENTER.
3) Enter the value 1.5 for parameter beta and press ENTER.
4) Enter the value 2.5 for parameter gamma and press ENTER.
5) Enter the value 0.3 for x and press R/S. The program displays the prompt "TOLER?"
6) Enter a small value 1E-15 for the tolerance and press R/S.
7) The program displays 1.36956073 as the value of the hypergeometric function.