Skip to content

Commit 0ec4fa3

Browse files
devmotionastrozotquytelda
authored
Backport fixes in #419 and #422 to SpecialFunctions 1.8 branch (#423)
* 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]>
1 parent e2013a9 commit 0ec4fa3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/gamma.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ function _zeta(s::ComplexOrReal{Float64})
439439
lg = loggamma(1 - s)
440440
rehalf = real(s)*0.5
441441
return zeta(1 - s) * exp(lg + absim*halfπ + s*log2π) * inv2π * Complex(
442-
sinpi(rehalf), copysign(cospi(rehalf), imag(s))
442+
sinpi(rehalf), flipsign(cospi(rehalf), imag(s))
443443
)
444444
else
445445
return zeta(1 - s) * gamma(1 - s) * sinpi(s*0.5) * twoπ^s * invπ

src/gamma_inc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ function gamma_inc_temme_1(a::Float64, x::Float64, z::Float64, ind::Integer)
670670
l = x/a
671671
y = -a * LogExpFunctions.logmxp1(l)
672672
if a*eps()*eps() > 3.28e-3
673-
throw(DomainError((a, x, ind_), "P(a,x) or Q(a,x) is computationally indeterminant in this case."))
673+
throw(DomainError((a, x, ind), "P(a,x) or Q(a,x) is computationally indeterminant in this case."))
674674
end
675675
c = exp(-y)
676676
w = 0.5*erfcx(sqrt(y))

test/gamma.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ end
266266
@test 1e-10 > relerr(zeta(.4 + 4053.0im), -0.1248993234383550+0.9195498409364987im)
267267
@test 1e-13 > relerr(zeta(.4 + 12.01im), 1.0233184799021265846512208845-0.8008078492939259287905322251im)
268268
@test zeta(.4 + 12.01im) == conj(zeta(.4 - 12.01im))
269+
270+
# issue #420
271+
@test zeta(-2+13im) conj(zeta(-2-13im)) -0.30019019877262619754737023564024299182018857012958761814433485-5.5583626885487917197617298283836431070419020764882132809770386im
272+
@test zeta(-6+13im) conj(zeta(-6-13im)) 133.4764526350263089084083707864441932569167866714712267139316498-54.15465727586582149098585229287107039070546786014930791081909684im
273+
@test 1e-12 > relerr(zeta(-2+13im, 3), 2.3621038290867825837364823054-3.9497600485207119519185591345im)
274+
@test 1e-12 > relerr(zeta(-2-13im, 3), 2.3621038290867825837364823054+3.9497600485207119519185591345im)
269275
end
270276

271277
@testset "logabsbinomial" begin

0 commit comments

Comments
 (0)