Euler's constant gamma

This number is defined:

gamma=H.N-LN(N)

where N goes to infinity and the N-th harmonic number is defined to be the sum

H.N=1+(1/2)+(1/3)+...+(1/N)

of the reciprocal of the integers from 1 to N.

ALGORITHM
We use the formula

LN(N)+gamma+error=
X/FACT(1)-X**2/(2*FACT(2))+X**3/(3*FACT(3))...

where FACT is the factorial function and L. Euler proved that error=O(EXP(-X)/X).

 

IMPLEMENTATION
Unit: program
 
Interface: the LN function
 
Result: program displays on the screen first 60 significant decimal digits of the gamma constant
 


X = 130; W=500; P = 130
numeric digits P
N = X; F = 1; D = 1; S = X
do K = 2 to W
  N = - N * X; F = F * K; D = F * K
  S = S + N / D
end
say S - LN(X, P)

 

This program requires about one minute of processing time. There is an another way to obtain the value of the gamma constant: we can compute the gamma number only once and save its value into the text of the function. The following GAMMA_CONST function can be used to compute the first P decimal digits of gamma, for P=1,...,60.

 


GAMMA_CONST: return,
"0.5772156649015328606065120900" ||,
"824024310421593359399235988058"

 

CONNECTIONS

Literature
Brent R. P. Ramanujan and Euler's Constant
Computer Sciences Laboratory, Australian National University, August 1993


Cover Contents Index Main page Rexx page   Mail

last modified 31th July 2001
Copyright © 2000-2001 Vladimir Zabrodsky
Czech Republic
 

1