September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -3,36 +3,35 @@ func gamma(z) {
|
|||
func withinepsilon(x) {
|
||||
abs(x - abs(x)) <= epsilon
|
||||
}
|
||||
|
||||
|
||||
var p = [
|
||||
676.5203681218851, -1259.1392167224028,
|
||||
771.32342877765313, -176.61502916214059,
|
||||
12.507343278686905, -0.13857109526572012,
|
||||
9.9843695780195716e-6, 1.5056327351493116e-7,
|
||||
]
|
||||
|
||||
var result;
|
||||
z = Complex(z)
|
||||
const pi = Complex.pi
|
||||
|
||||
if (z.real < 0.5) {
|
||||
result = (pi / (sin(pi * z) * gamma(Complex(1) - z)))
|
||||
|
||||
var result = 0
|
||||
const pi = Num.pi
|
||||
|
||||
if (z.re < 0.5) {
|
||||
result = (pi / (sin(pi * z) * gamma(1 - z)))
|
||||
}
|
||||
else {
|
||||
z -= 1
|
||||
var x = 0.99999999999980993
|
||||
|
||||
|
||||
p.each_kv { |i, v|
|
||||
x += v/(z + i + 1)
|
||||
}
|
||||
|
||||
|
||||
var t = (z + p.len - 0.5)
|
||||
result = (sqrt(pi*2) * t**(z+0.5) * exp(-t) * x)
|
||||
}
|
||||
|
||||
withinepsilon(result.im) ? result.real : result
|
||||
|
||||
withinepsilon(result.im) ? result.re : result
|
||||
}
|
||||
|
||||
|
||||
for i in 1..10 {
|
||||
say ("%.14e" % gamma(i/3));
|
||||
say ("%.14e" % gamma(i/3))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue