Gamma function: Difference between revisions

Content added Content deleted
(add lambdatalk code)
(→‎{{header|R}}: Issue found in previous R implementation step using 'seq.int' function: imaginary parts discarded in coercion; The edit resolved the issue and retain the imaginary part to make sure the precision. The edited lanczos(z) was benchmarked with gammaz(z) and complex_gamma(z) from 'pracma' and 'hypergeo' libraries to cross validate the solution accuracy)
Line 3,911: Line 3,911:
{
{
z <- z - 1
z <- z - 1
x <- p[1] + sum(p[-1]/seq.int(z+1, z+g+1))
x <- p[1]
for (i in 1:8) {
x <- x+p[i+1]/(z+i)
}
tt <- z + g + 0.5
tt <- z + g + 0.5
sqrt(2*pi) * tt^(z+0.5) * exp(-tt) * x
sqrt(2*pi) * tt^(z+0.5) * exp(-tt) * x