/usr/share/yacas/scripts/specfunc.rep/gammaconst.ys is in yacas 1.3.6-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | GammaConstNum() :=
[
Local(k, n, A, B, U'old, U, V'old, V, prec, result);
prec:=Builtin'Precision'Get();
NonN([
Builtin'Precision'Set(prec+IntLog(prec,10)+3); // 2 guard digits and 1 to compensate IntLog
n:= 1+Ceil(prec*0.5757+0.2862); // n>(P*Ln(10)+Ln(Pi))/4
A:= -Internal'LnNum(n);
B:=1;
U:=A;
V:=1;
k:=0;
U'old := 0; // these variables are for precision control
V'old := 0;
While(U'old-U != 0 Or V'old-V != 0)
[
k++;
U'old:=U;
V'old:=V;
// B:=N( B*n^2/k^2 );
B:=MultiplyNum(B,n^2/k^2); // slightly faster
// A:=N( (A*n^2/k+B)/k );
A:=MultiplyNum(MultiplyNum(A,n^2/k)+B, 1/k); // slightly faster
U:=U+A;
V:=V+B;
];
If(InVerboseMode(), Echo("GammaConstNum: Info: used", k, "iterations at working precision", Builtin'Precision'Get()));
result:=MathDivide(U,V); // N(U/V)
]);
Builtin'Precision'Set(prec); // restore precision
RoundTo(result, prec); // return correctly rounded result
];
|