SpecialFunctions.jl icon indicating copy to clipboard operation
SpecialFunctions.jl copied to clipboard

`gamma(0)` returns the wrong value.

Open oscardssmith opened this issue 3 years ago • 1 comments

This issue is the opposite issue of https://github.com/JuliaMath/SpecialFunctions.jl/issues/163. Currently gamma(0.0) returns Inf as does gamma(0.0+0.0im), and gamma(0.0-0.0im) This isn't the correct limit because

gamma(0. + 1e-16im)
0.6123233995736787 - 1.0000000000000034e16im

and

julia> gamma(0.0-1e-16im)
0.6123233995736787 + 1.0000000000000034e16im

which really makes it seem like gamma of complex 0s should return an appropriate complex infinity and gamma(0.0) should error.

oscardssmith avatar Oct 25 '22 15:10 oscardssmith

Usually for real arguments we take the limit along the real line, with the sign of zero determining the direction of the limit:

julia> gamma(1e-16)
1.0e16

julia> gamma(0.0)
Inf

julia> gamma(-1e-16)
-1.0e16

julia> gamma(-0.0)
-Inf

For a complex 0 possibly we should throw since the limit depends on the angle at which you approach zero?

stevengj avatar Oct 25 '22 17:10 stevengj