The Museum of HP Calculators


Gamma Function for the HP-65

This program is Copyright © 1974 by Hewlett-Packard and is used here by permission. This program was originally published in the HP-65 Pac 2.

This program is supplied without representation or warranty of any kind. Hewlett-Packard Company and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

This program approximates the value of gamma function Γ(x) for 1 < x <70.

Γ(x)  =0...∞ tx-1e-t dt

Formulas

Γ(x) = (x - 1)×Γ(x - 1)

For 1≤ x ≤ 2, polynomial approximation can be used.
Γ(x) ~ 1 + b1 (x - 1) + b2 (x- 1)2 + . . . + b8 (x - 1)8

where
b1 =-0.577191652, b2 = 0.988205891
b3 =-0.897056937, b4 = 0.918206857
b5 = -0.756704078, b6 =0.482199394
b7 = -0.193527818, b8 = 0.035868343

Note: This program can be used to find the generalized factorial x! for 0 ≤ x ≤ 69.
                 x! = Γ(x+ 1)

Instructions

Step Instructions Input Data/Units Keys Output Data/Units
1 Enter program on card 1      
2 Initialize   A  
3 Enter program on card 2      
4 Enter x  x A Γ(x)
  For a new value of x go to 4      

Examples

Γ(5.25) = 35.21
7! = Γ(8) = 5040.00
2.34! = Γ(3.34) = 2.80

The Program

Card 1

 CODE  KEYS
   23  LBL
   11  A 
   83  .
   00  0
   03  3
   05  5
   08  8
   06  6
   08  8
   03  3
   04  4
   03  3
33 01  STO 1
   83  .
   01  1
   09  9
   03  3
   05  5
   02  2
   07  7
   08  8
   01  1
   08  8
   42  CHS
33 02  STO 2
   83  .
   04  4
   08  8
   02  2
   01  1
   09  9
   09  9
   03  3
   09  9
   04  4
33 03  STO 3
   83  .
   07  7
   05  5
   06  6
   07  7
   00  0
   04  4
   00  0
   07  7
   08  8
   42  CHS
33 04  STO 4
   83  .
   09  9
   01  1
   08  8
   02  2
   00  0
   06  6
   08  8
   05  5
   07  7
33 05  STO 5
   83  .
   08  8
   09  9
   07  7
   00  0
   05  5
   06  6
   09  9
   03  3
   07  7
   42  CHS
33 06  STO 6
   83  .
   09  9
   08  8
   08  8
   02  2
   00  0
   05  5
   08  8
   09  9
   01  1
33 07  STO 7
   83  .
   05  5
   07  7
   07  7
   01  1
   09  9
   01  1
   06  6
   05  5
   02  2
   42  CHS
33 08  STO 8 
   84  R/S
35 01 g NOP
35 01 g NOP
35 01 g NOP
35 01 g NOP
35 01 g NOP

Card 2

 CODE  KEYS
   23  LBL
   11  A 
   41  ENTER↑ 
   01  1
   51  - 
   00  0
35 24  g x>y
   00  0 
   81  ÷
35 07  g x⇔y
   01  1
33 08  STO 8
   23  LBL
   02  2
35 07  g x⇔y
35 24  g x>y
   22  GTO
   01  1
   41  ENTER↑
   41  ENTER↑
   41  ENTER↑
34 01  RCL 1
   71  ×
34 02  RCL 2
   61  +
   71  ×
34 03  RCL 3
   61  +
   71  ×
34 04  RCL 4
   61  + 
   71  ×
34 05  RCL 5
   61  + 
   71  ×
34 06  RCL 6
   61  +
   71  ×
34 07  RCL 7
   61  +
   71  ×
   83  .
   05  5
   07  7
   07  7
   01  1
   09  9
   01  1
   06  6
   05  5
   02  2
   42  CHS
   61  +
   71  ×
   01  1
   61  +
34 08  RCL 8
   71  ×
   84  R/S
   23  LBL
   01  1
   33  STO
   71  ×
   08  8
35 07  g x⇔y
   51  -
   01  1
   22  GTO
   02  2
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP
35 01  g NOP

Register Use

R1  b8
R2  b7
R3  b6
R4  b5
R5  b4
R6  b3
R7  b2
R8  used
R9  used

Go back to the software library
Go back to the main exhibit hall