`zeta(s)` and `eta(s)` return `NaN` or `Inf` for every real s < `-170.62`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start in src/gamma.jl at _zeta(s::ComplexOrReal{Float64}) and inspect both the real-axis branch and the @pg_horner expansion. Reproduce the reported zeta values in Julia, then verify the relevant behavior around the gamma overflow threshold and negative even integers. Done means real inputs below -170.62 no longer incorrectly produce NaN or Inf, including the reported trivial zeros and finite values.
Written by the indexing model from the issue text.
Description
For example:
julia> using SpecialFunctions
julia> zeta(-170.0)
-0.0
julia> zeta(-172.0) # true value 0 (trivial zero): https://www.wolframalpha.com/input?i=zeta%28-172%29
NaN
julia> zeta(-180.0) # true value 0 (trivial zero): https://www.wolframalpha.com/input?i=zeta%28-180%29
NaN
julia> zeta(-200.0) # true value 0 (trivial zero): https://www.wolframalpha.com/input?i=zeta%28-200%29
NaN
julia> zeta(-250.0) # true value 0 (trivial zero): https://www.wolframalpha.com/input?i=zeta%28-250%29
NaN
julia> zeta(-175.0) # true value 7.4526910304300896e177: https://www.wolframalpha.com/input?i=zeta%28-175%29
Inf
julia> zeta(-171.0) # true value 1.2819489863517886e172: https://www.wolframalpha.com/input?i=zeta%28-171%29
Inf
Possible Cause (as considered by an AI)
src/gamma.jl, _zeta(s::ComplexOrReal{Float64}):
elseif real(s) < 0.5
absim = abs(imag(s))
if abs(real(s)) + absim < 1e-3 # Taylor series for small |s|
...
end
if absim > 12 # amplitude of sinpi(s/2) ≈ exp(imag(s)*π/2)
# avoid overflow/underflow (issue #128)
lg = loggamma(1 - s)
...
else
return zeta(1 - s) * gamma(1 - s) * sinpi(s*0.5) * twoπ^s * invπ
end
The else branch is the one from issue #128 that "avoids overflow" only when absim > 12.
On the real axis gamma(1 - s) is Inf for all s < -170.62, sinpi(s*0.5) is ∓0.0 at negative even integers, and twoπ^s is a tiny denormal-range factor that would have brought the product back into range had the multiplication been done in log space.
For the second regime, the @pg_horner macro (same file) expands to a Horner scheme whose coefficients are m*(m+1)*… products; for m ≈ 5.7e19 the third such product exceeds floatmax.
- Dominant language
- Julia
- Stars
- 384
- Forks
- 115
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaMath/SpecialFunctions.jl
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliaMath/SpecialFunctions.jl#570 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 40/100
JuliaMath/SpecialFunctions.jl#569 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
JuliaMath/SpecialFunctions.jl#567 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 56/100
JuliaMath/SpecialFunctions.jl#563 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
JuliaMath/SpecialFunctions.jl#560 ·
Maintainers usually reply within 1 day
All issues in JuliaMath/SpecialFunctions.jl
Similar issues
-
documentation priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
epiforecasts/BVDOutbreakSize#1260 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TuringLang/Turing.jl#2917 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Validate UserDemand return_factorPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days