Closed
Description
In scipy 0.18.0, I noticed that loggamma
ignores the sign of zero in the imaginary part when choosing the branch cut, which seems wrong:
>>> scipy.special.loggamma(-3.4 + 0.0j)
(-1.1211918156538432-12.566370614359172j)
>>> scipy.special.loggamma(complex(-3.4, -0.0))
(-1.1211918156538432-12.566370614359172j)
>>> scipy.special.loggamma(-3.4 - 1e-16j)
(-1.1211918156538432+12.566370614359172j)
I believe the imaginary part in the second return value should be positive. Otherwise you violate the identity loggamma(z) = conj(loggamma(conj(z)))
.
(I noticed this when I was implementing a new lgamma
function for Julia, validating against the one in SciPy and the one in Mathematica, and I was checking corner cases of the branch cuts: JuliaLang/julia#18330.)