Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,81 @@
|
|||
\*********************************************
|
||||
\Subject: Comparing five methods for
|
||||
\ computing Euler's constant 0.5772...
|
||||
\---------------------------------------------
|
||||
|
||||
include xpllib; \for Print
|
||||
define Epsilon = 1e-6;
|
||||
|
||||
real A, B, H, N2, R, U, V, S(2), B2;
|
||||
int K, K2, M, N;
|
||||
[Print("From the definition, error 3e-10\n");
|
||||
N:= 400; H:= 1.;
|
||||
for K:= 2 to N do
|
||||
H:= H + 1.0/float(K);
|
||||
\Faster convergence: Negoi, 1997
|
||||
A:= Ln(float(N) + 0.5 + 1.0/(24.*float(N)));
|
||||
Print("Hn %1.16f\n", H);
|
||||
Print("gamma %1.16f\nK = %d\n\n", H-A, N);
|
||||
|
||||
Print("Sweeney, 1963, error 3e-10\n");
|
||||
N:= 21; S(0):= 0.; S(1):= float(N);
|
||||
R:= float(N); K:= 1;
|
||||
repeat
|
||||
K:= K+1;
|
||||
R:= R * float(N) / float(K);
|
||||
S(K&1):= S(K&1) + R/float(K);
|
||||
until R <= Epsilon;
|
||||
Print("gamma %1.16f\nK = %d\n\n", S(1)-S(0)-Ln(float(N)), K);
|
||||
|
||||
Print("Bailey, 1988\n");
|
||||
N:= 5; A:= 1.; H:= 1.;
|
||||
N2:= Pow(2., float(N));
|
||||
R:= 1.; K:= 1;
|
||||
repeat
|
||||
K:= K+1;
|
||||
R:= R * N2 / float(K);
|
||||
H:= H + 1.0/float(K);
|
||||
B:= A; A:= A + R*H;
|
||||
until abs(B-A) <= Epsilon;
|
||||
A:= A * N2 / Exp(N2);
|
||||
Print("gamma %1.16f\nK = %d\n\n", A-float(N)*Ln(2.), K);
|
||||
|
||||
Print("Brent-McMillan, 1980\n");
|
||||
N:= 13; A:= -Ln(float(N));
|
||||
B:= 1.; U:= A; V:= B;
|
||||
N2:= float(N*N); K2:= 0; K:= 0;
|
||||
repeat
|
||||
K2:= K2 + 2*K + 1;
|
||||
K:= K+1;
|
||||
A:= A * N2 / float(K);
|
||||
B:= B * N2 / float(K2);
|
||||
A:= (A + B) / float(K);
|
||||
U:= U + A;
|
||||
V:= V + B;
|
||||
until abs(A) <= Epsilon;
|
||||
Print("gamma %1.16f\nK = %d\n\n", U/V, K);
|
||||
|
||||
Print("How Euler did it in 1735\n");
|
||||
\Bernoulli numbers with even indices
|
||||
B2:= [1.0, 1.0/6., -1.0/30., 1.0/42., -1.0/30.,
|
||||
5.0/66., -691.0/2730., 7.0/6., -3617.0/510., 43867.0/798.];
|
||||
M:= 7; N:= 10;
|
||||
\Nth harmonic number
|
||||
H:= 1.;
|
||||
for K:= 2 to N do
|
||||
H:= H + 1.0/float(K);
|
||||
Print("Hn %1.16f\n", H);
|
||||
H:= H - Ln(float(N));
|
||||
Print(" -ln %1.16f\n", H);
|
||||
\Expansion C:= -digamma(1)
|
||||
A:= -1.0 / (2.*float(N));
|
||||
N2:= float(N*N);
|
||||
R:= 1.;
|
||||
for K:= 1 to M do [
|
||||
R:= R * N2;
|
||||
A:= A + B2(K)/(2.*float(K)*R);
|
||||
];
|
||||
Print("err %1.16f\ngamma %1.16f\nK = %d", A, H+A, N+M);
|
||||
|
||||
Print("\n\nC = 0.57721566490153286...\n");
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue