Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
def gamma:
[
1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108, -0.04200263503409523553,
0.16653861138229148950, -0.04219773455554433675, -0.00962197152787697356, 0.00721894324666309954,
-0.00116516759185906511, -0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824,
-0.00000125049348214267, 0.00000113302723198170, -0.00000020563384169776, 0.00000000611609510448,
0.00000000500200764447, -0.00000000118127457049, 0.00000000010434267117, 0.00000000000778226344,
-0.00000000000369680562, 0.00000000000051003703, -0.00000000000002058326, -0.00000000000000534812,
0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119, 0.00000000000000000141,
-0.00000000000000000023, 0.00000000000000000002
] as $a
| (. - 1) as $y
| ($a|length) as $n
| reduce range(2; 1+$n) as $an
($a[$n-1]; (. * $y) + $a[$n - $an])
| 1 / . ;

View file

@ -0,0 +1,16 @@
# for reals, but easily extended to complex values
def gamma_by_lanczos:
def pow(x): if x == 0 then 1 elif x == 1 then . else x * log | exp end;
. as $x
| ((1|atan) * 4) as $pi
| if $x < 0.5 then $pi / ((($pi * $x) | sin) * ((1-$x)|gamma_by_lanczos ))
else
[ 0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.32342877765313, -176.61502916214059, 12.507343278686905,
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7] as $p
| ($x - 1) as $x
| ($x + 7.5) as $t
| reduce range(1; $p|length) as $i
($p[0]; . + ($p[$i]/($x + $i) ))
* ((2*$pi) | sqrt) * ($t | pow($x+0.5)) * ((-$t)|exp)
end;

View file

@ -0,0 +1,5 @@
def gamma_by_stirling:
def pow(x): if x == 0 then 1 elif x == 1 then . else x * log | exp end;
((1|atan) * 8) as $twopi
| . as $x
| (($twopi/$x) | sqrt) * ( ($x / (1|exp)) | pow($x));

View file

@ -0,0 +1,6 @@
def pad(n): tostring | . + (n - length) * " ";
" i: gamma lanczos tgamma",
(range(1;11)
| . / 3.0
| "\(pad(18)): \(gamma|pad(18)) : \(gamma_by_lanczos|pad(18)) : \(tgamma)")

View file

@ -0,0 +1,12 @@
$ jq -M -r -n -f Gamma_function_Stirling.jq
i: gamma lanczos tgamma
0.3333333333333333: 2.6789385347077483 : 2.6789385347077483 : 2.678938534707748
0.6666666666666666: 1.3541179394264005 : 1.3541179394263998 : 1.3541179394264005
1 : 1 : 0.9999999999999998 : 1
1.3333333333333333: 0.8929795115692493 : 0.8929795115692494 : 0.8929795115692493
1.6666666666666667: 0.9027452929509336 : 0.9027452929509342 : 0.9027452929509336
2 : 1 : 1.0000000000000002 : 1
2.3333333333333335: 1.190639348758999 : 1.1906393487589995 : 1.190639348758999
2.6666666666666665: 1.5045754882515399 : 1.5045754882515576 : 1.5045754882515558
3 : 1.9999999999939684 : 2.0000000000000013 : 2
3.3333333333333335: 2.778158479338573 : 2.778158480437665 : 2.7781584804376647