-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gamma function should return Inf at -1, -2, -3...... #163
Comments
There isn't a well-defined limit:
(I am sympathetic to returning |
NaN makes sense If I wan to plot gamma function from [-5, 5]. I can't do it, because it throws an error. If NaN is returned then it will be fine. right now I have to use python scipy.special.gamma instead, which return Inf at -1, -2, -3. I think it would be good not throwing any error on undefined points. |
I'd be in favour of this change: it's particularly annoying for the |
It should return julia> cot(0.0)
Inf |
That only works for because zeros are signed:
|
Although |
I agree with @putianyi889 This reciprocal argument also applies to @dlfivefifty 's example of And this of course simplifies plotting as @Jinwei1987 mentioned. |
An update: I notice that Also, I found the following inconsistency julia> exp(loggamma(-1-0.01))
99.59128511327795
julia> exp(loggamma(-1+0.01))
ERROR: DomainError with -0.99:
`gamma(x)` must be non-negative |
@bobbielf2, the latter example is not inconsistent: This may be why I would be in favor of returning |
Hi @stevengj, thanks for the explanation. I thought that all the negative inputs to julia> exp(loggamma(-0.99+0im))
-100.43695466580859 - 1.229997950475903e-14im I guess each time I need to enforce the continuity of julia> real(gamma(-1+0im))
-Inf This behavior falls into "questionable" by your definition, but I honestly feel like it would be nice to have |
Yes, for the same reason that |
Hi @stevengj, I see that type stability is important.
If it ended up that Thanks for the discussion. |
at -1, -2, -3... gamma should return Inf like gamma(0)
julia> gamma(0)
Inf
julia> gamma(-1.0)
ERROR: DomainError with -1.0:
NaN result for non-NaN input.
Stacktrace:
[1] nan_dom_err at ./math.jl:339 [inlined]
[2] gamma(::Float64) at /Users/zhengjinwei/.julia/packages/SpecialFunctions/fvheQ/src/gamma.jl:558
[3] top-level scope at none:0
The text was updated successfully, but these errors were encountered: