Skip to content

Commit

Permalink
Backport fixes in #419 and #422 to SpecialFunctions 1.8 branch (#423)
Browse files Browse the repository at this point in the history
* Small bug on gamma_inc_temme_1 fixed (#419)

* Fix zeta sign flipping in some input regions (#420) (#422)

Co-authored-by: Marco Lombardi <[email protected]>
Co-authored-by: Quytelda Kahja <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2023
1 parent e2013a9 commit 0ec4fa3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function _zeta(s::ComplexOrReal{Float64})
lg = loggamma(1 - s)
rehalf = real(s)*0.5
return zeta(1 - s) * exp(lg + absim*halfπ + s*log2π) * inv2π * Complex(
sinpi(rehalf), copysign(cospi(rehalf), imag(s))
sinpi(rehalf), flipsign(cospi(rehalf), imag(s))
)
else
return zeta(1 - s) * gamma(1 - s) * sinpi(s*0.5) * twoπ^s * invπ
Expand Down
2 changes: 1 addition & 1 deletion src/gamma_inc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function gamma_inc_temme_1(a::Float64, x::Float64, z::Float64, ind::Integer)
l = x/a
y = -a * LogExpFunctions.logmxp1(l)
if a*eps()*eps() > 3.28e-3
throw(DomainError((a, x, ind_), "P(a,x) or Q(a,x) is computationally indeterminant in this case."))
throw(DomainError((a, x, ind), "P(a,x) or Q(a,x) is computationally indeterminant in this case."))
end
c = exp(-y)
w = 0.5*erfcx(sqrt(y))
Expand Down
6 changes: 6 additions & 0 deletions test/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ end
@test 1e-10 > relerr(zeta(.4 + 4053.0im), -0.1248993234383550+0.9195498409364987im)
@test 1e-13 > relerr(zeta(.4 + 12.01im), 1.0233184799021265846512208845-0.8008078492939259287905322251im)
@test zeta(.4 + 12.01im) == conj(zeta(.4 - 12.01im))

# issue #420
@test zeta(-2+13im) conj(zeta(-2-13im)) -0.30019019877262619754737023564024299182018857012958761814433485-5.5583626885487917197617298283836431070419020764882132809770386im
@test zeta(-6+13im) conj(zeta(-6-13im)) 133.4764526350263089084083707864441932569167866714712267139316498-54.15465727586582149098585229287107039070546786014930791081909684im
@test 1e-12 > relerr(zeta(-2+13im, 3), 2.3621038290867825837364823054-3.9497600485207119519185591345im)
@test 1e-12 > relerr(zeta(-2-13im, 3), 2.3621038290867825837364823054+3.9497600485207119519185591345im)
end

@testset "logabsbinomial" begin
Expand Down

0 comments on commit 0ec4fa3

Please sign in to comment.