MCPcopy Create free account
hub / github.com/arguiot/TheoremJS / lngamma

Method lngamma

__test__/theorem.js:77–101  ·  view source on GitHub ↗
(z)

Source from the content-addressed store, hash-verified

75 return new BigNumber(buffer.times(2).toFixed(n - 1))
76 }
77 lngamma(z) {
78 const g_ln = 607/128;
79 const p_ln = [
80 0.99999999999999709182,
81 57.156235665862923517,
82 -59.597960355475491248,
83 14.136097974741747174,
84 -0.49191381609762019978,
85 0.33994649984811888699e-4,
86 0.46523628927048575665e-4,
87 -0.98374475304879564677e-4,
88 0.15808870322491248884e-3,
89 -0.21026444172410488319e-3,
90 0.21743961811521264320e-3,
91 -0.16431810653676389022e-3,
92 0.84418223983852743293e-4,
93 -0.26190838401581408670e-4,
94 0.36899182659531622704e-5
95 ];
96 if(z < 0) return Number('0/0');
97 let x = p_ln[0];
98 for(var i = p_ln.length - 1; i > 0; --i) x += p_ln[i] / (z + i);
99 const t = z + g_ln + 0.5;
100 return new BigNumber(Number(.5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z)).toFixed(10));
101 }
102 log(x, base, n = 15) {
103 if (x.isComplex) {
104 return x.log(base)

Callers 2

gammaMethod · 0.95
gamma.jsFile · 0.80

Calls 1

logMethod · 0.45

Tested by

no test coverage detected